MTrab / danfoss_ally

Danfoss Ally integration for Home Assistant
GNU General Public License v3.0
40 stars 10 forks source link

Icon2 room thermostats "hvac_action" is inverted #97

Closed mbsjoeberg closed 6 months ago

mbsjoeberg commented 7 months ago

Environment:

Describe the bug

The hvac_action attribute is inverted, showing "Heating (heat)" when NOT heating and "Heat" when heating.

Debug log

danfoss_ally

Log when not heating (Setpoint: 20C note: "work_state": Heat seems correct)

2024-02-06 09:50:07.565 DEBUG (MainThread) [custom_components.danfoss_ally] Updating Danfoss Ally devices 2024-02-06 09:50:07.959 DEBUG (MainThread) [custom_components.danfoss_ally] bf4b9898f673dcbcf4bgdg: {'isThermostat': False, 'name': 'Danfoss Ally™ Gateway', 'online': True, 'update': 1707035282, 'model': 'Danfoss Ally™ Gateway', 'floor_sensor': False} 2024-02-06 09:50:07.959 DEBUG (MainThread) [custom_components.danfoss_ally] bf1ea44f44ab8e2745xboz: {'isThermostat': False, 'name': 'Danfoss Icon2 Controller', 'online': True, 'update': 1707035282, 'model': '', 'floor_sensor': False, 'switch': False, 'fault': 0} 2024-02-06 09:50:07.959 DEBUG (MainThread) [custom_components.danfoss_ally] bf4b8c17753602a162kaze: {'isThermostat': True, 'name': 'Gæstetoilet', 'online': True, 'update': 1707035282, 'model': '', 'floor_sensor': True, 'switch': True, 'mode': 'manual', 'work_state': 'Heat', 'temp_set': 21.0, 'upper_temp': 35.0, 'temperature': 22.3, 'lower_temp': 4.0, 'child_lock': False, 'battery': 87, 'fault': 0, 'floor_temperature': 27.4, 'humidity': 42.0, 'setpointchangesource': 'Externally', 'manual_mode_fast': 20.0, 'at_home_setting': 21.0, 'leaving_home_setting': 19.0, 'pause_setting': 5.0, 'holiday_setting': 15.0, 'switch_state': False, 'output_status': False}

2024-02-06 09:50:07.962 DEBUG (MainThread) [custom_components.danfoss_ally.binary_sensor] Loading new binary_sensor data for device bf4b9898f673dcbcf4bgdg 2024-02-06 09:50:07.962 DEBUG (MainThread) [custom_components.danfoss_ally.binary_sensor] Loading new binary_sensor data for device bf1ea44f44ab8e2745xboz 2024-02-06 09:50:07.963 DEBUG (MainThread) [custom_components.danfoss_ally.binary_sensor] Loading new binary_sensor data for device bf4b8c17753602a162kaze 2024-02-06 09:50:07.964 DEBUG (MainThread) [custom_components.danfoss_ally.sensor] Loading new sensor data for Ally Sensor for device bf4b8c17753602a162kaze 2024-02-06 09:50:07.965 DEBUG (MainThread) [custom_components.danfoss_ally.sensor] Loading new sensor data for Ally Sensor for device bf4b8c17753602a162kaze 2024-02-06 09:50:07.966 DEBUG (MainThread) [custom_components.danfoss_ally.climate] Loading new climate data for device bf4b8c17753602a162kaze

Log when heating (setpoint: 35C. note: "work_state": heat_active seems correct)

2024-02-06 09:40:52.523 DEBUG (MainThread) [custom_components.danfoss_ally] Updating Danfoss Ally devices 2024-02-06 09:40:52.942 DEBUG (MainThread) [custom_components.danfoss_ally] bf4b9898f673dcbcf4bgdg: {'isThermostat': False, 'name': 'Danfoss Ally™ Gateway', 'online': True, 'update': 1707035282, 'model': 'Danfoss Ally™ Gateway', 'floor_sensor': False} 2024-02-06 09:40:52.942 DEBUG (MainThread) [custom_components.danfoss_ally] bf1ea44f44ab8e2745xboz: {'isThermostat': False, 'name': 'Danfoss Icon2 Controller', 'online': True, 'update': 1707035282, 'model': '', 'floor_sensor': False, 'switch': False, 'fault': 0} 2024-02-06 09:40:52.943 DEBUG (MainThread) [custom_components.danfoss_ally] bf4b8c17753602a162kaze: {'isThermostat': True, 'name': 'Gæstetoilet', 'online': True, 'update': 1707035282, 'model': '', 'floor_sensor': True, 'switch': True, 'mode': 'manual', 'work_state': 'heat_active', 'temp_set': 21.0, 'upper_temp': 35.0, 'temperature': 22.3, 'lower_temp': 4.0, 'child_lock': False, 'battery': 87, 'fault': 0, 'floor_temperature': 27.2, 'humidity': 42.0, 'setpointchangesource': 'Externally', 'manual_mode_fast': 35.0, 'at_home_setting': 21.0, 'leaving_home_setting': 19.0, 'pause_setting': 5.0, 'holiday_setting': 15.0, 'switch_state': False, 'output_status': True} 2024-02-06 09:40:52.945 DEBUG (MainThread) [custom_components.danfoss_ally.binary_sensor] Loading new binary_sensor data for device bf4b9898f673dcbcf4bgdg 2024-02-06 09:40:52.945 DEBUG (MainThread) [custom_components.danfoss_ally.binary_sensor] Loading new binary_sensor data for device bf1ea44f44ab8e2745xboz 2024-02-06 09:40:52.945 DEBUG (MainThread) [custom_components.danfoss_ally.binary_sensor] Loading new binary_sensor data for device bf4b8c17753602a162kaze 2024-02-06 09:40:52.946 DEBUG (MainThread) [custom_components.danfoss_ally.binary_sensor] Loading new binary_sensor data for device bf4b8c17753602a162kaze 2024-02-06 09:40:52.946 DEBUG (MainThread) [custom_components.danfoss_ally.sensor] Loading new sensor data for Ally Sensor for device bf4b8c17753602a162kaze 2024-02-06 09:40:52.947 DEBUG (MainThread) [custom_components.danfoss_ally.sensor] Loading new sensor data for Ally Sensor for device bf4b8c17753602a162kaze 2024-02-06 09:40:52.947 DEBUG (MainThread) [custom_components.danfoss_ally.climate] Loading new climate data for device bf4b8c17753602a162kaze

MTrab commented 7 months ago

Just to understand correct - It shows idle when heating and heating when idle?

Could you try swapping line 496 and 498 in climate.py? Just to see if that fixes the issue

Should look like this after you have edited:

            if self._device["work_state"] == "heat_active":
                return HVACAction.IDLE
            elif self._device["work_state"] == "Heat":
                return HVACAction.HEATING

Remember to only swap 496 and 498 as the lines are found more than one place, but only these lines are for Icon devices

mbsjoeberg commented 7 months ago

Correct, entity state is idle when the controller is actually heating and "heating_active" when idle.

Changed the climate.py: image no other changes made.

Reloaded DanFoss Ally integration -> no impact Restarted HomeAssistant -> no impact.

Log still shows correct "work-state", but entity is missing "hvac_action" attribute when heating is actually active, but has it with value "heating", when actually idle.

danfoss_ally2

Heating active: 2024-02-06 13:44:21.249 DEBUG (MainThread) [custom_components.danfoss_ally] Updating Danfoss Ally devices 2024-02-06 13:44:21.623 DEBUG (MainThread) [custom_components.danfoss_ally] bf4b9898f673dcbcf4bgdg: {'isThermostat': False, 'name': 'Danfoss Ally™ Gateway', 'online': True, 'update': 1707035282, 'model': 'Danfoss Ally™ Gateway', 'floor_sensor': False} 2024-02-06 13:44:21.623 DEBUG (MainThread) [custom_components.danfoss_ally] bf1ea44f44ab8e2745xboz: {'isThermostat': False, 'name': 'Danfoss Icon2 Controller', 'online': True, 'update': 1707035282, 'model': '', 'floor_sensor': False, 'switch': False, 'fault': 0} 2024-02-06 13:44:21.623 DEBUG (MainThread) [custom_components.danfoss_ally] bf4b8c17753602a162kaze: {'isThermostat': True, 'name': 'Gæstetoilet', 'online': True, 'update': 1707035282, 'model': '', 'floor_sensor': True, 'switch': True, 'mode': 'manual', 'work_state': 'heat_active', 'temp_set': 21.0, 'upper_temp': 35.0, 'temperature': 22.4, 'lower_temp': 4.0, 'child_lock': False, 'battery': 87, 'fault': 0, 'floor_temperature': 26.2, 'humidity': 42.0, 'setpointchangesource': 'Externally', 'manual_mode_fast': 35.0, 'at_home_setting': 21.0, 'leaving_home_setting': 19.0, 'pause_setting': 5.0, 'holiday_setting': 15.0, 'switch_state': False, 'output_status': True}

Entity state when heating active (hvac_action attribute is missing!?): image

Heating idle: 2024-02-06 13:47:21.259 DEBUG (MainThread) [custom_components.danfoss_ally] Updating Danfoss Ally devices 2024-02-06 13:47:21.680 DEBUG (MainThread) [custom_components.danfoss_ally] bf4b9898f673dcbcf4bgdg: {'isThermostat': False, 'name': 'Danfoss Ally™ Gateway', 'online': True, 'update': 1707035282, 'model': 'Danfoss Ally™ Gateway', 'floor_sensor': False} 2024-02-06 13:47:21.680 DEBUG (MainThread) [custom_components.danfoss_ally] bf1ea44f44ab8e2745xboz: {'isThermostat': False, 'name': 'Danfoss Icon2 Controller', 'online': True, 'update': 1707035282, 'model': '', 'floor_sensor': False, 'switch': False, 'fault': 0} 2024-02-06 13:47:21.680 DEBUG (MainThread) [custom_components.danfoss_ally] bf4b8c17753602a162kaze: {'isThermostat': True, 'name': 'Gæstetoilet', 'online': True, 'update': 1707035282, 'model': '', 'floor_sensor': True, 'switch': True, 'mode': 'manual', 'work_state': 'Heat', 'temp_set': 21.0, 'upper_temp': 35.0, 'temperature': 22.4, 'lower_temp': 4.0, 'child_lock': False, 'battery': 87, 'fault': 0, 'floor_temperature': 26.2, 'humidity': 42.0, 'setpointchangesource': 'Externally', 'manual_mode_fast': 20.0, 'at_home_setting': 21.0, 'leaving_home_setting': 19.0, 'pause_setting': 5.0, 'holiday_setting': 15.0, 'switch_state': False, 'output_status': False}

Entity state when heating is idle: danfoss_ally3

MTrab commented 7 months ago

Guess I'd need access to a system to fix this. Right now I'm just guessing.

mbsjoeberg commented 7 months ago

I'll see if i can find th eproblem and will revert asap. Might be a day or two beofre i have time.

HologramDK commented 7 months ago

I can confirm, though I am only on 1.2.1. When the Ally app shows the temperature mode to be "heat_active", the hvac_action state is missing on the HA entity. When the Ally app shows the temperature mode to be "Heat", hvac_action shows up with state "heating".

MTrab commented 7 months ago

Okay - so actually not a beta issue then ;) That makes much more sense, as the codebase haven't changed around that

MTrab commented 7 months ago

Guess the values have changed. Awaiting Danfoss' response to what the actual values returned are.

mbsjoeberg commented 7 months ago

okidoke - be aware there might be different values / addresses for Icon and Icon2 (i did some zigbee sniffing a few weeks ago and got a feeling they had shifted those at least; this of course might not propagate to their ally api, but you never know :) ).

MTrab commented 6 months ago

Would it be possible to lend an API key and secret, so we can get this fixed?

MTrab commented 6 months ago

Or perhaps send me the FULL output of test.py in https://github.com/mtrab/pydanfossally

HologramDK commented 6 months ago

I tried running the test.py script by following this guide: https://www.home-assistant.io/integrations/python_script/

Unfortunately I'm getting an error in the log, and seemingly no other output: Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/components/python_script/init.py", line 224, in execute exec(compiled.code, restricted_globals) # noqa: S102 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "test_ally.py", line 3, in ImportError: import not found

Since I rarely ever get that far under the hood of HA, I assume I'm doing something wrong :) Is there an easier/smarter way to run the script? Otherwise I'll dig out some keys later.

MTrab commented 6 months ago

Cannot be run in Home Assistant ;) It is only to be run on your computer.

Otherwise drop the key and secret on my email github_2024(at)trab.dk and I'll do some tests to find why it's not working as intended

MTrab commented 6 months ago

Think I have found the reason for this - and I'm not sure it's fixable as of right now :/ The Icon devices doesn't get recognized as Icon devices and hence the checks for heating and not heating is invalid as the values are not identical between Icon and Ally thermostats. I think I need to take this up with Danfoss for this to be resolved.

MTrab commented 6 months ago

For the EXPERIENCED user, try changing line 567 in climate.py to look like this, and see if that might (at least temporarily) fix the issue:

    if model == "Icon RT" or model == "":

I'm not sure if this will have any negative impact, but the Icon2 devices doesn't report the model, which is why it's not matched correct.

HologramDK commented 6 months ago

That seems to have fixed the issue for me, on an ICON2 system. When not heating, hvac_action is idle. When heating, hvac_action is heating. This is also correctly reflected in the Thermostat cards

mbsjoeberg commented 6 months ago

Same here, works fine on both wired Icon2 RT 24V (088U2125) and wireless Icon2 RT Featured (088U2122)

mbsjoeberg commented 6 months ago

@MTrab DanFoss must have changed the API. For Icon2 room thermostats, 'model' now reports 'Danfoss Icon2 RT', instead of ''. image

Chaning line 567 in climate.py to the below solves the problem: if model == "Icon RT" or model == "Danfoss Icon2 RT":

MTrab commented 6 months ago

Correct - Danfoss have fixed the missing model name for the Icon devices