From d4c6ccdce32713d559273e1c554c283dcb112e3d Mon Sep 17 00:00:00 2001 From: Andre Basche Date: Sun, 23 Apr 2023 20:14:52 +0200 Subject: [PATCH] Use parameter optional --- pyhon/appliance.py | 9 ++++++++- pyhon/connection/api.py | 2 +- setup.py | 2 +- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/pyhon/appliance.py b/pyhon/appliance.py index 90a7f12..defcf69 100644 --- a/pyhon/appliance.py +++ b/pyhon/appliance.py @@ -1,4 +1,5 @@ import importlib +import logging from contextlib import suppress from typing import Optional, Dict, Any from typing import TYPE_CHECKING @@ -11,6 +12,9 @@ from pyhon import HonAPI +_LOGGER = logging.getLogger(__name__) + + class HonAppliance: def __init__( self, api: Optional["HonAPI"], info: Dict[str, Any], zone: int = 0 @@ -183,7 +187,10 @@ def parameters(self): async def load_attributes(self): self._attributes = await self._api.load_attributes(self) - for name, values in self._attributes.pop("shadow").get("parameters").items(): + _LOGGER.warning(self._attributes) + for name, values in ( + self._attributes.pop("shadow", {}).get("parameters", {}).items() + ): self._attributes.setdefault("parameters", {})[name] = values["parNewVal"] async def load_statistics(self): diff --git a/pyhon/connection/api.py b/pyhon/connection/api.py index cededa4..f40f5b8 100644 --- a/pyhon/connection/api.py +++ b/pyhon/connection/api.py @@ -12,7 +12,7 @@ from pyhon.connection.handler.anonym import HonAnonymousConnectionHandler from pyhon.connection.handler.hon import HonConnectionHandler -_LOGGER = logging.getLogger() +_LOGGER = logging.getLogger(__name__) class HonAPI: diff --git a/setup.py b/setup.py index 71bca29..628b6e0 100644 --- a/setup.py +++ b/setup.py @@ -7,7 +7,7 @@ setup( name="pyhOn", - version="0.8.5", + version="0.8.6", author="Andre Basche", description="Control hOn devices with python", long_description=long_description,