From f52f84711f87215972a36431b60924033ef602ca Mon Sep 17 00:00:00 2001 From: Andre Basche Date: Wed, 8 Mar 2023 22:18:44 +0100 Subject: [PATCH] Fix bugs --- pyhon/appliances/__init__.py | 0 pyhon/device.py | 11 ++++++----- setup.py | 2 +- 3 files changed, 7 insertions(+), 6 deletions(-) create mode 100644 pyhon/appliances/__init__.py diff --git a/pyhon/appliances/__init__.py b/pyhon/appliances/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/pyhon/device.py b/pyhon/device.py index 0836a98..9157e0c 100644 --- a/pyhon/device.py +++ b/pyhon/device.py @@ -23,7 +23,7 @@ class HonDevice: if "." in item: result = self.data for key in item.split("."): - if all([k in "0123456789" for k in key]): + if all([k in "0123456789" for k in key]) and type(result) is list: result = result[int(key)] else: result = result[key] @@ -31,15 +31,16 @@ class HonDevice: else: if item in self.data: return self.data[item] - return self.attributes["parameters"].get(item, self.appliance[item]) + if item in self.attributes["parameters"]: + return self.attributes["parameters"].get(item) + return self.appliance[item] def get(self, item, default=None): try: return self[item] - except KeyError | IndexError: + except (KeyError, IndexError): return default - @property def appliance_model_id(self): return self._appliance.get("applianceModelId") @@ -127,7 +128,7 @@ class HonDevice: @property def data(self): result = {"attributes": self.attributes, "appliance": self.appliance, "statistics": self.statistics, - "commands": self.parameters} + **self.parameters} if self._extra: return result | self._extra.Appliance(result).get() return result diff --git a/setup.py b/setup.py index 442e1c2..34c408a 100644 --- a/setup.py +++ b/setup.py @@ -7,7 +7,7 @@ with open("README.md", "r") as f: setup( name="pyhOn", - version="0.3.1", + version="0.3.2", author="Andre Basche", description="Control hOn devices with python", long_description=long_description,