WillCodeForCats / tekmar-482

Home Assistant integration for the Tekmar Gateway 482
MIT License
7 stars 1 forks source link

Add slab setpoint number entity #68

Open WillCodeForCats opened 8 months ago

WillCodeForCats commented 8 months ago

Add slab setpoint number entity

atlasflux commented 2 months ago

Do you expect to merge this soon? It will be helpful for my seasonal automations.

WillCodeForCats commented 2 months ago

I haven't had a chance to set up a test platform for it yet.

atlasflux commented 2 months ago

I haven't had a chance to set up a test platform for it yet.

Understood, I have thermostats with radiant and can test the changes when I get a chance. I'll let you know my findings.

WillCodeForCats commented 2 months ago

Go ahead and try Release v0.9.21-pre.1

atlasflux commented 2 days ago

I've finally gotten a chance to test this. Here's the patch I needed to get it to work.

diff -u tekmar_482.orig/hub.py tekmar_482/hub.py
--- tekmar_482.orig/hub.py      2024-11-04 18:22:10.959731341 +0000
+++ tekmar_482/hub.py   2024-11-04 18:51:51.595592321 +0000
@@ -628,6 +628,8 @@
         self._config_cool_setpoint_min = None
         self._config_heat_setpoint_max = None
         self._config_heat_setpoint_min = None
+        self._config_slab_setpoint_max = None
+        self._config_slab_setpoint_min = None

         self._tha_heat_setpoints = {  # degE
             0x00: None,  # day
@@ -644,6 +646,7 @@
         self._tha_slab_setpoints = {  # degE
             0x00: None,
             0x01: None,
+            0x02: None,
         }

         self._tha_fan_percent = {  # degE
@@ -967,7 +970,12 @@

     @property
     def slab_setpoint(self) -> str:
-        return self._tha_slab_setpoint
+        try:
+            return self._tha_slab_setpoints[
+                SETBACK_SETPOINT_MAP[self._tha_setback_state]
+            ]
+        except KeyError:
+            return None

     @property
     def active_demand(self) -> str:
diff -u tekmar_482.orig/number.py tekmar_482/number.py
--- tekmar_482.orig/number.py   2024-11-04 18:22:18.927861406 +0000
+++ tekmar_482/number.py        2024-11-04 18:56:29.625581749 +0000
@@ -538,5 +538,5 @@
         return self._tekmar_tha.config_slab_setpoint_max

     async def async_set_native_value(self, value: float) -> None:
-        slab_setpoint = int(degCtoE(value))
+        slab_setpoint = int(round(degCtoE(value), 0))
         await self._tekmar_tha.set_slab_setpoint_txqueue(slab_setpoint)
atlasflux commented 2 days ago

On another note, I'd like to get opinions on how to handle a situation I have. I have thermostats (in particularly I have the Tekmar 552) used for radiant flooring that use the room air sensor but still have a slab minimum configuration. Essentially, the floor is heated if the air temp is below the heat setpoint but the floor is also heated if the floor temp is below the slab minimum (which is essentially the slab setpoint). I use this to keep tile floors warm, even if the room is at air temp.

The problem is that these thermostats do not have the SlabSetpoint attribute turned on in the DeviceAttributes when they're configured this way. Consequently, the slab setpoint is not available in Home Assistant as this integration only includes slab-setpoint if the SlapSetpoint attribute is set. Any thoughts on the right way to handle this?

WillCodeForCats commented 2 days ago

The problem is that these thermostats do not have the SlabSetpoint attribute turned on in the DeviceAttributes when they're configured this way. Consequently, the slab setpoint is not available in Home Assistant as this integration only includes slab-setpoint if the SlapSetpoint attribute is set. Any thoughts on the right way to handle this?

We can try removing that check and send the command anyway to see how it responds if the SlabSetpoint attribute is reporting off.

rjmcdougall commented 1 day ago

I worked on the same set of changes before discovering this! I had the same question about the device attributes -- I've been testing with a forced add of the slab attribute. I agree with your suggestion above about trying to see if it responds to SlabSetpoint.

rjmcdougall commented 1 day ago

How have you been testing this? I added this temporary override to test:


                    elif tha_method in ["DeviceAttributes"]:
                        _LOGGER.debug(
                            f"Address {b['address']} attributes {b['attributes']}"
                        )                           
                        self._tha_inventory[b["address"]]["attributes"].attrs = int(
                            b["attributes"] | 0b100
                        )            
rjmcdougall commented 1 day ago

I have 529, 553, 557 thermostats. This is working with 553/557 but greyed out for 529. Not sure why yet given it has the forced override.

rjmcdougall commented 1 day ago

I was able to resolve this for the 529 through the UI by setting enable on the setpoint settings.

WillCodeForCats commented 20 hours ago

In the slab-setpoint branch you can disable the check by removing line 518 in number.py to ignore the Slab_Setpoint attribute for availability.

https://github.com/WillCodeForCats/tekmar-482/blob/8f72fdfda223a155aa53aca6cb2c65e8eaf3cadc/custom_components/tekmar_482/number.py#L518

WillCodeForCats commented 20 hours ago

Release v0.9.21-pre.2