diff --git a/.github/workflows/python-check.yml b/.github/workflows/python-check.yml index 3d6f17c..00027a2 100644 --- a/.github/workflows/python-check.yml +++ b/.github/workflows/python-check.yml @@ -34,7 +34,7 @@ jobs: mypy pyhon/ - name: Analysing the code with pylint run: | - pylint $(git ls-files '*.py') + pylint $(git ls-files '*.py') - name: Check black style run: | black . --check diff --git a/pyhon/commands.py b/pyhon/commands.py index b671e55..68df63a 100644 --- a/pyhon/commands.py +++ b/pyhon/commands.py @@ -102,10 +102,12 @@ class HonCommand: if name == "zoneMap" and self._appliance.zone: data["default"] = self._appliance.zone if data.get("category") == "rule": - if "fixedValue" not in data: - _LOGGER.error("Rule not supported: %s", data) - else: + if "fixedValue" in data: self._rules.append(HonRuleSet(self, data["fixedValue"])) + elif "enumValues" in data: + self._rules.append(HonRuleSet(self, data["enumValues"])) + else: + _LOGGER.warning("Rule not supported: %s", data) match data.get("typology"): case "range": self._parameters[name] = HonParameterRange(name, data, parameter) @@ -137,6 +139,8 @@ class HonCommand: async def send_parameters(self, params: Dict[str, str | float]) -> bool: ancillary_params = self.parameter_groups.get("ancillaryParameters", {}) ancillary_params.pop("programRules", None) + if "prStr" in params: + params["prStr"] = self._category_name.upper() self.appliance.sync_command_to_params(self.name) try: result = await self.api.send_command( diff --git a/pyhon/const.py b/pyhon/const.py index 4f97435..8d1fd26 100644 --- a/pyhon/const.py +++ b/pyhon/const.py @@ -6,7 +6,7 @@ CLIENT_ID = ( "3MVG9QDx8IX8nP5T2Ha8ofvlmjLZl5L_gvfbT9." "HJvpHGKoAS_dcMN8LYpTSYeVFCraUnV.2Ag1Ki7m4znVO6" ) -APP_VERSION = "2.1.2" +APP_VERSION = "2.3.5" OS_VERSION = 31 OS = "android" DEVICE_MODEL = "exynos9820" diff --git a/pyhon/parameter/base.py b/pyhon/parameter/base.py index 4d70051..5d93b29 100644 --- a/pyhon/parameter/base.py +++ b/pyhon/parameter/base.py @@ -68,8 +68,9 @@ class HonParameter: self._triggers.setdefault(value, []).append((func, data)) def check_trigger(self, value: str | float) -> None: - if str(value) in self._triggers: - for trigger in self._triggers[str(value)]: + triggers = {str(k).lower(): v for k, v in self._triggers.items()} + if str(value).lower() in triggers: + for trigger in triggers[str(value)]: func, args = trigger func(args) diff --git a/pyhon/parameter/fixed.py b/pyhon/parameter/fixed.py index 125ecd2..67a3056 100644 --- a/pyhon/parameter/fixed.py +++ b/pyhon/parameter/fixed.py @@ -18,7 +18,7 @@ class HonParameterFixed(HonParameter): @property def value(self) -> str | float: - return self._value if self._value is not None else "0" + return self._value if self._value != "" else "0" @value.setter def value(self, value: str | float) -> None: diff --git a/pyhon/rules.py b/pyhon/rules.py index 57d6de5..4a1a314 100644 --- a/pyhon/rules.py +++ b/pyhon/rules.py @@ -56,6 +56,11 @@ class HonRuleSet: extra[trigger_key] = trigger_value for extra_key, extra_data in param_data.items(): self._parse_conditions(param_key, extra_key, extra_data, extra) + else: + param_data = {"typology": "fixed", "fixedValue": param_data} + self._create_rule( + param_key, trigger_key, trigger_value, param_data, extra + ) def _create_rule( self, @@ -102,6 +107,10 @@ class HonRuleSet: param.values = [str(value)] param.value = str(value) elif isinstance(param, HonParameterRange): + if float(value) < param.min: + param.min = float(value) + elif float(value) > param.max: + param.max = float(value) param.value = float(value) return param.value = str(value) diff --git a/requirements.txt b/requirements.txt index 2e9957d..ca541a3 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1,3 @@ -aiohttp~=3.8.5 -yarl~=1.9.2 -typing-extensions~=4.7.1 +aiohttp~=3.8 +yarl~=1.9 +typing-extensions~=4.7 diff --git a/setup.py b/setup.py index e6a9cf6..e12972d 100644 --- a/setup.py +++ b/setup.py @@ -7,7 +7,7 @@ with open("README.md", "r", encoding="utf-8") as f: setup( name="pyhOn", - version="0.15.6", + version="0.15.9", 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~=3.8.5", "typing-extensions~=4.7.1", "yarl~=1.9.2"], + install_requires=["aiohttp~=3.8", "typing-extensions~=4.7", "yarl~=1.9"], classifiers=[ "Development Status :: 4 - Beta", "Environment :: Console",