🔥 Advanced Heating Control

you can define template sensors under sensor, binary_sensor or template section. In your case you need one of the last two options.

binary_sensor:
- platform: template
  sensors:
    winter_mode:
      value_template: "{{ state_attr('weather.forecast_home','temperature') < 18  }}"
template:
  - binary_sensor:
      - name: "Wintemode"
        state: "{{ state_attr('weather.forecast_home','temperature') < 18  }}"

Then the sensor is called binary_sensor.winter_mode and not sensor.winter_mode.

2 Likes

You are awesome, thank you! If you don’t already have one, get yourself a Cookie!

Working perfectly now <3

1 Like

Thank you for walking me through the debug process.
I set the two TRVs to turn on at 10:42 am this morning and both traces show that the set_temperature service was called but it was only executed on one TRV. After going through and comparing both devices activity in the ZHA logs I can see (1) no evidence of DeliveryError and (2) what seems to be absent in the ‘failing’ TRV logs is the lines:

[homeassistant.components.zha.core.channels.base] [0x9A1A:1:0x0201]: Attribute report 'SiterwellThermostat'[occupied_heating_setpoint] = 2000
[homeassistant.components.zha.entity] climate.main_bedroom_radiator_thermostat: Attribute 'occupied_heating_setpoint' = 2000 update

ZHA log for TRV that did not execute set_temperature correctly:

—
2023-05-03 10:42:04.018 DEBUG (MainThread) [homeassistant.components.zha.core.channels.base] [0xA399:1:0x0201]: wrote {'system_mode': <SystemMode.Heat: 4>} attrs, Status: [[WriteAttributesStatusRecord(status=<Status.SUCCESS: 0>)]]
2023-05-03 10:42:04.018 DEBUG (MainThread) [homeassistant.components.zha.core.channels.base] [0xA399:1:0x0201]: set system to SystemMode.Heat
2023-05-03 10:42:04.079 DEBUG (MainThread) [homeassistant.components.zha.core.channels.base] [0xA399:1:0x0201]: Attribute report 'SiterwellThermostat'[system_mode] = SystemMode.Heat
2023-05-03 10:42:04.080 DEBUG (MainThread) [homeassistant.components.zha.core.channels.base] [0xA399:1:0x0201]: Attribute report 'SiterwellThermostat'[programing_oper_mode] = ProgrammingOperationMode.Simple
2023-05-03 10:42:04.081 DEBUG (MainThread) [homeassistant.components.zha.core.channels.base] [0xA399:1:0x0201]: Attribute report 'SiterwellThermostat'[running_mode] = RunningMode.Heat
2023-05-03 10:42:04.083 DEBUG (MainThread) [homeassistant.components.zha.core.channels.base] [0xA399:1:0x0201]: Attribute report 'SiterwellThermostat'[running_state] = RunningState.Heat_State_On
2023-05-03 10:42:04.089 DEBUG (MainThread) [homeassistant.components.zha.entity] climate.ensuite_radiator_thermostat: Attribute 'system_mode' = SystemMode.Heat update
2023-05-03 10:42:04.090 DEBUG (MainThread) [homeassistant.components.zha.entity] climate.ensuite_radiator_thermostat: Attribute 'programing_oper_mode' = ProgrammingOperationMode.Simple update
2023-05-03 10:42:04.091 DEBUG (MainThread) [homeassistant.components.zha.entity] climate.ensuite_radiator_thermostat: Attribute 'running_mode' = RunningMode.Heat update
2023-05-03 10:42:04.092 DEBUG (MainThread) [homeassistant.components.zha.entity] climate.ensuite_radiator_thermostat: Attribute 'running_state' = RunningState.Heat_State_On update
—
2023-05-03 10:42:09.498 DEBUG (MainThread) [homeassistant.components.zha.entity] climate.ensuite_radiator_thermostat: Attribute 'system_mode' = SystemMode.Heat update
2023-05-03 10:42:09.500 DEBUG (MainThread) [homeassistant.components.zha.entity] climate.ensuite_radiator_thermostat: Attribute 'programing_oper_mode' = ProgrammingOperationMode.Simple update
2023-05-03 10:42:09.501 DEBUG (MainThread) [homeassistant.components.zha.entity] climate.ensuite_radiator_thermostat: Attribute 'running_mode' = RunningMode.Heat update
2023-05-03 10:42:09.502 DEBUG (MainThread) [homeassistant.components.zha.entity] climate.ensuite_radiator_thermostat: Attribute 'running_state' = RunningState.Heat_State_On update
2023-05-03 10:42:09.596 DEBUG (MainThread) [homeassistant.components.zha.core.channels.base] [0xA399:1:0x0201]: wrote {'occupied_heating_setpoint': 2000} attrs, Status: [[WriteAttributesStatusRecord(status=<Status.SUCCESS: 0>)]]
—
2023-05-03 10:42:20.306 DEBUG (MainThread) [homeassistant.components.zha.core.channels.base] [0xA399:1:0x0201]: Attribute report 'SiterwellThermostat'[system_mode] = SystemMode.Heat
2023-05-03 10:42:20.307 DEBUG (MainThread) [homeassistant.components.zha.core.channels.base] [0xA399:1:0x0201]: Attribute report 'SiterwellThermostat'[programing_oper_mode] = ProgrammingOperationMode.Simple
2023-05-03 10:42:20.307 DEBUG (MainThread) [homeassistant.components.zha.core.channels.base] [0xA399:1:0x0201]: Attribute report 'SiterwellThermostat'[running_mode] = RunningMode.Heat
2023-05-03 10:42:20.308 DEBUG (MainThread) [homeassistant.components.zha.core.channels.base] [0xA399:1:0x0201]: Attribute report 'SiterwellThermostat'[running_state] = RunningState.Heat_State_On
2023-05-03 10:42:20.317 DEBUG (MainThread) [homeassistant.components.zha.entity] climate.ensuite_radiator_thermostat: Attribute 'system_mode' = SystemMode.Heat update
2023-05-03 10:42:20.318 DEBUG (MainThread) [homeassistant.components.zha.entity] climate.ensuite_radiator_thermostat: Attribute 'programing_oper_mode' = ProgrammingOperationMode.Simple update
2023-05-03 10:42:20.319 DEBUG (MainThread) [homeassistant.components.zha.entity] climate.ensuite_radiator_thermostat: Attribute 'running_mode' = RunningMode.Heat update
2023-05-03 10:42:20.319 DEBUG (MainThread) [homeassistant.components.zha.entity] climate.ensuite_radiator_thermostat: Attribute 'running_state' = RunningState.Heat_State_On update
2023-05-03 10:42:20.533 DEBUG (MainThread) [homeassistant.components.zha.core.channels.base] [0xA399:1:0x0201]: Attribute report 'SiterwellThermostat'[system_mode] = SystemMode.Heat
2023-05-03 10:42:20.534 DEBUG (MainThread) [homeassistant.components.zha.core.channels.base] [0xA399:1:0x0201]: Attribute report 'SiterwellThermostat'[programing_oper_mode] = ProgrammingOperationMode.Simple
2023-05-03 10:42:20.536 DEBUG (MainThread) [homeassistant.components.zha.core.channels.base] [0xA399:1:0x0201]: Attribute report 'SiterwellThermostat'[running_mode] = RunningMode.Heat
2023-05-03 10:42:20.537 DEBUG (MainThread) [homeassistant.components.zha.core.channels.base] [0xA399:1:0x0201]: Attribute report 'SiterwellThermostat'[running_state] = RunningState.Heat_State_On
2023-05-03 10:42:20.544 DEBUG (MainThread) [homeassistant.components.zha.entity] climate.ensuite_radiator_thermostat: Attribute 'system_mode' = SystemMode.Heat update
2023-05-03 10:42:20.545 DEBUG (MainThread) [homeassistant.components.zha.entity] climate.ensuite_radiator_thermostat: Attribute 'programing_oper_mode' = ProgrammingOperationMode.Simple update
2023-05-03 10:42:20.546 DEBUG (MainThread) [homeassistant.components.zha.entity] climate.ensuite_radiator_thermostat: Attribute 'running_mode' = RunningMode.Heat update
2023-05-03 10:42:20.546 DEBUG (MainThread) [homeassistant.components.zha.entity] climate.ensuite_radiator_thermostat: Attribute 'running_state' = RunningState.Heat_State_On update
2023-05-03 10:42:20.652 DEBUG (MainThread) [homeassistant.components.zha.core.channels.base] [0xA399:1:0x0201]: Attribute report 'SiterwellThermostat'[occupied_heating_setpoint] = 1600
2023-05-03 10:42:20.663 DEBUG (MainThread) [homeassistant.components.zha.entity] climate.ensuite_radiator_thermostat: Attribute 'occupied_heating_setpoint' = 1600 update
—

ZHA log for TRV that did execute set_temperature correctly:

—
2023-05-03 10:42:01.316 DEBUG (MainThread) [homeassistant.components.zha.core.channels.base] [0x9A1A:1:0x0201]: wrote {'system_mode': <SystemMode.Heat: 4>} attrs, Status: [[WriteAttributesStatusRecord(status=<Status.SUCCESS: 0>)]]
2023-05-03 10:42:01.317 DEBUG (MainThread) [homeassistant.components.zha.core.channels.base] [0x9A1A:1:0x0201]: set system to SystemMode.Heat
2023-05-03 10:42:01.369 DEBUG (MainThread) [homeassistant.components.zha.core.channels.base] [0x9A1A:1:0x0201]: Attribute report 'SiterwellThermostat'[system_mode] = SystemMode.Heat
2023-05-03 10:42:01.370 DEBUG (MainThread) [homeassistant.components.zha.core.channels.base] [0x9A1A:1:0x0201]: Attribute report 'SiterwellThermostat'[programing_oper_mode] = ProgrammingOperationMode.Simple
2023-05-03 10:42:01.371 DEBUG (MainThread) [homeassistant.components.zha.core.channels.base] [0x9A1A:1:0x0201]: Attribute report 'SiterwellThermostat'[running_mode] = RunningMode.Heat
2023-05-03 10:42:01.372 DEBUG (MainThread) [homeassistant.components.zha.core.channels.base] [0x9A1A:1:0x0201]: Attribute report 'SiterwellThermostat'[running_state] = RunningState.Heat_State_On
2023-05-03 10:42:01.384 DEBUG (MainThread) [homeassistant.components.zha.entity] climate.main_bedroom_radiator_thermostat: Attribute 'system_mode' = SystemMode.Heat update
2023-05-03 10:42:01.385 DEBUG (MainThread) [homeassistant.components.zha.entity] climate.main_bedroom_radiator_thermostat: Attribute 'programing_oper_mode' = ProgrammingOperationMode.Simple update
2023-05-03 10:42:01.386 DEBUG (MainThread) [homeassistant.components.zha.entity] climate.main_bedroom_radiator_thermostat: Attribute 'running_mode' = RunningMode.Heat update
2023-05-03 10:42:01.387 DEBUG (MainThread) [homeassistant.components.zha.entity] climate.main_bedroom_radiator_thermostat: Attribute 'running_state' = RunningState.Heat_State_On update
2023-05-03 10:42:01.508 DEBUG (MainThread) [homeassistant.components.zha.core.channels.base] [0x9A1A:1:0x0201]: Attribute report 'SiterwellThermostat'[system_mode] = SystemMode.Heat
2023-05-03 10:42:01.509 DEBUG (MainThread) [homeassistant.components.zha.core.channels.base] [0x9A1A:1:0x0201]: Attribute report 'SiterwellThermostat'[programing_oper_mode] = ProgrammingOperationMode.Simple
2023-05-03 10:42:01.510 DEBUG (MainThread) [homeassistant.components.zha.core.channels.base] [0x9A1A:1:0x0201]: Attribute report 'SiterwellThermostat'[running_mode] = RunningMode.Heat
2023-05-03 10:42:01.511 DEBUG (MainThread) [homeassistant.components.zha.core.channels.base] [0x9A1A:1:0x0201]: Attribute report 'SiterwellThermostat'[running_state] = RunningState.Heat_State_On
2023-05-03 10:42:01.519 DEBUG (MainThread) [homeassistant.components.zha.entity] climate.main_bedroom_radiator_thermostat: Attribute 'system_mode' = SystemMode.Heat update
2023-05-03 10:42:01.520 DEBUG (MainThread) [homeassistant.components.zha.entity] climate.main_bedroom_radiator_thermostat: Attribute 'programing_oper_mode' = ProgrammingOperationMode.Simple update
2023-05-03 10:42:01.521 DEBUG (MainThread) [homeassistant.components.zha.entity] climate.main_bedroom_radiator_thermostat: Attribute 'running_mode' = RunningMode.Heat update
2023-05-03 10:42:01.522 DEBUG (MainThread) [homeassistant.components.zha.entity] climate.main_bedroom_radiator_thermostat: Attribute 'running_state' = RunningState.Heat_State_On update
2023-05-03 10:42:01.671 DEBUG (MainThread) [homeassistant.components.zha.core.channels.base] [0x9A1A:1:0x0201]: Attribute report 'SiterwellThermostat'[occupied_heating_setpoint] = 1600
2023-05-03 10:42:01.678 DEBUG (MainThread) [homeassistant.components.zha.entity] climate.main_bedroom_radiator_thermostat: Attribute 'occupied_heating_setpoint' = 1600 update
—
2023-05-03 10:42:07.227 DEBUG (MainThread) [homeassistant.components.zha.core.channels.base] [0x9A1A:1:0x0201]: wrote {'occupied_heating_setpoint': 2000} attrs, Status: [[WriteAttributesStatusRecord(status=<Status.SUCCESS: 0>)]]
2023-05-03 10:42:07.267 DEBUG (MainThread) [homeassistant.components.zha.core.channels.base] [0x9A1A:1:0x0201]: Attribute report 'SiterwellThermostat'[occupied_heating_setpoint] = 2000
2023-05-03 10:42:07.273 DEBUG (MainThread) [homeassistant.components.zha.entity] climate.main_bedroom_radiator_thermostat: Attribute 'occupied_heating_setpoint' = 2000 update
2023-05-03 10:42:07.445 DEBUG (MainThread) [homeassistant.components.zha.core.channels.base] [0x9A1A:1:0x0201]: Attribute report 'SiterwellThermostat'[occupied_heating_setpoint] = 2000
2023-05-03 10:42:07.452 DEBUG (MainThread) [homeassistant.components.zha.entity] climate.main_bedroom_radiator_thermostat: Attribute 'occupied_heating_setpoint' = 2000 update
2023-05-03 10:42:07.558 DEBUG (MainThread) [homeassistant.components.zha.core.channels.base] [0x9A1A:1:0x0201]: Attribute report 'SiterwellThermostat'[occupied_heating_setpoint] = 2000
2023-05-03 10:42:07.566 DEBUG (MainThread) [homeassistant.components.zha.entity] climate.main_bedroom_radiator_thermostat: Attribute 'occupied_heating_setpoint' = 2000 update
2023-05-03 10:42:07.700 DEBUG (MainThread) [homeassistant.components.zha.core.channels.base] [0x9A1A:1:0x0201]: Attribute report 'SiterwellThermostat'[occupied_heating_setpoint] = 2000
2023-05-03 10:42:07.708 DEBUG (MainThread) [homeassistant.components.zha.entity] climate.main_bedroom_radiator_thermostat: Attribute 'occupied_heating_setpoint' = 2000 update
2023-05-03 10:42:07.910 DEBUG (MainThread) [homeassistant.components.zha.core.channels.base] [0x9A1A:1:0x0201]: Attribute report 'SiterwellThermostat'[occupied_heating_setpoint] = 2000
2023-05-03 10:42:07.915 DEBUG (MainThread) [homeassistant.components.zha.entity] climate.main_bedroom_radiator_thermostat: Attribute 'occupied_heating_setpoint' = 2000 update
—
2023-05-03 10:42:09.635 DEBUG (MainThread) [homeassistant.components.zha.core.device] [0x9A1A](TS0601): Device seen - marking the device available and resetting counter
2023-05-03 10:42:09.635 DEBUG (MainThread) [homeassistant.components.zha.core.device] [0x9A1A](TS0601): Update device availability - device available: True - new availability: True - changed: False
—

I think there is a custom quirk for your valve. Mine works with zha out of the box, too. But it didn’ provide me a calibration entity for example.

Can you check out that custom quirk?

  1. Unpair the trv
  2. download the file and copy it to your config/custom_zha_quirks directory
  3. add this to your home assistant config:
zha:
  custom_quirks_path: /config/custom_zha_quirks/
  1. Restart Home Assistant
  2. Repair your TRV and check entities and services

I have not installed a custom quirk for this device myself but when pairing with ZHA I think this quirk that you’ve linked to was used by ZHA? This is what I see:


Looking at the .py file that you’ve linked to, the replacement endpoints also match the clusters that I can see for this device:

thank you for this awesome blueprint!
I have one question left… if i manual change the temperature of a TRV is there a way to automatic set the scheduled temperature back?

Just trigger the automation with a service call or from the automation menu.

service: automation.trigger
data:
  skip_condition: false
target:
  entity_id: automation.your_heating_automation

to simple… thx

One other question a few post ago there was a question about the aqara trv and the External Temperatur Sensor. In the meantime the trv is now more compatible with ZHA but don´t have number value for the calibration instead an external sensor:

So i guess the External Temperatur Sensor is still not working?

Wish I have an aqara e1 in my hands. Seems external senseor is a binary_sensor which just shows if an external sensor is given. From that what I read the Aqara E1 can only be calibrated using zigbee2mqtt. You have to puplish the external sensor in the mqtt topic and then you are able to set it using an automation. Technically it’s easy because the trv calculates the difference by itself. But for ZHA there is no possibility atm.
If there is some code or a blueprint for that I would be very pleased. Maybe you have other information.

Ok. I’ve read a bit about that problem. Other TRVs have this issue, too. Mostly Moes/TUYA based. Since so many specialities are out there I will provide a little workaround section in that blueprint.

1 Like

So, here you are. At the end of the blueprint you will find an number slider so increase/decrease the delay between the two service calls. Waiting for your feedback. (Don’t forget to test out the guest mode :wink: )

The blueprint has been running for three days now and the Guest Mode feature is working as expected.

With the input slider, I increased the delay on my ‘problem’ TRV to 7 seconds (picked it at random) and it has worked as expected 100% of the time. I left the other TRV on 2 seconds and it mostly worked as expected except for one occasion where it did not change the set temperature based on the schedule.

I’m now going to expand the use of the blueprint to all 8 TRVs (4 Siterwell _TZE200_zivfvd7h and 4 Aqara lumi.airrtc.agl001) and will update here later in the week. Thanks!

(One new use case that I’ve been thinking of is when we’re out of the house and about to journey back home and want the heating to come on ahead of time so the house is warm on arrival. I think that the Guest Mode can be used for this purpose too?)

1 Like

Yes, for that purpose there is the proximity integration which measures the distance between home and persons / device trackers. I test it atm. It has an attribute which shows the travel direction. For me it would be interesting if someone on the way home inside the tolerance window. Think thats the smartest way.

1 Like

If the Holiday mode is On and the Guest mode is activated will the holiday schedule be used by the blueprint?

Yes, you only switch between schedulers using holiday mode.

All eight TRVs appear to be working correctly this week. I’ve so far only had to adjust the delay on the first ‘problem’ TRV and it has been working as expected.

Separately, I’ve noticed that when a TRV schedule is ‘on’ and if I change the target temperature on the TRV then sometimes after a few minutes the TRV will reset the target temperature back to the number defined in the blueprint config. Is this expected behaviour?

1 Like

Yes, every trigger cause in setting mode and temperature of the trvs. The only way to change the target temperature is the comfort temperature input.
Since there is a delay for setting the temperature in the blueprint you can use an automation which instantly maps the manual set temperature of a trv to the comfort temperature input. Be sure to check in a condition if the new trv temperature value in’t equal to the number_input of the comfort temperature.

Okay thanks. I was thinking of a more temporary use case where you want to change the target temp until the schedule changes. For example, the kitchen TRV morning schedule is from 6:00 to 9:00 but this morning I’m feeling like I want to override the comfort temp of 20C to 21.5C and that override stays in place until 9:00 when the min temperature kicks in as scheduled. (The next morning the TRV comes on at 6:00 at the ‘usual’ target temp of 20C.)

Thats not possible with current blueprint or better with that binary scheduler. For that purpose we need schedulers with multiple states. There is a custom component for that but I want to go with the standard tools.
So if you want to achieve this, you need a 2nd. automation that sets the comfort temperatur input depending on time.

I think this may require that the min temperature be updated to accept an input_number helper to build a simple automation for such a purpose? I was thinking of something like:

  1. input_number.set_min_temp with a value of e.g. 15
  2. input_number.set_comfort_temp with a value of e.g. 20
  3. input_number.boost_temp_amount
  4. input_boolean.boost_temp

Then a simple automation where a change in the boolean state could trigger a change in the value of the boost_temp_amount between 0 and some number e.g. 1. (The automation would also trigger a change in the boolean state of the Party mode to ensure the heating comes on.) After a fixed time period the automation would then revert the boolean states back to ‘off’.

The actual min_temp and comfort_temp used by the blueprint would be the sum of the boost_temp_amount and the set_min_temp and set_comfort_temp (that can be created by combining sensors in the UI.)