mirror of
https://github.com/Andre0512/pyhOn.git
synced 2024-11-24 06:40:12 +01:00
Make 'code' attribute optional, fix hon#51
This commit is contained in:
parent
b5af81b744
commit
af4fbdd8cd
@ -83,6 +83,8 @@ class HonAPI:
|
|||||||
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"):
|
||||||
|
params["code"] = code
|
||||||
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", {})
|
||||||
|
21
pyhon/hon.py
21
pyhon/hon.py
@ -1,4 +1,5 @@
|
|||||||
import asyncio
|
import asyncio
|
||||||
|
import logging
|
||||||
from types import TracebackType
|
from types import TracebackType
|
||||||
from typing import List, Optional, Dict, Any, Type
|
from typing import List, Optional, Dict, Any, Type
|
||||||
|
|
||||||
@ -8,6 +9,8 @@ from typing_extensions import Self
|
|||||||
from pyhon import HonAPI, exceptions
|
from pyhon import HonAPI, exceptions
|
||||||
from pyhon.appliance import HonAppliance
|
from pyhon.appliance import HonAppliance
|
||||||
|
|
||||||
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
class Hon:
|
class Hon:
|
||||||
def __init__(
|
def __init__(
|
||||||
@ -70,13 +73,17 @@ class Hon:
|
|||||||
appliance = HonAppliance(self._api, appliance_data, zone=zone)
|
appliance = HonAppliance(self._api, appliance_data, zone=zone)
|
||||||
if appliance.mac_address == "":
|
if appliance.mac_address == "":
|
||||||
return
|
return
|
||||||
await asyncio.gather(
|
try:
|
||||||
*[
|
await asyncio.gather(
|
||||||
appliance.load_attributes(),
|
*[
|
||||||
appliance.load_commands(),
|
appliance.load_attributes(),
|
||||||
appliance.load_statistics(),
|
appliance.load_commands(),
|
||||||
]
|
appliance.load_statistics(),
|
||||||
)
|
]
|
||||||
|
)
|
||||||
|
except (KeyError, ValueError, IndexError) as error:
|
||||||
|
_LOGGER.exception(error)
|
||||||
|
_LOGGER.error(f"Device data - %s", appliance_data)
|
||||||
self._appliances.append(appliance)
|
self._appliances.append(appliance)
|
||||||
|
|
||||||
async def setup(self) -> None:
|
async def setup(self) -> None:
|
||||||
|
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.6",
|
version="0.10.7",
|
||||||
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,
|
||||||
|
Loading…
Reference in New Issue
Block a user