mirror of
https://github.com/Andre0512/pyhOn.git
synced 2024-11-23 22:30:57 +01:00
Improvements
This commit is contained in:
parent
44f40c531e
commit
0553e6c17d
@ -99,7 +99,7 @@ async def main() -> None:
|
||||
print(printer.key_print(data))
|
||||
print(
|
||||
printer.pretty_print(
|
||||
printer.create_command(device.commands, concat=True)
|
||||
printer.create_commands(device.commands, concat=True)
|
||||
)
|
||||
)
|
||||
else:
|
||||
|
@ -106,7 +106,7 @@ class HonAppliance:
|
||||
@property
|
||||
def nick_name(self) -> str:
|
||||
result = self._check_name_zone("nickName")
|
||||
if not result or re.findall("^[xX\s]+$", result):
|
||||
if not result or re.findall("^[xX1\\s]+$", result):
|
||||
return self.model_name
|
||||
return result
|
||||
|
||||
@ -238,12 +238,12 @@ class HonAppliance:
|
||||
if not (command := self.commands.get(command_name)):
|
||||
return
|
||||
for key, value in self.attributes.get("parameters", {}).items():
|
||||
if isinstance(value, str) and (new := command.parameters.get(key)):
|
||||
if new := command.parameters.get(key):
|
||||
self.attributes["parameters"][key].update(
|
||||
str(new.intern_value), shield=True
|
||||
)
|
||||
|
||||
def sync_command(self, main: str, target: Optional[List[str]] = None) -> None:
|
||||
def sync_command(self, main: str, target: Optional[List[str] | str] = None) -> None:
|
||||
base: Optional[HonCommand] = self.commands.get(main)
|
||||
if not base:
|
||||
return
|
||||
|
@ -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.10"
|
||||
APP_VERSION = "2.1.2"
|
||||
OS_VERSION = 31
|
||||
OS = "android"
|
||||
DEVICE_MODEL = "exynos9820"
|
||||
|
@ -89,12 +89,11 @@ def yaml_export(appliance: "HonAppliance", anonymous: bool = False) -> str:
|
||||
if anonymous:
|
||||
for sensible in ["serialNumber", "coords"]:
|
||||
data.get("appliance", {}).pop(sensible, None)
|
||||
data = {
|
||||
"data": data,
|
||||
"commands": printer.create_command(appliance.commands),
|
||||
"rules": printer.create_rules(appliance.commands),
|
||||
}
|
||||
result = printer.pretty_print(data)
|
||||
result = printer.pretty_print({"data": data})
|
||||
if commands := printer.create_commands(appliance.commands):
|
||||
result += printer.pretty_print({"commands": commands})
|
||||
if rules := printer.create_rules(appliance.commands):
|
||||
result += printer.pretty_print({"rules": rules})
|
||||
if anonymous:
|
||||
result = anonymize_data(result)
|
||||
return result
|
||||
|
@ -41,4 +41,4 @@ class HonParameterEnum(HonParameter):
|
||||
self._value = value
|
||||
self.check_trigger(value)
|
||||
else:
|
||||
raise ValueError(f"Allowed values {self._values}")
|
||||
raise ValueError(f"Allowed values: {self._values} But was: {value}")
|
||||
|
@ -28,7 +28,7 @@ class HonParameterProgram(HonParameterEnum):
|
||||
if value in self.values:
|
||||
self._command.category = value
|
||||
else:
|
||||
raise ValueError(f"Allowed values {self.values}")
|
||||
raise ValueError(f"Allowed values: {self.values} But was: {value}")
|
||||
|
||||
@property
|
||||
def values(self) -> List[str]:
|
||||
|
@ -53,7 +53,9 @@ class HonParameterRange(HonParameter):
|
||||
self._value = value
|
||||
self.check_trigger(value)
|
||||
else:
|
||||
raise ValueError(f"Allowed: min {self.min} max {self.max} step {self.step}")
|
||||
raise ValueError(
|
||||
f"Allowed: min {self.min} max {self.max} step {self.step} But was: {value}"
|
||||
)
|
||||
|
||||
@property
|
||||
def values(self) -> List[str]:
|
||||
|
@ -59,7 +59,7 @@ def pretty_print(
|
||||
return result
|
||||
|
||||
|
||||
def create_command(
|
||||
def create_commands(
|
||||
commands: Dict[str, "HonCommand"], concat: bool = False
|
||||
) -> Dict[str, Any]:
|
||||
result: Dict[str, Any] = {}
|
||||
|
Loading…
Reference in New Issue
Block a user