Compare commits
12 Commits
Author | SHA1 | Date | |
---|---|---|---|
715d8a96fc | |||
ec358034e1 | |||
6cdac99ce8 | |||
0c1670733f | |||
744094dc07 | |||
bf2015fcb9 | |||
bc7e8994c9 | |||
8ca40d7ad0 | |||
9a6a07fd46 | |||
f1818bbc5d | |||
3d5c8405ea | |||
e234ef3bbb |
@ -11,6 +11,7 @@ from pyhon.attributes import HonAttribute
|
||||
from pyhon.command_loader import HonCommandLoader
|
||||
from pyhon.commands import HonCommand
|
||||
from pyhon.parameter.base import HonParameter
|
||||
from pyhon.parameter.enum import HonParameterEnum
|
||||
from pyhon.parameter.range import HonParameterRange
|
||||
from pyhon.typedefs import Parameter
|
||||
|
||||
@ -109,7 +110,7 @@ class HonAppliance:
|
||||
@property
|
||||
def nick_name(self) -> str:
|
||||
result = self._check_name_zone("nickName")
|
||||
if not result or re.findall("^[xX1\\s]+$", result):
|
||||
if not result or re.findall("^[xX1\\s-]+$", result):
|
||||
return self.model_name
|
||||
return result
|
||||
|
||||
@ -252,7 +253,9 @@ class HonAppliance:
|
||||
if not (command := self.commands.get(command_name)):
|
||||
return
|
||||
for key in command.setting_keys:
|
||||
if (new := self.attributes.get("parameters", {}).get(key)) is None:
|
||||
if (
|
||||
new := self.attributes.get("parameters", {}).get(key)
|
||||
) is None or new.value == "":
|
||||
continue
|
||||
setting = command.settings[key]
|
||||
try:
|
||||
@ -283,4 +286,6 @@ class HonAppliance:
|
||||
parameter.max = int(base_value.value)
|
||||
parameter.min = int(base_value.value)
|
||||
parameter.step = 1
|
||||
elif isinstance(parameter, HonParameterEnum):
|
||||
parameter.values = base_value.values
|
||||
parameter.value = base_value.value
|
||||
|
@ -14,11 +14,4 @@ class Appliance(ApplianceBase):
|
||||
data["parameters"]["remainingTimeMM"].value = "0"
|
||||
|
||||
data["active"] = data["parameters"]["onOffStatus"] == "1"
|
||||
|
||||
if program := int(data["parameters"]["prCode"].value):
|
||||
if (setting := self.parent.settings["startProgram.program"]) and isinstance(
|
||||
setting, HonParameterProgram
|
||||
):
|
||||
data["programName"] = setting.ids.get(program, "")
|
||||
|
||||
return data
|
||||
|
@ -187,18 +187,19 @@ class HonCommandLoader:
|
||||
command = favourite.get("command", {})
|
||||
command_name = command.get("commandName", "")
|
||||
program_name = self._clean_name(command.get("programName", ""))
|
||||
base: HonCommand = copy(
|
||||
self.commands[command_name].categories[program_name]
|
||||
)
|
||||
if not (base := self.commands[command_name].categories.get(program_name)):
|
||||
continue
|
||||
base_command: HonCommand = copy(base)
|
||||
for data in command.values():
|
||||
if isinstance(data, str):
|
||||
continue
|
||||
for key, value in data.items():
|
||||
if parameter := base.parameters.get(key):
|
||||
if parameter := base_command.parameters.get(key):
|
||||
with suppress(ValueError):
|
||||
parameter.value = value
|
||||
extra_param = HonParameterFixed("favourite", {"fixedValue": "1"}, "custom")
|
||||
base.parameters.update(favourite=extra_param)
|
||||
if isinstance(program := base.parameters["program"], HonParameterProgram):
|
||||
base_command.parameters.update(favourite=extra_param)
|
||||
program = base_command.parameters["program"]
|
||||
if isinstance(program, HonParameterProgram):
|
||||
program.set_value(name)
|
||||
self.commands[command_name].categories[name] = base
|
||||
self.commands[command_name].categories[name] = base_command
|
||||
|
@ -267,8 +267,13 @@ class TestAPI(HonAPI):
|
||||
_LOGGER.warning("Can't open %s", str(path))
|
||||
return {}
|
||||
with open(path, "r", encoding="utf-8") as json_file:
|
||||
data: Dict[str, Any] = json.loads(json_file.read())
|
||||
text = json_file.read()
|
||||
try:
|
||||
data: Dict[str, Any] = json.loads(text)
|
||||
return data
|
||||
except json.decoder.JSONDecodeError as error:
|
||||
_LOGGER.error("%s - %s", str(path), error)
|
||||
return {}
|
||||
|
||||
async def load_appliances(self) -> List[Dict[str, Any]]:
|
||||
result = []
|
||||
|
@ -1,2 +1,3 @@
|
||||
aiohttp==3.8.4
|
||||
yarl==1.8.2
|
||||
aiohttp~=3.8.5
|
||||
yarl~=1.9.2
|
||||
typing-extensions~=4.7.1
|
||||
|
4
setup.py
4
setup.py
@ -7,7 +7,7 @@ with open("README.md", "r") as f:
|
||||
|
||||
setup(
|
||||
name="pyhOn",
|
||||
version="0.14.7",
|
||||
version="0.14.12",
|
||||
author="Andre Basche",
|
||||
description="Control hOn devices with python",
|
||||
long_description=long_description,
|
||||
@ -21,7 +21,7 @@ setup(
|
||||
packages=find_packages(),
|
||||
include_package_data=True,
|
||||
python_requires=">=3.10",
|
||||
install_requires=["aiohttp"],
|
||||
install_requires=["aiohttp~=3.8.5", "typing-extensions~=4.7.1", "yarl~=1.9.2"],
|
||||
classifiers=[
|
||||
"Development Status :: 4 - Beta",
|
||||
"Environment :: Console",
|
||||
|
Reference in New Issue
Block a user