Compare commits
3 Commits
Author | SHA1 | Date | |
---|---|---|---|
9971fe95e2 | |||
9f130e2e85 | |||
dfbc24452b |
@ -98,6 +98,13 @@ class HonAppliance:
|
|||||||
def nick_name(self) -> str:
|
def nick_name(self) -> str:
|
||||||
return self._check_name_zone("nickName")
|
return self._check_name_zone("nickName")
|
||||||
|
|
||||||
|
@property
|
||||||
|
def code(self) -> str:
|
||||||
|
if code := self.info.get("code"):
|
||||||
|
return code
|
||||||
|
serial_number = self.info.get("serialNumber", "")
|
||||||
|
return serial_number[:8] if len(serial_number) < 18 else serial_number[:11]
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def commands_options(self):
|
def commands_options(self):
|
||||||
return self._appliance_model.get("options")
|
return self._appliance_model.get("options")
|
||||||
@ -276,7 +283,7 @@ class HonAppliance:
|
|||||||
extra = {n: c.data for n, c in self._commands.items() if c.data}
|
extra = {n: c.data for n, c in self._commands.items() if c.data}
|
||||||
if extra:
|
if extra:
|
||||||
data |= {"extra_command_data": extra}
|
data |= {"extra_command_data": extra}
|
||||||
for sensible in ["PK", "SK", "serialNumber", "code", "coords", "device"]:
|
for sensible in ["PK", "SK", "serialNumber", "coords", "device"]:
|
||||||
data.get("appliance", {}).pop(sensible, None)
|
data.get("appliance", {}).pop(sensible, None)
|
||||||
result = helper.pretty_print({"data": data}, whitespace=whitespace)
|
result = helper.pretty_print({"data": data}, whitespace=whitespace)
|
||||||
result += helper.pretty_print(
|
result += helper.pretty_print(
|
||||||
|
@ -72,23 +72,23 @@ class HonAPI:
|
|||||||
async def load_commands(self, appliance: HonAppliance) -> Dict:
|
async def load_commands(self, appliance: HonAppliance) -> Dict:
|
||||||
params: Dict = {
|
params: Dict = {
|
||||||
"applianceType": appliance.appliance_type,
|
"applianceType": appliance.appliance_type,
|
||||||
"code": appliance.info["code"],
|
|
||||||
"applianceModelId": appliance.appliance_model_id,
|
"applianceModelId": appliance.appliance_model_id,
|
||||||
"macAddress": appliance.mac_address,
|
"macAddress": appliance.mac_address,
|
||||||
"os": const.OS,
|
"os": const.OS,
|
||||||
"appVersion": const.APP_VERSION,
|
"appVersion": const.APP_VERSION,
|
||||||
"series": appliance.info["series"],
|
"code": appliance.code,
|
||||||
}
|
}
|
||||||
if firmware_id := appliance.info.get("eepromId"):
|
if firmware_id := appliance.info.get("eepromId"):
|
||||||
params["firmwareId"] = firmware_id
|
params["firmwareId"] = firmware_id
|
||||||
if firmware_version := appliance.info.get("fwVersion"):
|
if firmware_version := appliance.info.get("fwVersion"):
|
||||||
params["fwVersion"] = firmware_version
|
params["fwVersion"] = firmware_version
|
||||||
if code := appliance.info.get("code"):
|
if series := appliance.info.get("series"):
|
||||||
params["code"] = code
|
params["series"] = series
|
||||||
url: str = f"{const.API_URL}/commands/v1/retrieve"
|
url: str = f"{const.API_URL}/commands/v1/retrieve"
|
||||||
async with self._hon.get(url, params=params) as response:
|
async with self._hon.get(url, params=params) as response:
|
||||||
result: Dict = (await response.json()).get("payload", {})
|
result: Dict = (await response.json()).get("payload", {})
|
||||||
if not result or result.pop("resultCode") != "0":
|
if not result or result.pop("resultCode") != "0":
|
||||||
|
_LOGGER.error(await response.json())
|
||||||
return {}
|
return {}
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
@ -83,7 +83,7 @@ class Hon:
|
|||||||
)
|
)
|
||||||
except (KeyError, ValueError, IndexError) as error:
|
except (KeyError, ValueError, IndexError) as error:
|
||||||
_LOGGER.exception(error)
|
_LOGGER.exception(error)
|
||||||
_LOGGER.error(f"Device data - %s", appliance_data)
|
_LOGGER.error("Device data - %s", appliance_data)
|
||||||
self._appliances.append(appliance)
|
self._appliances.append(appliance)
|
||||||
|
|
||||||
async def setup(self) -> None:
|
async def setup(self) -> None:
|
||||||
|
@ -9,7 +9,7 @@ class HonParameterEnum(HonParameter):
|
|||||||
self._default = attributes.get("defaultValue")
|
self._default = attributes.get("defaultValue")
|
||||||
self._value = self._default or "0"
|
self._value = self._default or "0"
|
||||||
self._values: List[str] = attributes.get("enumValues", [])
|
self._values: List[str] = attributes.get("enumValues", [])
|
||||||
if self._default and self._default not in self._values:
|
if self._default and str(self._default) not in self.values:
|
||||||
self._values.append(self._default)
|
self._values.append(self._default)
|
||||||
|
|
||||||
def __repr__(self) -> str:
|
def __repr__(self) -> str:
|
||||||
|
2
setup.py
2
setup.py
@ -7,7 +7,7 @@ with open("README.md", "r") as f:
|
|||||||
|
|
||||||
setup(
|
setup(
|
||||||
name="pyhOn",
|
name="pyhOn",
|
||||||
version="0.10.7",
|
version="0.10.10",
|
||||||
author="Andre Basche",
|
author="Andre Basche",
|
||||||
description="Control hOn devices with python",
|
description="Control hOn devices with python",
|
||||||
long_description=long_description,
|
long_description=long_description,
|
||||||
|
Reference in New Issue
Block a user