jacekk015 / zha_quirks

All quirks in one place
MIT License
144 stars 20 forks source link

Update to ts0601_thermostat_avatto.py to support Avatto ZWT07 _TZE200_g9a3awaj T5Z #49

Closed jezzaaa closed 8 months ago

jezzaaa commented 9 months ago

I bought an inexpensive ZigBee boiler/heater thermostat for my gas ducted heater. I couldn't get it to work with the official quirks, but managed to hack the AVATTO thermostat quirk from this repo. All I did was add the manufacturer ID string "_TZE200_g9a3awaj" wherever I saw "_TZE200_2ekuz3dz", as they appear to work almost exactly the same. Plus I had to reverse the sense of the state of AVATTO_HEAT_STATE_ATTR for the g9a3awaj case (seems this is the only difference between the two).

I'm not familiar with using git, so I'm hoping it's sufficient for me to just paste my patch here. I'll also attach my updated version of the file. ts0601_thermostat_avatto.py.patch ts0601_thermostat_avatto.zip

I'm puzzled why the file I'm patching isn't in the official repo. But I'm grateful I found it here. Thankyou! My thermostat seems to have most features working perfectly, including reading/setting the child lock, and automatically having the time set after changing batteries. I haven't explored reading/setting the stored schedules, but I just assumed I would have Home Assistant do that for me.

My patch:

--- ts0601_thermostat_avatto.py.orig    2024-02-09 01:32:25.332864497 +1100
+++ ts0601_thermostat_avatto.py 2024-02-09 02:02:11.039436479 +1100
@@ -208,7 +208,7 @@
         """Override default _update_attribute."""
         super()._update_attribute(attrid, value)
         if attrid in self.DIRECT_MAPPED_ATTRS:
-            if self.endpoint.device.manufacturer == "_TZE200_2ekuz3dz" or (
+            if self.endpoint.device.manufacturer in ( "_TZE200_2ekuz3dz", "_TZE200_g9a3awaj" ) or (
                 attrid == AVATTO_TEMPERATURE_ATTR
                 and self.endpoint.device.manufacturer
                 in (
@@ -235,7 +235,7 @@
                 )

         if attrid == AVATTO_TEMP_CALIBRATION_ATTR:
-            if self.endpoint.device.manufacturer == "_TZE200_2ekuz3dz":
+            if self.endpoint.device.manufacturer in ( "_TZE200_2ekuz3dz", "_TZE200_g9a3awaj" ) :
                 self.endpoint.device.AvattoTempCalibration_bus.listener_event(
                     "set_value", value / 10
                 )
@@ -252,9 +252,14 @@
         elif attrid == AVATTO_MODE_ATTR:
             self.endpoint.device.thermostat_bus.listener_event("mode_change", value)
         elif attrid == AVATTO_HEAT_STATE_ATTR:
-            self.endpoint.device.thermostat_bus.listener_event(
-                "state_change", not value
-            )
+            if self.endpoint.device.manufacturer == "_TZE200_g9a3awaj":
+                self.endpoint.device.thermostat_bus.listener_event(
+                    "state_change", value
+                )
+            else:
+                self.endpoint.device.thermostat_bus.listener_event(
+                    "state_change", not value
+                )
         elif attrid == BEOK_HEAT_STATE_ATTR:
             self.endpoint.device.thermostat_bus.listener_event("state_change", value)
         elif attrid == AVATTO_SYSTEM_MODE_ATTR:
@@ -330,7 +335,7 @@
         """Map standardized attribute value to dict of manufacturer values."""

         if attribute in self.DIRECT_MAPPING_ATTRS:
-            if self.endpoint.device.manufacturer == "_TZE200_2ekuz3dz":
+            if self.endpoint.device.manufacturer in ( "_TZE200_2ekuz3dz", "_TZE200_g9a3awaj" ):
                 return {
                     self.DIRECT_MAPPING_ATTRS[attribute][0]: value
                     if self.DIRECT_MAPPING_ATTRS[attribute][2] is None
@@ -458,7 +463,7 @@
                 continue
             self._update_attribute(attrid, value)

-            if self.endpoint.device.manufacturer == "_TZE200_2ekuz3dz":
+            if self.endpoint.device.manufacturer in ( "_TZE200_2ekuz3dz", "_TZE200_g9a3awaj" ):
                 await AvattoManufClusterSelf[
                     self.endpoint.device.ieee
                 ].endpoint.tuya_manufacturer.write_attributes(
jezzaaa commented 9 months ago

This appears to be a re-branded Avatto ZWT07. There's support in Z2M for this model.

jacekk015 commented 8 months ago

Code merged.