Przeglądaj źródła

fix(device_config): respect invert inside conditions

This was documented as being available, and allowed by unit tests, but
not implemented, and not present in the json schema.

Issue #5486
Jason Rumney 4 dni temu
rodzic
commit
0227a8be01

+ 4 - 0
custom_components/tuya_local/devices/device_config_schema.json

@@ -418,6 +418,10 @@
                                                             "type": "boolean",
                                                             "description": "true if this condition indicates an invalid state."
                                                         },
+                                                        "invert": {
+                                                            "type": "boolean",
+                                                            "description": "true to invert the value within the range when this condition is matched."
+                                                        },
                                                         "mapping": {
                                                             "type": "array",
                                                             "description": "An override list of mappings that potentially change the value in HA compared to the raw DP value when this condition is matched.",

+ 2 - 0
custom_components/tuya_local/helpers/device_config.py

@@ -807,6 +807,7 @@ class TuyaDpsConfig:
                     return None
                 replaced = replaced or "value" in cond
                 result = cond.get("value", result)
+                invert = cond.get("invert", result)
                 redirect = cond.get("value_redirect", redirect)
                 mirror = cond.get("value_mirror", mirror)
                 target_range = cond.get("target_range", target_range)
@@ -1040,6 +1041,7 @@ class TuyaDpsConfig:
                 step = cond.get("step", step)
                 redirect = cond.get("value_redirect", redirect)
                 target_range = cond.get("target_range", target_range)
+                invert = cond.get("invert", invert)
 
             if redirect:
                 _LOGGER.debug("Redirecting %s to %s", self.name, redirect)