Issue with sync_command #16

Merged
VadymMelnychuk merged 20 commits from main into main 2023-10-12 16:43:41 +02:00
5 changed files with 14 additions and 12 deletions
Showing only changes of commit 55c43db3a6 - Show all commits

View File

@ -11,6 +11,7 @@ from pyhon.attributes import HonAttribute
from pyhon.command_loader import HonCommandLoader from pyhon.command_loader import HonCommandLoader
from pyhon.commands import HonCommand from pyhon.commands import HonCommand
from pyhon.parameter.base import HonParameter from pyhon.parameter.base import HonParameter
from pyhon.parameter.enum import HonParameterEnum
from pyhon.parameter.range import HonParameterRange from pyhon.parameter.range import HonParameterRange
from pyhon.typedefs import Parameter from pyhon.typedefs import Parameter
@ -109,7 +110,7 @@ class HonAppliance:
@property @property
def nick_name(self) -> str: def nick_name(self) -> str:
result = self._check_name_zone("nickName") 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 self.model_name
return result return result
@ -283,4 +284,6 @@ class HonAppliance:
parameter.max = int(base_value.value) parameter.max = int(base_value.value)
parameter.min = int(base_value.value) parameter.min = int(base_value.value)
parameter.step = 1 parameter.step = 1
elif isinstance(parameter, HonParameterEnum):
parameter.values = base_value.values
parameter.value = base_value.value parameter.value = base_value.value

View File

@ -14,11 +14,4 @@ class Appliance(ApplianceBase):
data["parameters"]["remainingTimeMM"].value = "0" data["parameters"]["remainingTimeMM"].value = "0"
data["active"] = data["parameters"]["onOffStatus"] == "1" 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 return data

View File

@ -267,8 +267,13 @@ class TestAPI(HonAPI):
_LOGGER.warning("Can't open %s", str(path)) _LOGGER.warning("Can't open %s", str(path))
return {} return {}
with open(path, "r", encoding="utf-8") as json_file: with open(path, "r", encoding="utf-8") as json_file:
data: Dict[str, Any] = json.loads(json_file.read()) text = json_file.read()
return data 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]]: async def load_appliances(self) -> List[Dict[str, Any]]:
result = [] result = []

View File

@ -1,2 +1,3 @@
aiohttp==3.8.4 aiohttp==3.8.4
yarl==1.8.2 yarl==1.8.2
typing-extensions==4.7.1

View File

@ -7,7 +7,7 @@ with open("README.md", "r") as f:
setup( setup(
name="pyhOn", name="pyhOn",
version="0.14.7", version="0.14.9",
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,
@ -21,7 +21,7 @@ setup(
packages=find_packages(), packages=find_packages(),
include_package_data=True, include_package_data=True,
python_requires=">=3.10", python_requires=">=3.10",
install_requires=["aiohttp"], install_requires=["aiohttp==3.8.4", "typing-extensions==4.7.1"],
classifiers=[ classifiers=[
"Development Status :: 4 - Beta", "Development Status :: 4 - Beta",
"Environment :: Console", "Environment :: Console",