zigpy / zha-device-handlers

ZHA device handlers bridge the functionality gap created when manufacturers deviate from the ZCL specification, handling deviations and exceptions by parsing custom messages to and from Zigbee devices.
Apache License 2.0
721 stars 670 forks source link

[Device Support Request] TS0601 _TZE200_a4bpgplm tuya trv #1159

Closed joaoasilva closed 10 months ago

joaoasilva commented 2 years ago

Is your feature request related to a problem? Please describe. Bought this thermostat from AliExpress looking at this https://zigbee.blakadder.com/Haozee_TRV601.html that says it works with ZHA but it doesn't. It's possible to get the temperature and set but most of the stuff doesn't work.

Describe the solution you'd like For it to work ex: window status, schedule, turn on/off.

Someone already converted it successfully to work on HA but I don't understand how can I port that to ZHA here: https://github.com/Koenkk/zigbee-herdsman-converters/blob/245fc8273e3afac8d71ec196d0e3ae71e413cba9/lib/tuya.js#L426

Please help. Thanks

MattWestb commented 2 years ago

I have making one new preset with PRESET_NONE, PRESET_BOOST, PRESET_SCHEDULE. Download and rename the file to climate.py and copy it in the HA container as with the first version. climate.py.rtitek.txt .

laurius commented 2 years ago

@MattWestb thanks, replaced the climate.py. When selecting boost i get the error: Failed to call service climate /set_preset_mode . 'NoneType' object is not iterable Selecting schedule works fine and changes the symbon on the TRV display.

MattWestb commented 2 years ago

Hopefully fixed BOOST: climate.py.rtitek2.txt

jacekk015 commented 2 years ago

@laurius To be honest I still doesn't see anything happens. I see 0x0104 switched to [1] and nothing more. That BOOST mode comes mostly from user info, since we don't have those TRVs. It's very possible that it isn't really BOOST. You can try to find it - just switch every switch on TRV, one by one, and check the logs for changing value of 0x0104, between [0] and [1]. If Matts "BOOST" Preset will work it should switch the switch. You could see on TRV what's changing. If that wont work - I can make a temporary switch to test that attribute 0x0104

2021-12-05 13:44:27 DEBUG (MainThread) [zigpy.zcl] [0xf4bc:1:0xef00] ZCL request 0x0002: [Command(status=0, tsn=63, command_id=260, function=0, data=[1, 1])]
2021-12-05 13:44:27 DEBUG (MainThread) [zhaquirks.tuya] [0xf4bc:1:0xef00] Received value [1] for attribute 0x0104 (command 0x0002)
2021-12-05 13:44:27 DEBUG (MainThread) [homeassistant.components.zha.core.channels.base] [0xF4BC:1:0x0201]: Attribute report 'RtiThermostat'[programing_oper_mode] = ProgrammingOperationMode.Simple
2021-12-05 13:44:27 DEBUG (MainThread) [homeassistant.components.zha.core.channels.base] [0xF4BC:1:0x0201]: Attribute report 'RtiThermostat'[occupancy] = Occupancy.Occupied
2021-12-05 13:44:27 DEBUG (MainThread) [homeassistant.components.zha.core.channels.base] [0xF4BC:1:0x0201]: Attribute report 'RtiThermostat'[operation_preset] = Preset.Boost
2021-12-05 13:44:27 DEBUG (MainThread) [homeassistant.components.zha.entity] climate.tze200_a4bpgplm_ts0601_734540fe_thermostat: Attribute 'programing_oper_mode' = ProgrammingOperationMode.Simple update
2021-12-05 13:44:27 DEBUG (MainThread) [homeassistant.components.zha.entity] climate.tze200_a4bpgplm_ts0601_734540fe_thermostat: Attribute 'occupancy' = Occupancy.Occupied update
2021-12-05 13:44:27 DEBUG (MainThread) [homeassistant.components.zha.entity] climate.tze200_a4bpgplm_ts0601_734540fe_thermostat: Attribute 'operation_preset' = Preset.Boost update
2021-12-05 13:45:35 DEBUG (MainThread) [zigpy.zcl] [0xf4bc:1:0xef00] ZCL deserialize: <ZCLHeader frame_control=<FrameControl frame_type=CLUSTER_COMMAND manufacturer_specific=False is_reply=True disable_default_response=False> manufacturer=None tsn=35 command_id=1>
2021-12-05 13:45:35 DEBUG (MainThread) [zigpy.zcl] [0xf4bc:1:0xef00] ZCL request 0x0001: [Command(status=0, tsn=64, command_id=515, function=0, data=[4, 0, 0, 0, 228])]
2021-12-05 13:45:35 DEBUG (MainThread) [zhaquirks.tuya] [0xf4bc:1:0xef00] Received value [0, 0, 0, 228] for attribute 0x0203 (command 0x0001)
2021-12-05 13:45:35 DEBUG (MainThread) [homeassistant.components.zha.core.channels.base] [0xF4BC:1:0x0201]: Attribute report 'RtiThermostat'[local_temp] = 2280
2021-12-05 13:45:35 DEBUG (MainThread) [homeassistant.components.zha.entity] climate.tze200_a4bpgplm_ts0601_734540fe_thermostat: Attribute 'local_temp' = 2280 update
2021-12-05 13:46:07 DEBUG (MainThread) [zigpy.zcl] [0xf4bc:1:0xef00] ZCL deserialize: <ZCLHeader frame_control=<FrameControl frame_type=CLUSTER_COMMAND manufacturer_specific=False is_reply=True disable_default_response=False> manufacturer=None tsn=36 command_id=1>
2021-12-05 13:46:07 DEBUG (MainThread) [zigpy.zcl] [0xf4bc:1:0xef00] ZCL request 0x0001: [Command(status=0, tsn=65, command_id=515, function=0, data=[4, 0, 0, 0, 230])]
2021-12-05 13:46:07 DEBUG (MainThread) [zhaquirks.tuya] [0xf4bc:1:0xef00] Received value [0, 0, 0, 230] for attribute 0x0203 (command 0x0001)
2021-12-05 13:46:07 DEBUG (MainThread) [homeassistant.components.zha.core.channels.base] [0xF4BC:1:0x0201]: Attribute report 'RtiThermostat'[local_temp] = 2300
2021-12-05 13:46:07 DEBUG (MainThread) [homeassistant.components.zha.entity] climate.tze200_a4bpgplm_ts0601_734540fe_thermostat: Attribute 'local_temp' = 2300 update
2021-12-05 13:47:05 DEBUG (MainThread) [zigpy.zcl] [0xf4bc:1:0xef00] ZCL deserialize: <ZCLHeader frame_control=<FrameControl frame_type=CLUSTER_COMMAND manufacturer_specific=False is_reply=True disable_default_response=False> manufacturer=None tsn=37 command_id=1>
2021-12-05 13:47:05 DEBUG (MainThread) [zigpy.zcl] [0xf4bc:1:0xef00] ZCL request 0x0001: [Command(status=0, tsn=66, command_id=515, function=0, data=[4, 0, 0, 0, 225])]
2021-12-05 13:47:05 DEBUG (MainThread) [zhaquirks.tuya] [0xf4bc:1:0xef00] Received value [0, 0, 0, 225] for attribute 0x0203 (command 0x0001)
2021-12-05 13:47:05 DEBUG (MainThread) [homeassistant.components.zha.core.channels.base] [0xF4BC:1:0x0201]: Attribute report 'RtiThermostat'[local_temp] = 2250
2021-12-05 13:47:05 DEBUG (MainThread) [homeassistant.components.zha.entity] climate.tze200_a4bpgplm_ts0601_734540fe_thermostat: Attribute 'local_temp' = 2250 update
2021-12-05 13:47:09 DEBUG (MainThread) [zigpy.zcl] [0xf4bc:1:0xef00] ZCL deserialize: <ZCLHeader frame_control=<FrameControl frame_type=CLUSTER_COMMAND manufacturer_specific=False is_reply=True disable_default_response=False> manufacturer=None tsn=38 command_id=1>
2021-12-05 13:47:09 DEBUG (MainThread) [zigpy.zcl] [0xf4bc:1:0xef00] ZCL request 0x0001: [Command(status=0, tsn=67, command_id=515, function=0, data=[4, 0, 0, 0, 230])]
2021-12-05 13:47:09 DEBUG (MainThread) [zhaquirks.tuya] [0xf4bc:1:0xef00] Received value [0, 0, 0, 230] for attribute 0x0203 (command 0x0001)
2021-12-05 13:47:09 DEBUG (MainThread) [homeassistant.components.zha.core.channels.base] [0xF4BC:1:0x0201]: Attribute report 'RtiThermostat'[local_temp] = 2300
2021-12-05 13:47:09 DEBUG (MainThread) [homeassistant.components.zha.entity] climate.tze200_a4bpgplm_ts0601_734540fe_thermostat: Attribute 'local_temp' = 2300 update
anlu85 commented 2 years ago

@jacekk015 Thank you for the updated file!

I just replaced the file in my HA, restarted and reconnect after a factory reset.

Min/Max values are fine. I don't have the time to test it in detail right now, but I noticed the value sate (%) does not to work (anymore? Not total sure, but I think it showed at least any value as in the screenshot I sent before...) image

Here is the related logfile: home-assistant (3).log

jacekk015 commented 2 years ago

@anlu85 Valve position is RTI_VALVE_POSITION_ATTR = 0x0266 I don't see it in your LOGs, maybe because TRV doesn't heat, so it's not sending any data to 0x0266 Set target temp to 30 degrees - it will heat for sure then.

jamjam9 commented 2 years ago

Factory reset and re paired. All looking good. 1 minor issue is the calibration scale shows in lovelace from -20 to +20, but it only effects the reported temp with the scale -2 to + 2.

Log of the pair and 10 minutes attached. I changes many settings both in lovelace and ont he device itself and all works ok.

Also set temp in node red also works.

Thanks jacekk015 , can I buy you a beer?

home-assistant.log

jacekk015 commented 2 years ago

@jamjam9 Thanks! Check physically on the TRV what is the range of temp Calibration. I don't know the range myself. So you need to check it or post a manual page - didn't find any.

@anlu85 Reset you calibration to the center, to zero. You can get strange results because of that.

jamjam9 commented 2 years ago

Nothing in the manual , it might be mentioned in the tuya app. It's no bother really as I can work around the values reported.

MattWestb commented 2 years ago

For later then the basic is in place:

One thing with presets and presets / modes. In the video before its looks the TRV is going in off mode the setting the local tem to or under the min temp its having and on if to or over the max temp. Is it aslo reporting mode changed on attribute 0x0401 ??

Both is defined as modes and can being mapped as preset if the TRV is in that mode.

I think its good setting the same presets in ZHA as the device is showing / being in. I think TRV On / Off in ZHA is no good function then its still alive and also On and Off is breaking the heating algorithm in the device but user can using that in automations then having it as presets in ZHA.

jacekk015 commented 2 years ago

@MattWestb RTI_TARGET_TEMP_ATTR = 0x0202 # target room temp (decidegree) RTI_TEMPERATURE_ATTR = 0x0203 # current room temp (decidegree) RTI_MODE_ATTR = 0x0401 # [0] schedule [1] manual [2] off [3] on RTI_CHILD_LOCK_ATTR = 0x010C # [0] unlocked [1] locked RTI_TEMP_CALIBRATION_ATTR = 0x0265 # temperature calibration (degree) RTI_MIN_TEMPERATURE_ATTR = 0x020F # minimum limit of temperature setting (decidegree) RTI_MAX_TEMPERATURE_ATTR = 0x0210 # maximum limit of temperature setting (decidegree) RTI_WINDOW_DETECT_ATTR = 0x0108 # [0] alarm not active [1] alarm active RTI_BOOST_ATTR = 0x0104 # [0] off [1] on RTI_BOOST_COUNTDOWN_ATTR = 0x0205 # (seconds) RTI_VALVE_POSITION_ATTR = 0x0266 # opening percentage /10 RTI_VALVE_STATE_ATTR = 0x0406 # [0] closed [1] opened RTI_BATTERY_ATTR = 0x020D # battery percentage remaining 0-100% RTI_SOFT_VER_ATTR = 0x0296 # 109 means 1.0.9

@jamjam9 Really, please check it on TRV. It's a quick code change then. Just need to know the range and stepping. Put logs and that's all I need. Maybe someone also find what 0x0104 is responsible for - it looks that's not a Boost.

anlu85 commented 2 years ago

@jacekk015 I changed the offset-value to 0°C (it was on NaN after pairing, didn't change it)

The valve is active right now and shows a valve state of 55% on the OLED.

Here is the updated log (I can't still does not show any 0x0266 message)

home-assistant (7).log

(I also checked the log file I saved before for it - without any results. May be it just never worked and I set in once by hand...)

MattWestb commented 2 years ago

0x0104 Antifreeze with 0x0205 as temperature ??

Try put on TRV in the freezer and looking if its sending something then going down to zero °C

anlu85 commented 2 years ago

When checking the manual of the my valve (OLED) I can't find anything about a boost function. But there is something written about an "anti-scale" function that will be activated every Monday at 12:00: --> I think "anti-scale" is the translation mistake, the function is for calcification protection.

laurius commented 2 years ago

There is a temporary mode in addition to schedule and manual IMG_20211205_162046 Also didn't find anything mentioning boost.

MattWestb commented 2 years ago

So likely 0x0104 = anti calc / valve jammed function and 0x0205 is valve is jammed.

For Siterwell its working having it activated and putting the setpoint some degree over the local and waiting some hours its sending the alarm and showing ! then not being mounted on one radiator.

MattWestb commented 2 years ago

Temporary is then you have TRV in schedule mode and setting / sending one new setpoint temperature and its staying until next time is executed changing the setpoint temperature.

I hope the TRV is staying in schedule mode and ZHA shall doing the same if the TRV is in that mode.

Edit: The TRV dont have time programs in hardware so all schedule is done from the host system software, The trickey is they is showing 4 different icons for day / night and home away that must being sent to the device from the host system.

jamjam9 commented 2 years ago

home-assistant.log

Log after moving calibration slider several times

jacekk015 commented 2 years ago

Temp calibration corrected It looks like +2/-2 range with step 0.1 Code changed. ts0601_trv_rtitek.py.zip

jacekk015 commented 2 years ago

Boost mode came from Z2M

Model configuration https://github.com/Koenkk/zigbee-herdsman-converters/blob/master/devices/tuya.js#L926

Parameters DP DP4 = 0x0104 DP5 = 0x0205 DP102 = 0x0266 which they say it's valve opening position https://github.com/Koenkk/zigbee-herdsman-converters/blob/master/lib/tuya.js#L430

https://github.com/Koenkk/zigbee-herdsman-converters/issues/3190#issue-1030558948

jacekk015 commented 2 years ago

@anlu85 You had a valve position in that post - see picture, and you have OLED version. https://github.com/zigpy/zha-device-handlers/issues/1159#issuecomment-986099831

[edit] After check all your logs I've found Valve position 0x0266 only in logs of jamjam9

2021-12-02 21:12:23 DEBUG (MainThread) [zigpy.zcl] [0x1afd:1:0xef00] ZCL request 0x0001: [Command(status=0, tsn=154, command_id=614, function=0, data=[4, 0, 0, 0, 0])]
2021-12-02 21:12:23 DEBUG (MainThread) [zhaquirks.tuya] [0x1afd:1:0xef00] Received value [0, 0, 0, 0] for attribute 0x0266 (command 0x0001)
2021-12-02 21:12:23 DEBUG (MainThread) [zigpy.zcl] [0x1afd:1:0xef00] ZCL request 0x0001: [Command(status=0, tsn=154, command_id=614, function=0, data=[4, 0, 0, 0, 0])]
2021-12-02 21:12:23 DEBUG (MainThread) [zhaquirks.tuya] [0x1afd:1:0xef00] Received value [0, 0, 0, 0] for attribute 0x0266 (command 0x0001)

joaoasilva

2021-12-03 09:43:05 DEBUG (MainThread) [zigpy.zcl] [0x3b1f:1:0xef00] ZCL request 0x0001: [Command(status=0, tsn=129, command_id=614, function=0, data=[4, 0, 0, 0, 0])]
2021-12-03 09:43:05 DEBUG (MainThread) [zhaquirks.tuya] [0x3b1f:1:0xef00] Received value [0, 0, 0, 0] for attribute 0x0266 (command 0x0001)
2021-12-03 09:44:04 DEBUG (MainThread) [zigpy.zcl] [0x3b1f:1:0xef00] ZCL request 0x0001: [Command(status=0, tsn=150, command_id=614, function=0, data=[4, 0, 0, 3, 232])]
2021-12-03 09:44:04 DEBUG (MainThread) [zhaquirks.tuya] [0x3b1f:1:0xef00] Received value [0, 0, 3, 232] for attribute 0x0266 (command 0x0001)

[0, 0, 3, 232] 3*255 + 232 = 997 / 10 = 99,7% opened valve Both are LED versions

jacekk015 commented 2 years ago

Someone want to play with values? You can do this with Cluster Manager on device card. Choose RtiManufCluster cluster and then you have attributes, which you can manually read/write to/from TRV. Change them and see what's changing on your TRV.

RTI_TARGET_TEMP_ATTR = 0x0202 # target room temp (decidegree) -> target_temperature RTI_TEMPERATURE_ATTR = 0x0203 # current room temp (decidegree) -> temperature RTI_MODE_ATTR = 0x0401 # [0] schedule [1] manual [2] off [3] on -> mode RTI_CHILD_LOCK_ATTR = 0x010C # [0] unlocked [1] locked -> child_lock RTI_TEMP_CALIBRATION_ATTR = 0x0265 # temperature calibration (degree) -> temperature_calibration RTI_MIN_TEMPERATURE_ATTR = 0x020F # minimum limit of temperature setting (decidegree) -> min_temperature RTI_MAX_TEMPERATURE_ATTR = 0x0210 # maximum limit of temperature setting (decidegree) -> max_temperature RTI_WINDOW_DETECT_ATTR = 0x0108 # [0] alarm not active [1] alarm active -> window_detection RTI_BOOST_ATTR = 0x0104 # [0] off [1] on -> boost_enabled RTI_BOOST_COUNTDOWN_ATTR = 0x0205 # (seconds) -> boost_duration_seconds RTI_VALVE_POSITION_ATTR = 0x0266 # opening percentage /10 -> valve_position RTI_VALVE_STATE_ATTR = 0x0406 # [0] closed [1] opened -> valve_state RTI_BATTERY_ATTR = 0x020D # battery percentage remaining 0-100% -> battery

jamjam9 commented 2 years ago

Temp calibration corrected It looks like +2/-2 range with step 0.1 Code changed. ts0601_trv_rtitek.py.zip

Tested , all fine , lovelace showing -2 to +2 scale. Thanks.

laurius commented 2 years ago

Reading after factory reset: RTI_TARGET_TEMP_ATTR = 0x0202 # target room temp (decidegree) -> target_temperature -> 150 RTI_TEMPERATURE_ATTR = 0x0203 # current room temp (decidegree) -> temperature -> 219 RTI_MODE_ATTR = 0x0401 # [0] schedule [1] manual [2] off [3] on -> mode -> 1 RTI_CHILD_LOCK_ATTR = 0x010C # [0] unlocked [1] locked -> child_lock -> 0 RTI_TEMP_CALIBRATION_ATTR = 0x0265 # temperature calibration (degree) -> temperature_calibration -> None RTI_MIN_TEMPERATURE_ATTR = 0x020F # minimum limit of temperature setting (decidegree) -> min_temperature -> 50 RTI_MAX_TEMPERATURE_ATTR = 0x0210 # maximum limit of temperature setting (decidegree) -> max_temperature -> 350 RTI_WINDOW_DETECT_ATTR = 0x0108 # [0] alarm not active [1] alarm active -> window_detection -> 0 RTI_BOOST_ATTR = 0x0104 # [0] off [1] on -> boost_enabled -> 0 RTI_BOOST_COUNTDOWN_ATTR = 0x0205 # (seconds) -> boost_duration_seconds -> None RTI_VALVE_POSITION_ATTR = 0x0266 # opening percentage /10 -> valve_position -> None RTI_VALVE_STATE_ATTR = 0x0406 # [0] closed [1] opened -> valve_state -> 0 RTI_BATTERY_ATTR = 0x020D # battery percentage remaining 0-100% -> battery -> 45

Changing values: RTI_TARGET_TEMP_ATTR = 0x0202 # target room temp (decidegree) -> target_temperature -> changing possible 210 -> 21°C RTI_TEMPERATURE_ATTR = 0x0203 # current room temp (decidegree) -> temperature -> if set overwritten by current temp RTI_MODE_ATTR = 0x0401 # [0] schedule [1] manual [2] off [3] on -> mode -> 0: schedule symbol and 15°C, 1: current setpoint from HA, 3: Off RTI_CHILD_LOCK_ATTR = 0x010C # [0] unlocked [1] locked -> child_lock -> 0: no lock symbol, 1: lock symbol RTI_TEMP_CALIBRATION_ATTR = 0x0265 # temperature calibration (degree) -> temperature_calibration -> no change visible to me in temperature value, maybe i looked at the wrong values RTI_MIN_TEMPERATURE_ATTR = 0x020F # minimum limit of temperature setting (decidegree) -> min_temperature -> as expected changing to 60 sets limit to 6°C RTI_MAX_TEMPERATURE_ATTR = 0x0210 # maximum limit of temperature setting (decidegree) -> max_temperature -> as expected changing to 250 sets limit to 25°C RTI_WINDOW_DETECT_ATTR = 0x0108 # [0] alarm not active [1] alarm active -> window_detection -> setting this to one activates it showing window signal on TRV display RTI_BOOST_ATTR = 0x0104 # [0] off [1] on -> boost_enabled -> can be set but no change on TRV visible RTI_BOOST_COUNTDOWN_ATTR = 0x0205 # (seconds) -> boost_duration_seconds -> can be set but no change on TRV visible RTI_VALVE_POSITION_ATTR = 0x0266 # opening percentage /10 -> valve_position -> still none even if changing cluster attribute RTI_VALVE_STATE_ATTR = 0x0406 # [0] closed [1] opened -> valve_state -> if valve pos is different from 0% -> 1 RTI_BATTERY_ATTR = 0x020D # battery percentage remaining 0-100% -> battery -> overwritten by current state

anlu85 commented 2 years ago

Hey together!

how is your expirience with the valve so far? I got my running for a view days now and noticed two things (running the OLED Version):

I have an automation that should set the target temperature to 19°C in the morgning. When I am trying the script, everything look fine - but in the morging it never worked. I hat the same script running with another trv before and everything worked fine. In the evening, I am reducing the temp with an similar script. This works also fine with the TZE200.

I am not so familar reading the log files - seems to me like something strange with the operation mode is happening. May be you have an idea....

This is the automation:

alias: Heizung Küche ein
description: ''
trigger:
  - platform: time
    at: '05:30'
condition: []
action:
  - service: climate.set_temperature
    data:
      temperature: 19
    target:
      device_id: b2a081fafd5c615b4476f82d91e7370a
mode: single

And here are the logs:

2021-12-09 05:30:00 INFO (MainThread) [homeassistant.components.automation.heizung_kuche_ein] Heizung Küche ein: Running automation actions
2021-12-09 05:30:00 INFO (MainThread) [homeassistant.components.automation.heizung_kuche_ein] Heizung Küche ein: Executing step call service
2021-12-09 05:30:00 INFO (MainThread) [homeassistant.components.automation.neue_automatisierung_3] Heizung / Küchenlicht Timer: Running automation actions
2021-12-09 05:30:00 INFO (MainThread) [homeassistant.components.automation.neue_automatisierung_3] Heizung / Küchenlicht Timer: Executing step device automation
2021-12-09 05:30:00 DEBUG (MainThread) [zhaquirks.tuya] [0x3c60:1:0x0201] Mapping standard system_mode (0x001c) with value <SystemMode.Heat: 4> to custom {1025: <Preset.Manual: 2>}
2021-12-09 05:30:00 DEBUG (MainThread) [homeassistant.components.zha.core.channels.base] [0x3C60:1:0x0201]: wrote {'system_mode': <SystemMode.HEAT: 4>} attrs, Status: [[WriteAttributesStatusRecord(status=<Status.SUCCESS: 0>)]]
2021-12-09 05:30:00 DEBUG (MainThread) [homeassistant.components.zha.core.channels.base] [0x3C60:1:0x0201]: set system to SystemMode.HEAT
2021-12-09 05:30:00 DEBUG (MainThread) [zhaquirks.tuya] [0x3c60:1:0x0201] Mapping standard occupied_heating_setpoint (0x0012) with value 1900 to custom {514: 190.0}
2021-12-09 05:30:00 DEBUG (MainThread) [homeassistant.components.zha.core.channels.base] [0x3C60:1:0x0201]: wrote {'occupied_heating_setpoint': 1900} attrs, Status: [[WriteAttributesStatusRecord(status=<Status.SUCCESS: 0>)]]
12-09 05:30:30 DEBUG (MainThread) [homeassistant.components.zha.core.channels.base] [0x3C60:1:0x0201]: Attribute report 'RtiThermostat'[programing_oper_mode] = ProgrammingOperationMode.Schedule_programming_mode
2021-12-09 05:30:30 DEBUG (MainThread) [homeassistant.components.zha.core.channels.base] [0x3C60:1:0x0201]: Attribute report 'RtiThermostat'[occupancy] = Occupancy.Occupied
2021-12-09 05:30:30 DEBUG (MainThread) [homeassistant.components.zha.core.channels.base] [0x3C60:1:0x0201]: Attribute report 'RtiThermostat'[operation_preset] = Preset.Schedule
2021-12-09 05:30:30 DEBUG (MainThread) [homeassistant.components.zha.entity] climate.tze200_a4bpgplm_ts0601_b3923cfe_thermostat: Attribute 'programing_oper_mode' = ProgrammingOperationMode.Schedule_programming_mode update
2021-12-09 05:30:30 DEBUG (MainThread) [homeassistant.components.zha.entity] climate.tze200_a4bpgplm_ts0601_b3923cfe_thermostat: Attribute 'occupancy' = Occupancy.Occupied update
2021-12-09 05:30:30 DEBUG (MainThread) [homeassistant.components.zha.entity] climate.tze200_a4bpgplm_ts0601_b3923cfe_thermostat: Attribute 'operation_preset' = Preset.Schedule update
2021-12-09 05:30:30 DEBUG (MainThread) [homeassistant.components.zha.core.channels.base] [0x3C60:1:0x0201]: Attribute report 'RtiThermostat'[local_temp] = 1620
2021-12-09 05:30:30 DEBUG (MainThread) [homeassistant.components.zha.entity] climate.tze200_a4bpgplm_ts0601_b3923cfe_thermostat: Attribute 'local_temp' = 1620 update

The second issue I have is reagding the messured temperature. Most of the time it is completely fine, but from time to time I have some strange peaks in the history:

image

When I check the log the Valve I see a message where the Valve send a raw value of 655260. I also noticed this morning that the valve started to re-adapt itself - but I am not sure if it was at the time the peak occur in the logs.... Again, may be you have an idea about this... log_peak.txt

Thanks in advance!!

jacekk015 commented 2 years ago

This is the automation:

You change the temperature but what about Preset? It looks like you're still in Scheduled mode. System mode is not a proper attribute since it depends for On/Off of the device. Presets are responsible for TRV working mode.

That peak was send by TRV itself.

2021-12-09 10:42:19 DEBUG (MainThread) [zigpy.zcl] [0x3c60:1:0xef00] ZCL deserialize: <ZCLHeader frame_control=<FrameControl frame_type=CLUSTER_COMMAND manufacturer_specific=False is_reply=True disable_default_response=False> manufacturer=None tsn=28 command_id=1>
2021-12-09 10:42:19 DEBUG (MainThread) [zigpy.zcl] [0x3c60:1:0xef00] ZCL request 0x0001: [Command(status=0, tsn=5, command_id=515, function=0, data=[4, 0, 0, 255, 246])]
2021-12-09 10:42:19 DEBUG (MainThread) [zhaquirks.tuya] [0x3c60:1:0xef00] Received value [0, 0, 255, 246] for attribute 0x0203 (command 0x0001)
2021-12-09 10:42:19 DEBUG (MainThread) [homeassistant.components.zha.core.channels.base] [0x3C60:1:0x0201]: Attribute report 'RtiThermostat'[local_temp] = 655260
2021-12-09 10:42:19 DEBUG (MainThread) [homeassistant.components.zha.entity] climate.tze200_a4bpgplm_ts0601_b3923cfe_thermostat: Attribute 'local_temp' = 655260 update
MattWestb commented 2 years ago

@anlu85 I think your TRV was in Scheduled mode = its using the time program setpoints in the device and you cant overriding it by sending one new setpoint temperature (is depends how the device is working internal).

On the TRV device card you have "presets" and "none" = manual mode for setting manual setpoint temperature.

Can you doing changing of presets from the TRV card and posting the log so jacekk015 can see is its working OK or not ?

If the mapping is not OK then its being problem sending commands to the device then its put of sync.

anlu85 commented 2 years ago

Thanks for your advices!!

Regarding the Peak: it is correct that the value is send by the trv. I just restartet the adaption prozess again - seems it always send this value while adapting. It's not the nicest behavior or the trv, cause it crashes all the graphs while doing it :-( Maybe I should more why it adapted itself... However, if it is not only me having this behavior it might be a nice feature to filter out this values (if this is possible)

Regarding Scheduling / Preset: I am pretty sure I have set it on manual mode on the TRV itself, but may be someone of my family (or I by myself) changed it by adjusting the temperature. My problem right now is that I can't find anything regarding this on the TRV card. By googleing I found some screenshots how it apeard on Is there any trick to activate this feature? (Sorry if this is a dumb question...)

This is all I got:

image image

jacekk015 commented 2 years ago

@anlu85 You're missing Preset, file climate.py update. Those peeks are filtered in file below. I hope no one else will have a room temp over 6000 degress, because it won't work for him ;-) ts0601_trv_rtitek.py.zip

There are no dumb questions. @MattWestb Probably have, or can cook, a good file for you.

RTI_MODE_ATTR = 0x0401  # [0] schedule [1] manual [2] off [3] on

on/off ommited

MattWestb commented 2 years ago

Some TRV have anticalking / valve conditioning with or without alarm that can being on or off that i think is doing the same as you have described but we have not finding any command in the device that can enabling / disabling that function in rtitek TRVs.

It can also being the TRV is trying heating for adjusting its algorithms (calibrating it to one room takes days) but then it shall being lesser after some days.

MattWestb commented 2 years ago

Presets for ZHA.climate_rtitek2.zip Unzip and putting in your HA config folder. Copy it into the HA docker container by open one CLI in the HA container and issue this command:

cp /config/climate.py  /usr/src/homeassistant/homeassistant/components/zha/climate.py

Instruction for open CLI in the HA docker container: https://github.com/zigpy/zha-device-handlers#testing-quirks-in-development-in-docker-based-install

For jacekk015.

    async def async_attribute_updated(self, record):
        """Handle attribute update from device."""
        if record.attr_name == "operation_preset":
            if record.value == 0:
                self._preset = PRESET_SCHEDULE
            if record.value == 1:
                self._preset = PRESET_NONE
        await super().async_attribute_updated(record)

    async def async_preset_handler(self, preset: str, enable: bool = False) -> bool:
        """Set the preset mode."""
        mfg_code = self._zha_device.manufacturer_code
        if not enable:
            return await self._thrm.write_attributes(
                {"operation_preset": 1}, manufacturer=mfg_code
            )
        if preset == PRESET_SCHEDULE:
            return await self._thrm.write_attributes(
                {"operation_preset": 0}, manufacturer=mfg_code
            )
laurius commented 2 years ago

@MattWestb thanks just got to test this now, with the new climate.py if i select schedule i get the error: Failed to call service climate /set_preset_mode . 'NoneType' object is not iterable

MattWestb commented 2 years ago

OK perhaps i have somthing "not so good" (=bad) :-(

@jacekk015 can you taking one fast look if i have messing the presets up ? I think i was doing it OK then mapping the functions and numbers but i not 110% sure.

Thanks in advance !!

jacekk015 commented 2 years ago

@laurius post some logs so I could look inside

laurius commented 2 years ago

Repaired the TRV and tried to change the preset to schedule 3 times: 12_12_2021 schedule preset home-assistant.log Pairing log 12_12_2021.txt

jacekk015 commented 2 years ago

@laurius

2021-12-12 13:24:46 DEBUG (MainThread) [zhaquirks.tuya] [0x6a00:1:0x0201] Mapping standard operation_preset (0x4002) with value <Preset.Away: 0> to custom None

You don't have away mode on your TRV ;-) - so it can't be set.

Actually, from Presets you have Schedule and Manual only. On/Off isn't served there, actually it isn't server anywhere.

RTI_MODE_ATTR = 0x0401  # [0] schedule [1] manual [2] off [3] on
laurius commented 2 years ago

@jacekk015 Thanks, see that in the log now as well. Maybe a stupid question, why is it trying to set it to Away and not schedule? Isn't Away a separate preset mode?

jacekk015 commented 2 years ago

@laurius https://github.com/home-assistant/core/blob/master/homeassistant/components/zha/climate.py

 async def async_attribute_updated(self, record):
        """Handle attribute update from device."""
        if record.attr_name == "operation_preset":
            if record.value == 0:
                self._preset = PRESET_AWAY
            if record.value == 1:
                self._preset = PRESET_SCHEDULE
            if record.value == 2:
                self._preset = PRESET_NONE
            if record.value == 3:
                self._preset = PRESET_COMFORT
            if record.value == 4:
                self._preset = PRESET_ECO
            if record.value == 5:
                self._preset = PRESET_BOOST
            if record.value == 6:
                self._preset = PRESET_COMPLEX
        await super().async_attribute_updated(record)

This is 1:1 mapped to quirk:

class Preset(t.enum8):
        """Working modes of the thermostat."""

        Away = 0x00
        Schedule = 0x01
        Manual = 0x02
        Comfort = 0x03
        Eco = 0x04
        Boost = 0x05
        Complex = 0x06
        TempManual = 0x07

Depends on what file @MattWestb prepared for you, you should only see Schedule and Manual

MattWestb commented 2 years ago

Dont forgetting if updating HA (to 2021.12) the present patch is lost and must being copied in to the new container for working.

laurius commented 2 years ago

@jacekk015 thanks, for clearing that up. I don't have Away available from the dropdown, only "None" and "schedule". So that part looks right.

@MattWestb Thanks that's good to know

laurius commented 2 years ago

I tried changing the values of the presets mode the following is working (1 / 2 instead of 0 / 1). It also shows the correct symbols on the TRV: ` async def async_preset_handler(self, preset: str, enable: bool = False) -> bool: """Set the preset mode.""" mfg_code = self._zha_device.manufacturer_code if not enable: return await self._thrm.write_attributes( {"operation_preset": 2}, manufacturer=mfg_code ) if preset == PRESET_SCHEDULE: return await self._thrm.write_attributes( {"operation_preset": 1}, manufacturer=mfg_code )

    return False`
laurius commented 2 years ago

Needed to change the update from device as well. This sets preset correctly and updates if i change on TRV as well: rtitek preset climate.zip

MattWestb commented 2 years ago

plus 1 * 2 !!!

Thanks for testing and correcting @laurius !!!

If you is setting the setpoint temperature to min that you can do is the TRV going in off mode ? And the same if setting it to max ?

I was looking on one video from the start and it looks it was doing it then the min and max temperature was wrong.

laurius commented 2 years ago

@MattWestb when turning manually on TRV by hand it goes to off below set min and above max it goes to on. When using HA or cluster 0x0202 i can't set below min or above max. Also noticed using cluster attribute RTI_MODE_ATTR = 0x0401 manually i can set it to off(2) and on(3).

laurius commented 2 years ago

Here min is 6°C and max is 27.5°C: https://user-images.githubusercontent.com/35629808/146067650-2630184f-b172-4c66-8cd0-32daec99a2d7.mp4

MattWestb commented 2 years ago

Is the TRV also sending on / off to the host system on DP / cluster 0x0401 then setting the temp manual on the device ?

Its good getting it right how its working so its being sync with ZHA and the outer way.

Also if setting off with 0x0401 from ZHA and increasing the temperature on the device is it starting from the min temp or the "old" used before sending off and is it sending on then or manual mode ? Also the same with on / max ?

laurius commented 2 years ago

cluster 0x0401 is displaying change for on(3) off(2) if set manually on TRV.

It is starting from the old value it was at before setting it to min/max, the same for min and max.

MattWestb commented 2 years ago

@jacekk015 Shall we mapping on and off mode to presets

so ZHA is following the TRV and not being confusing ? Or shall we making on new presets for alway on / valve 100% open ?

Also this mode must being set with attribute / DP 0x0401 from ZHA and is being sett locally with setting min and max setpoint temperature and is one working mode of the TRV.

Any thinkings ?

And great thanks @laurius for testing !!

jacekk015 commented 2 years ago

I've mapped myself a Maxsmart/Lidl to Lovelace Flame/Off icons. When you click Off it goes to manual and zero degrees - that's an Off for Maxsmart/Lidl. On state is Manual with 30 degrees - but I don't have any option to map it. When you click the Flame icon it comes back to Schedule.

laurius commented 2 years ago

For me personally the following makes sense: Flame button high: On Flame button low: mode and temp it was before power button high: mode and temp it was before power button low: off

Anyway if there is anything i can test let me know.