Crewski/njsPC-HA

Easytouch solar heating climate status shows as "cooling"

a1k0n opened this issue · 1 comments

a1k0n commented

Thanks for this integration; I've been enjoying this for a couple days now as my homeassistant slowly extends its tendrils into every single device on my house and property.

Only minor issue I'm running into is that when the solar heater is on, the climate widget in homeassistant says it's cooling.

Screenshot from 2022-09-13 14-47-48

I believe this can be traced back to this bit of code in this repo

NJSPC_HVAC_ACTION_TO_HASS = {
# Map to None if we do not know how to represent.
0: HVACAction.OFF,
1: HVACAction.HEATING,
2: HVACAction.HEATING,
3: HVACAction.COOLING,
4: HVACAction.HEATING,
6: HVACAction.HEATING,
8: HVACAction.COOLING,
128: HVACAction.OFF,
}

which doesn't exactly correspond to that of an Easytouch in nodejs-poolController:

https://github.com/tagyoureit/nodejs-poolController/blob/master/controller/boards/EasyTouchBoard.ts#L43-L50

        this.valueMaps.heatStatus = new byteValueMap([
            [0, { name: 'off', desc: 'Off' }],
            [1, { name: 'heater', desc: 'Heater' }],
            [2, { name: 'cooling', desc: 'Cooling' }],
            [3, { name: 'solar', desc: 'Solar' }],
            [4, { name: 'hpheat', desc: 'Heatpump' }],
            [5, { name: 'dual', desc: 'Dual'}]
        ]);

it looks like it corresponds to a Nixie board, so I'm guessing that's what you have yourself?

I'm not familiar with the API; there must be a way to get the friendly name of the heatStatus rather than the byte sent back from the controller and use that to map to HVACActions?

a1k0n commented

I'm going to test this change:

diff --git a/custom_components/njspc_ha/climate.py b/custom_components/njspc_ha/climate.py
index 8087c8a..6a3cd5a 100644
--- a/custom_components/njspc_ha/climate.py
+++ b/custom_components/njspc_ha/climate.py
@@ -14,14 +14,15 @@ from .const import DOMAIN, EVENT_AVAILABILITY, EVENT_BODY

 NJSPC_HVAC_ACTION_TO_HASS = {
     # Map to None if we do not know how to represent.
-    0: HVACAction.OFF,
-    1: HVACAction.HEATING,
-    2: HVACAction.HEATING,
-    3: HVACAction.COOLING,
-    4: HVACAction.HEATING,
-    6: HVACAction.HEATING,
-    8: HVACAction.COOLING,
-    128: HVACAction.OFF,
+    'off':      HVACAction.OFF,
+    'heater':   HVACAction.HEATING,
+    'solar':    HVACAction.HEATING,
+    'cooling':  HVACAction.COOLING,
+    'hpheat':   HVACAction.HEATING,
+    'hybheat':  HVACAction.HEATING,
+    'mtheat':   HVACAction.HEATING,
+    'hpcool':   HVACAction.COOLING,
+    'cooldown': HVACAction.OFF,
 }


@@ -182,7 +183,7 @@ class Climate(CoordinatorEntity, ClimateEntity):
     @property
     def hvac_action(self) -> HVACAction:
         try:
-            return NJSPC_HVAC_ACTION_TO_HASS[self._body["heatStatus"]["val"]]
+            return NJSPC_HVAC_ACTION_TO_HASS[self._body["heatStatus"]["name"]]
         except:
             return HVACAction.OFF

...but my solar heater just shut off.

I'll send a pull request if it tests out OK.