mirror of
https://github.com/Andre0512/pyhOn.git
synced 2024-01-19 02:50:44 +00:00
Add favourites to progams hon#47
This commit is contained in:
parent
4888f2b1d0
commit
a081ef1f97
|
@ -2,6 +2,7 @@ import importlib
|
|||
import json
|
||||
import logging
|
||||
from contextlib import suppress
|
||||
from copy import copy
|
||||
from datetime import datetime, timedelta
|
||||
from pathlib import Path
|
||||
from typing import Optional, Dict, Any
|
||||
|
@ -214,8 +215,27 @@ class HonAppliance:
|
|||
self._appliance_model = raw.pop("applianceModel")
|
||||
raw.pop("dictionaryId", None)
|
||||
self._commands = self._get_commands(raw)
|
||||
await self._add_favourites()
|
||||
await self._recover_last_command_states()
|
||||
|
||||
async def _add_favourites(self):
|
||||
favourites = await self._api.command_favourites(self)
|
||||
for favourite in favourites:
|
||||
name = favourite.get("favouriteName")
|
||||
command = favourite.get("command")
|
||||
command_name = command.get("commandName")
|
||||
program_name = command.get("programName", "").split(".")[-1].lower()
|
||||
base = copy(self._commands[command_name].categories[program_name])
|
||||
for param, data in command.items():
|
||||
if isinstance(data, str):
|
||||
continue
|
||||
for key, value in data.items():
|
||||
if parameter := base.parameters.get(key):
|
||||
with suppress(ValueError):
|
||||
parameter.value = value
|
||||
base.parameters["program"].set_value(name)
|
||||
self._commands[command_name].categories[name] = base
|
||||
|
||||
async def load_attributes(self):
|
||||
self._attributes = await self.api.load_attributes(self)
|
||||
for name, values in self._attributes.pop("shadow").get("parameters").items():
|
||||
|
|
|
@ -4,7 +4,7 @@ API_KEY = "GRCqFhC6Gk@ikWXm1RmnSmX1cm,MxY-configuration"
|
|||
APP = "hon"
|
||||
# All seen id's (different accounts, different devices) are the same, so I guess this hash is static
|
||||
CLIENT_ID = "3MVG9QDx8IX8nP5T2Ha8ofvlmjLZl5L_gvfbT9.HJvpHGKoAS_dcMN8LYpTSYeVFCraUnV.2Ag1Ki7m4znVO6"
|
||||
APP_VERSION = "2.0.9"
|
||||
APP_VERSION = "2.0.10"
|
||||
OS_VERSION = 31
|
||||
OS = "android"
|
||||
DEVICE_MODEL = "exynos9820"
|
||||
|
|
|
@ -47,3 +47,6 @@ class HonParameterProgram(HonParameterEnum):
|
|||
if "iot_" not in n and p.parameters.get("prCode")
|
||||
}
|
||||
return dict(sorted(values.items()))
|
||||
|
||||
def set_value(self, value: str):
|
||||
self._value = value
|
||||
|
|
Loading…
Reference in a new issue