mirror of
https://github.com/Andre0512/pyhOn.git
synced 2024-12-22 18:55:32 +00:00
Fix some minor issues
This commit is contained in:
parent
4e88bc7a9f
commit
44f40c531e
|
@ -165,7 +165,9 @@ class HonAppliance:
|
|||
|
||||
async def load_attributes(self) -> None:
|
||||
self._attributes = await self.api.load_attributes(self)
|
||||
for name, values in self._attributes.pop("shadow").get("parameters").items():
|
||||
for name, values in (
|
||||
self._attributes.pop("shadow", {}).get("parameters", {}).items()
|
||||
):
|
||||
if name in self._attributes.get("parameters", {}):
|
||||
self._attributes["parameters"][name].update(values)
|
||||
else:
|
||||
|
|
|
@ -15,7 +15,7 @@ class Appliance(ApplianceBase):
|
|||
|
||||
data["active"] = data["parameters"]["onOffStatus"] == "1"
|
||||
|
||||
if program := int(data["parameters"]["prCode"]):
|
||||
if program := int(data["parameters"]["prCode"].value):
|
||||
if (setting := self.parent.settings["startProgram.program"]) and isinstance(
|
||||
setting, HonParameterProgram
|
||||
):
|
||||
|
|
|
@ -55,7 +55,7 @@ class HonCommandLoader:
|
|||
async def load_commands(self) -> None:
|
||||
"""Trigger loading of command data"""
|
||||
await self._load_data()
|
||||
self._appliance_data = self._api_commands.pop("applianceModel")
|
||||
self._appliance_data = self._api_commands.pop("applianceModel", {})
|
||||
self._get_commands()
|
||||
self._add_favourites()
|
||||
self._recover_last_command_states()
|
||||
|
|
|
@ -250,9 +250,11 @@ class TestAPI(HonAPI):
|
|||
|
||||
def _load_json(self, appliance: HonAppliance, file: str) -> Dict[str, Any]:
|
||||
directory = f"{appliance.appliance_type}_{appliance.appliance_model_id}".lower()
|
||||
path = f"{self._path}/{directory}/{file}.json"
|
||||
if (path := self._path / directory / f"{file}.json").exists():
|
||||
with open(path, "r", encoding="utf-8") as json_file:
|
||||
return json.loads(json_file.read())
|
||||
_LOGGER.warning(f"Can't open {str(path)}")
|
||||
return {}
|
||||
|
||||
async def load_appliances(self) -> List[Dict[str, Any]]:
|
||||
result = []
|
||||
|
|
|
@ -57,7 +57,7 @@ class HonConnectionHandler(ConnectionHandler):
|
|||
async def _intercept(
|
||||
self, method: Callback, url: str | URL, *args: Any, **kwargs: Any
|
||||
) -> AsyncIterator[aiohttp.ClientResponse]:
|
||||
loop: int = kwargs.get("loop", 0)
|
||||
loop: int = kwargs.pop("loop", 0)
|
||||
kwargs["headers"] = await self._check_headers(kwargs.get("headers", {}))
|
||||
async with method(url, *args, **kwargs) as response:
|
||||
if (
|
||||
|
|
Loading…
Reference in a new issue