Compare commits

...

2 Commits

Author SHA1 Message Date
6b346f766f Fix command start 2023-03-08 23:01:59 +01:00
f52f84711f Fix bugs 2023-03-08 22:18:44 +01:00
6 changed files with 10 additions and 8 deletions

View File

@ -129,7 +129,7 @@ class HonConnection:
},
"ancillaryParameters": ancillary_parameters,
"parameters": parameters,
"applianceType": device.appliance_type_name
"applianceType": device.appliance_type
}
url = f"{const.API_URL}/commands/v1/send"
async with self._session.post(url, headers=await self._headers, json=data) as resp:

View File

View File

@ -6,4 +6,5 @@ class Appliance:
if self._data["attributes"]["lastConnEvent"]["category"] == "DISCONNECTED":
self._data["attributes"]["parameters"]["machMode"] = "0"
self._data["active"] = bool(self._data.get("activity"))
self._data["pause"] = self._data["attributes"]["parameters"]["machMode"] == "3"
return self._data

View File

@ -38,7 +38,7 @@ class HonCommand:
return {key: parameter.value for key, parameter in self._ancillary_parameters.items()}
async def send(self):
parameters = {name: parameter.value for name, parameter in self._parameters}
parameters = {name: parameter.value for name, parameter in self._parameters.items()}
return await self._connector.send_command(self._device, self._name, parameters, self.ancillary_parameters)
def get_programs(self):

View File

@ -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

View File

@ -7,7 +7,7 @@ with open("README.md", "r") as f:
setup(
name="pyhOn",
version="0.3.1",
version="0.3.3",
author="Andre Basche",
description="Control hOn devices with python",
long_description=long_description,