Perfect Heating Automation with Sonoff TRVZB

Perfect Heating Automation with Sonoff TRVZB

Hello everyone,
To keep this post concise, I’ll focus on practical solutions without diving into excessive details. Recently, I purchased a Sonoff TRVZB. This is not my first experience with TRVs; I’ve already been using seven Moes BRT-100 TRVs in my home. Let me tell you right away: Moes TRVs are the worst TRVs ever produced. After some time, they released newer versions to address their shortcomings.

I integrated the Sonoff TRVZB into Home Assistant via Zigbee2MQTT (Z2M) without any issues. After the installation, I examined the features provided by the Z2M panel. One feature that caught my attention was the “external temperature sensor integration”, introduced in a recent firmware update. Unfortunately, this feature wasn’t available in Z2M yet. This update is currently exclusive to Sonoff Zigbee Bridge Pro devices, and firmware updates can only be performed via this hub. Sonoff has announced that it will be available for other hubs by Q4 2024.


Problem 1: Inaccurate Temperature Sensor

The first problem I encountered was the inaccurate temperature readings from the built-in sensor on the TRV. Since the offset values kept changing, manual calibration wasn’t a viable option. My initial step was to disable temperature reporting from the TRV in Z2M and create an automation that pulls temperature data from an external sensor.

  • How to disable reporting:
    I disabled all reporting fields in Z2M to ensure the TRV doesn’t send inaccurate temperature data

image

  • External sensor selection:
    For the living room, I used a Sonoff SNZB-02D temperature sensor. However, even though these sensors were connected via Z2M, their reporting frequency wasn’t sufficient. For precise climate control, the sensor needs to update temperature data frequently. The Sonoff sensors, unfortunately, updated data every 5–10 minutes, which was inadequate.
  • Solution for faster updates:
    I adjusted the Z2M reporting settings to ensure quicker updates. Here are the settings I used:

After these adjustments, the sensors started updating more frequently, which resolved the issue. Now, I needed to transmit the updated sensor data to the Sonoff TRVs in real time. Since such a feature was not yet available via MQTT, I accomplished this through a Home Assistant automation. The automation is as follows

alias: TRV Calibration - BedroomTRV_Calibration
description: Bedroom TRV'nin sıcaklık kalibrasyonunu oda sıcaklık sensörüne göre ayarlar
triggers:
  - entity_id:
      - climate.bedroom_trv
    attribute: current_temperature
    trigger: state
  - entity_id:
      - sensor.xiaomi_bedroom_temperature
    trigger: state
conditions:
  - condition: template
    value_template: >
      {{ state_attr('climate.bedroom_trv', 'current_temperature') | float !=
      states('sensor.xiaomi_bedroom_temperature') | float }}
actions:
  - variables:
      trvtemp: "{{ state_attr('climate.bedroom_trv', 'current_temperature') | float }}"
      trvcalib: >-
        {{ states('number.0x847127fffe9ec06e_local_temperature_calibration') |
        float }}
      roomtemp: "{{ states('sensor.xiaomi_bedroom_temperature') | float }}"
      calibration: "{{ (trvcalib - (trvtemp - roomtemp)) | round(2) }}"
      vpayload: |
        {
          "local_temperature_calibration": {{ calibration }}
        }
  - data:
      topic: zigbee2mqtt/0x847127fffe9ec06e/set
      payload: "{{ vpayload }}"
    action: mqtt.publish
mode: single

In this automation, you will need the MQTT-configured Sonoff thermostat, the external sensor from which you will retrieve the temperature data, and the MQTT ID of the Sonoff TRV. You can find the MQTT ID on the Home Assistant Zigbee2MQTT main page.

image


Problem 2: Integrating Better Thermostat

With accurate temperature readings, the next step was to use Better Thermostat in Home Assistant. I created thermostat cards for each TRV in my home, assigning external temperature sensors, door/window sensors, and other inputs where applicable.

  • Key settings:
    • Target Base Temperature: Configured for optimal comfort.
    • Calibration: Disabled the app’s internal calibration to avoid errors, as I had already set accurate calibration through Z2M.

However, now a new issue emerged: Hysteresis values.


Problem 3: Hysteresis Handling

Sonoff TRVs use a hysteresis of about 1°C, meaning the valve opens when the room temperature drops 1°C below the set point. This was problematic in my case due to significant temperature variations in my home. For comparison:

  • Netatmo TRVs: Hysteresis = 0.3°C
  • Aqara TRVs: Hysteresis = 0.5°C

To bypass this limitation, I created a custom automation in Home Assistant:

  1. Compared Better Thermostat’s heating mode with the actual MQTT thermostat state.
  2. If Better Thermostat entered “heating mode,” the automation forced the MQTT thermostat to do the same.

Since there’s no “force open valve” option in Home Assistant climate settings, I added a workaround by temporarily increasing the set temperature by 2°C and then reverting it.

alias: TRV - Salon TRV 3 Better - Periyodik HVAC Kontrol
description: >-
  Salon TRV 3 Better her 5 saniyede bir durum kontrolü yapar ve gerektiğinde
  işlem uygular.
triggers:
  - seconds: /59
    trigger: time_pattern
conditions: []
actions:
  - choose:
      - conditions:
          - condition: state
            entity_id: climate.salon_trv3_better
            attribute: hvac_action
            state: heating
          - condition: state
            entity_id: climate.salon_trv_3
            attribute: hvac_action
            state: heating
        sequence: []
      - conditions:
          - condition: state
            entity_id: climate.salon_trv3_better
            attribute: hvac_action
            state: heating
          - condition: state
            entity_id: climate.salon_trv_3
            attribute: hvac_action
            state: idle
        sequence:
          - variables:
              original_temperature: "{{ state_attr('climate.salon_trv_3', 'temperature') }}"
          - target:
              entity_id: climate.salon_trv_3
            data:
              temperature: "{{ original_temperature | float + 2 }}"
            action: climate.set_temperature
          - delay:
              seconds: 2
          - target:
              entity_id: climate.salon_trv_3
            data:
              temperature: "{{ original_temperature }}"
            action: climate.set_temperature
mode: single

This code will run in the background every 1 minute and compare the states of the Better Thermostat with the original MQTT thermostat. In the example, climate.salon_trv3_better is the entity ID created with Better Thermostat, while climate.salon_trv_3 refers to the original MQTT thermostat


Daily Automation

The final step was creating a daily automation to adjust temperatures based on my schedule:

  • 8 AM – 6 PM: Lower temperatures for efficiency.
  • 6 PM – 11:30 PM: Higher temperatures for comfort.
  • 11:30 PM onwards: Reduced all TRVs to 5°C as the central heating system shuts off.
alias: TRV Oto Mod - Zaman ve Duruma Göre
description: TRV'leri belirli saat aralıklarında ve koşullara göre ayarlar.
triggers:
  - trigger: time_pattern
    minutes: /10
conditions:
  - condition: state
    entity_id: input_boolean.live_tiles_trv_auto_aqara
    state: "on"
  - condition: state
    entity_id: person.berkan
    state: home
  - condition: state
    entity_id: alarm_control_panel.ha_alarm
    state: disarmed
actions:
  - choose:
      - conditions:
          - condition: time
            after: "08:00:00"
            before: "18:00:00"
        sequence:
          - target:
              entity_id: climate.bedroom_trv_better
            data:
              temperature: 20
            action: climate.set_temperature
          - target:
              entity_id: climate.ofis_trv_better
            data:
              temperature: 23
            action: climate.set_temperature
          - target:
              entity_id: climate.giysi_trv_better
            data:
              temperature: 22
            action: climate.set_temperature
          - target:
              entity_id:
                - climate.salon_trv_1_better
                - climate.salon_trv2_better
                - climate.salon_trv3_better
                - climate.salon_trv_4_better
            data:
              temperature: 22
            action: climate.set_temperature
      - conditions:
          - condition: time
            after: "18:00:00"
            before: "23:30:00"
        sequence:
          - target:
              entity_id: climate.bedroom_trv_better
            data:
              temperature: 22
            action: climate.set_temperature
          - target:
              entity_id: climate.ofis_trv_better
            data:
              temperature: 23
            action: climate.set_temperature
          - target:
              entity_id: climate.giysi_trv_better
            data:
              temperature: 23
            action: climate.set_temperature
          - target:
              entity_id:
                - climate.salon_trv_1_better
                - climate.salon_trv2_better
                - climate.salon_trv3_better
                - climate.salon_trv_4_better
            data:
              temperature: 23
            action: climate.set_temperature
      - conditions:
          - condition: time
            after: "23:30:00"
            before: "07:59:59"
        sequence:
          - target:
              entity_id:
                - climate.bedroom_trv_better
                - climate.ofis_trv_better
                - climate.giysi_trv_better
                - climate.salon_trv_1_better
                - climate.salon_trv2_better
                - climate.salon_trv3_better
                - climate.salon_trv_4_better
            data:
              temperature: 5
            action: climate.set_temperature
mode: single


Conclusion

By combining Zigbee2MQTT, Better Thermostat, and custom Home Assistant automations, I achieved a perfectly optimized heating system. It reacts to real-time changes, maintains accurate temperatures, and overcomes the limitations of Sonoff TRVs. Additionally, Sonoff TRVs allow you to configure the percentage at which the valves remain open or closed via MQTT. This feature enables you to create automations throughout the day based on temperature conditions. For example, even if the TRVs reach their set points after 6 PM, you can keep the valves 25% open to slow down the cooling of the room, ensuring a more comfortable environment.

I hope this helps anyone facing similar issues. Feel free to ask questions or share your thoughts!

3 Likes

Hi I’m also trying to use external sensors for my Sonoff TRVZB. I think it might be easier to just use external temperature sensors to adjust the TRV’s offset value. This way there’s no need to adjust the polling rate as it just need to verify the offset value every 5-10 min

Hello. Actually, I initially tried a similar solution. However, I noticed some issues when I didn’t disable the internal sensor on the Sonoff TRV itself. For example, the temperature readings were highly unstable. Let’s say the room was 23°C, the sensor would show 23.4°C at one moment, then drop to 22.8°C, and later record something like 23.3°C. In short, the readings weren’t consistent. How can you manually assign a stable value to an external sensor when the readings fluctuate like this? For instance, the offset value can go from -2.3 to +2 in a short period of time. In my opinion, at least for me, the most reliable method is to disable this reporting and use automation instead.

2 Likes

I have a problem with sonoff trv (zigbeetoMQTT) using better thermostat, if the temperature drops with 0.1 degrees the trv starts heating until the set temperature is reached meaning for 0.1 degrees, how can i change the tolerance to 0.5, the tolerance setting in better thermostat seems not to work. thanks

The reason for this is that the values created by the Better Thermostat do not affect the actual main valve, which is the MQTT valve. In other words, you set the tolerance value in Better, but it does not impact the actual valve in MQTT. Honestly, I don’t know if there is a way to address this. Maybe it can be achieved with a complex automation as well.

Thanks for the answer, that is really not so god news for me. But anyone has the same problem? O jut i see it as a problem? Also i am not able to disable all the reporting

How to disable these too?

Thanks for this overview, very helpful. I took a different approach using automations. I set up two for each TRV, one for high temp and one for low temp using an external zigbee thermometer as the trigger. I set the hvac mode to on/off (high/low). This worked fine. I then tried to manually set (within zigbee2mqtt) the degree open/close % for some finer control (i.e. i did not want the valves to total close, only 50% for example). but I could not seem to get this to work. Has anyone else manage to get the degree close % for the valves to work? Any suggestions for how to test them, I tried to manually set the values but nothing seems to change with the valves. I would expect (for example) if the valve is closed, and degree is set to 100. If I then change the degree closed to say 50% the valve would then open to half way, but all my tests nothing seems to happen when I play with this attribute. I have the latest firmware so this should not be an issues. I was thinking/hoping to adjusting that value (degree open/close) directly but I think I could live with on/off with the % on/off being fixed if I could get it to work.

Thanks,

Pete.

Ok. so I am going to reply to my own post as I have had a bit of a break through. Here are my observations.

If the local temperature (i.e. TRV temp) is 20c, occupied heating setpoint is set to 30c with heating mode set to “heat”. I can then adjust the valve open degree and hear the valve changing. If the set point is below the local temperature changing the open degree has no effect.

If the local temperature (i.e. TRV temp) is 20c, occupied heating setpoint is set to 15c with heating mode set to “off”. I can then adjust the valve close degree and hear the valve changing. If the set point is above the local temperature changing the close degree has no effect.

It appears there is some interrelationship between the temperature set point, local temperature and the ability to change/adjust the open/close degree. I’m guessing this make sense is you are using the local/temperature and set point.

So, it appears if I want to have this fine control in my automations I will need to change the set point temperature on close/open to be above or below temperature as appropriate then i can adjust the close/open degree.

As mentioned above. Being able to exchange the local provided temperature for an external temperature (i.e. provided by a zigbee thermometer) would be great additional functionality.

Yet another reply to my own post. It appears the “temperature” entity is not the set point temperature but the calibration temperature. Very odd to have this exposed and an entity but not the set point temperature. I will look into updating the zigbee2mqtt description file to fix this as it is available via mqtt just not as an entity with HA. in the mean time a work around is to send an mqtt message to change the set point in my automations.
.

Hello. First of all, you can set the valves to open and close at specific percentages. This can be done easily with an automation since the valves appear as entities. However, instead of dealing with complex automations, I have a simpler suggestion for you.

For instance, in the example automation I shared, I divided the day into two parts. From 8:00 AM to 6:00 PM, I set different degrees, and from 6:00 PM to 11:30 PM, I set another degree. You could create an automation that, for example, adjusts the valve’s closing position to a specific percentage (like 50%) after 6:00 PM. Then, at 11:30 PM, the automation could turn itself off.

This way, in the evenings, when the setpoint is reached, the valves won’t close completely, preventing the room from cooling down quickly again.

The temperature part, as you mentioned, is the section where calibration is performed. Setpoints, on the other hand, are directly controlled via thermostat cards or service calls. These are entirely different things.

As I also mentioned in my text, unfortunately, the temperature value for Sonoff TRVs is extremely unstable. It does not remain at a constant value, which causes incorrect readings when manual calibration is performed.

You can change the set temperature values via MQTT messages, and you can also create actions. I preferred the action part.

Thanks for the feedback. Yep, I went with the mqtt approach for low and high temp. I leave the mode to heat. When my room thermostat goes over a certain value I reduce the setpoint temp low (10c) and when room thermostat drops below a certain temperature increase the setpoint (30c). When the automation runs I see the setpoint value change and the state change idle/heat. I’ll play around with the valve degree values for further fine tuning over the next few days.

mqtt action…

Topic:
zigbee2mqtt/TRV Bathroom/set
payload:
{“occupied_heating_setpoint”: 10}

It’s odd that the calibration temperature is exposed as an entity but the setpoint temperature is not, not sure if that is an oversight or if there is a technical reason for this situation.

1 Like

Getting

z2m: Request 'zigbee2mqtt/bridge/request/device/configure_reporting' failed with error: 'Bind 0x0ceff6fffe6799d4/1 msTemperatureMeasurement from '0x00124b001ccdfe83/1' failed (AREQ - ZDO - bindRsp after 10000ms)'

when I try to modify any reporting intervals for my SNZB-02Ds.

Update. My method for using an external thermometer with TRVZB seems to be working well so far.

Recap:
set mode to heat
Create automation triggered by max temperature required in room
action mqtt:
Topic:
zigbee2mqtt/TRV Bathroom/set
payload:
{“occupied_heating_setpoint”: 10}

Similar for the low temp. But set heating temp to something like 30c

I have also adjusted the open/close degree for finer control.

I see on the official Sonoff website for these devices it says

 You can select a SONOFF Zigbee temp. sensor as the external sensor

Anyone know if this capability will be added to HA/zigbee2mqtt?

There may be certain reasons why the reporting feature of your device cannot be disabled. Below are potential causes and solutions based on my experience:

  1. USB Dongle Issue:
    The problem might be related to the USB dongle you are using. I managed to disable this reporting feature successfully with a Sonoff Dongle Plus.
  2. Firmware Updates:
    Ensure that all your devices are running the latest firmware. Outdated firmware can cause unexpected issues.
  3. Device-Specific Issues:
    There might be a problem specific to the device itself, affecting its behavior.
  4. Coordinator Limitations:
    Check if the Zigbee coordinator you are using is nearing its capacity limit. Overloading the coordinator can lead to performance issues.

Maybe in a future update but not for now.