Skip to content

Commit

Permalink
Mypi fix (#231)
Browse files Browse the repository at this point in the history
  • Loading branch information
SukramJ authored Jan 25, 2022
1 parent 66c362c commit be5c2b0
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 14 deletions.
5 changes: 1 addition & 4 deletions hahomematic/central_unit.py
Original file line number Diff line number Diff line change
Expand Up @@ -519,10 +519,7 @@ async def get_install_mode(self, interface_id: str) -> int:
return 0

async def get_value(
self,
interface_id: str,
channel_address: str,
parameter: str
self, interface_id: str, channel_address: str, parameter: str
) -> Any | None:
"""Get a single value on paramset VALUES."""

Expand Down
16 changes: 12 additions & 4 deletions hahomematic/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -300,10 +300,14 @@ async def put_paramset(
"""Set paramsets manually."""
try:
if rx_mode:
await self._proxy.putParamset(channel_address, paramset_key, value, rx_mode)
await self._proxy.putParamset(
channel_address, paramset_key, value, rx_mode
)
else:
await self._proxy.putParamset(channel_address, paramset_key, value)
_LOGGER.debug("put_paramset: %s, %s, %s", channel_address, paramset_key, value)
_LOGGER.debug(
"put_paramset: %s, %s, %s", channel_address, paramset_key, value
)
except BaseHomematicException as hhe:
_LOGGER.warning(
"put_paramset failed: %s (%s) %s, %s, %s",
Expand All @@ -314,7 +318,9 @@ async def put_paramset(
value,
)

async def fetch_paramset_description(self, channel_address: str, paramset: str) -> None:
async def fetch_paramset_description(
self, channel_address: str, paramset: str
) -> None:
"""
Fetch a specific paramset and add it to the known ones.
"""
Expand Down Expand Up @@ -395,7 +401,9 @@ async def get_all_paramsets(
all_paramsets: dict[str, dict[str, Any]] = {}
for device_description in device_descriptions:
all_paramsets.update(
await self.get_paramset_descriptions(device_description=device_description)
await self.get_paramset_descriptions(
device_description=device_description
)
)
return all_paramsets

Expand Down
16 changes: 10 additions & 6 deletions hahomematic/hmcli.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,13 @@
import argparse
import json
import sys
from typing import Any
from xmlrpc.client import ServerProxy

from hahomematic.helpers import build_api_url, get_tls_context


def main():
def main() -> None:
"""Main function."""
parser = argparse.ArgumentParser(
description="Commandline tool to query HomeMatic hubs via XML-RPC."
Expand Down Expand Up @@ -87,6 +88,7 @@ def main():
print(res)
sys.exit(0)
elif args.paramset == "VALUES" and args.value:
value: Any
if args.type == "int":
value = int(args.value)
elif args.type == "float":
Expand All @@ -98,11 +100,13 @@ def main():
proxy.setValue(args.address, args.parameter, value)
sys.exit(0)
elif args.paramset == "MASTER" and args.value is None:
res = proxy.getParamset(args.address, args.paramset).get(args.parameter)
if args.json:
print(json.dumps({args.parameter: res}))
else:
print(res)
paramset: dict[str, Any] | None
if paramset := proxy.getParamset(args.address, args.paramset): # type: ignore
if param_value := paramset.get(args.parameter):
if args.json:
print(json.dumps({args.parameter: param_value}))
else:
print(param_value)
sys.exit(0)
elif args.paramset == "MASTER" and args.value:
if args.type == "int":
Expand Down

0 comments on commit be5c2b0

Please sign in to comment.