ZHA Smart TRV

I Have just installed a smart TRV and paired it with ZHA.
ZHA has created a climate entity. Where is this entity located, as I do not want the climate entity to use the built in temperature sensor from the TRV but use the room sensor.

I also noticed that the built-in temperature sensor on my TRV is absolutely useless. I did the following:

  • create an input number helper to set the target temperature.
  • create an automation that sets the TRV set temperature to minimum (5C - which will effectively close the TRV) when the room sensor temp is higher than that input number helper and will set the TRV temp to max (30C) when the room sensor temp is below this input number helper.

You can use the below code as an example:

input_number:
  room_set_temperature:
    name: Room target temperature
    max: 30
    min: 5
    step: 0.5
    unit_of_measurement: "°C"

automation:
  - id: climate_TRV_turn_off
    alias: Climate TRV turn off
    description: Turn off the heating when target temp has been reached
    mode: single
    trigger:
      - platform: template
        value_template: >-
          {{ states.sensor.ble_temperature_room_sensor.state > states.input_number.room_set_temperature.state }}
    condition: []
    action:
      - service: climate.set_temperature
        target:
          entity_id: climate.room_thermostat
        data:
          temperature: 5

  - id: climate_TRV_turn_on
    alias: Climate TRV turn on
    description: Turn on the heating when actual drops below target temp
    mode: single
    trigger:
      - platform: template
        value_template: >-
          {{ states.sensor.ble_temperature_room_sensor.state < states.input_number.room_set_temperature.state }}
    condition: []
    action:
      - service: climate.set_temperature
        target:
          entity_id: climate.room_thermostat
        data:
          temperature: 30

In the above code, you need to replace sensor.ble_temperature_room_sensor with whatever sensor is providing your room temperature. climate.room_thermostat should refer to your TRV climate entity.

Once you got that working, you can start adding automations to shedule your TRV. If you got the input number and above 2 automations, your schedule (and really any control - i.e. on a card) shoud always change the input number helper. Below is an example to turn on the TRV on specific days at specific times. Change as you need and create a similar automation to turn it off.

  - id: climate_room_start_schedule_weekdays
    alias: Climate start of schedule weekdays
    description: Set target to 19C at defined times
    mode: single
    trigger:
      - platform: time
        at: '06:20:00'
      - platform: time
        at: '16:00:00'
    condition:
      - condition: time
        weekday:
          - mon
          - tue
          - thu
    action:
      - service: input_number.set_value
        target:
          entity_id: input_number.room_set_temperature
        data:
          value: 19

While this will create very simple and basic on/off behavior, which is far from intelligent, I find it works really well for me. Obviously, this assumes your main boiler is running.

You can also add this input number to lovelace to change the temperature on the fly. You can also add the climate entity to lovelace which will indicate when the TRV is open or closed. If you need inspiration, see my room card below.

image

image

Be aware that it takes around 30s for the climate entity to change from idle to heating when you change the temperature. This is simply because it takes the TRV that long to open the valve. So if you play around with it, be patient.

p.s. On the kids rooms I added door sensors and a bunch of extra automations which turn off the TRVs if the kids leave their door open. If they need their room to be warm, they’ll have to remember to close their doors :smiley:

Good luck.

2 Likes

Thanks for your detailed solution. I was hoping to simply change the templerature sensor entity used on the Climate entity.

Ha, yes that would make for a much simpler solution :sweat_smile: I don’t know if that is possible though. Maybe someone else can chime in.

If it is possible, I clearly overengineered it :thinking:

thanks for your efforts

Hi tjafke, thanks for your input.
I just have a question: I see that you have created an icon to show when there is heating or not but you don’t change the TRV state with your automation.
If I’m not mistaken, you just keep the state on auto and change the temperature.
In my experience, this consumes a lot of batteries.

I indeed do not change the TRV state. I only change the set temperature. Maybe you have different TRVs, I have the Moeshouse Tuya Zigbee3.0 TRVs. In the climate entity they create, I actually can only change the temperature. I was under the impression that the heating/idle is a status the TRVs themselves report, not something I can actually change. At least I wouldn’t know how to actively change it (there is also no service call for that) and as I said, the status changes whenever I set the target temperature above or below the actual temperature. This is how the climate entity looks like for me. There is no “auto” state for my TRVs that I am aware of.

image

Notice that that is different from the HVAC action, which is something you can change, but for TRVs there is only 1 HVAC action which is heat (at least for my TRVs).

Anyway I have not noticed anything suspicious with battery drain. Granted they are only running for around 6 weeks now, but they all still report 100% battery - though I know that these cheap Zigbee devices don’t always reliably report battery state.

Do your TRVs behave differently?

I have a Moes TRV model TS0601 and I can change the operating mode (Heat-Auto-Off).
But it doesn’t work properly because when the operating mode is in status, the valve remains open (if in heating mode before) and the heating continues.
The best solution is to work with the temperature and keep the operation in status but unfortunately this drains the battery as the TRV remains active.

image

Hmm, that is interesting. I have the exact same TRVs. But in my case, I do not have that auto or off operation mode. From the screenshot above, I assume you use Zigbee2MQTT? Maybe it behaves differently in ZHA? When I set the target temp. to 5C, the valve definitely closes.

p.s. I did notice I have a separate On_off switch in ZHA, but that doesn’t seem to do anything. It doesn’t matter if that switch is set to on or off, the TRVs all change open/close state based on the set temperature.

Anyway, I’ll keep an eye out for the battery status. How fast does your drain?

Just 1 addition: As you can see I used the extremes in my control, meaning 5C (fully closed) and 30C (fully open). I never tried with something in between. Maybe that’s the difference?

That’s right, I use the zigbee2mqtt solution.
This explains the difference.
Since for me, the solution of setting the TRV Off does not work for closing the valve, I will use the solution of lowering the temperature or raising it.
I have no other choice, I have to leave the TRV in auto mode despite the battery consumption.
I replace the batteries about every 2 months, I will try to use rechargeable NiZn batteries from now on.
Thanks for your solution, I will implement it.

I know this thread is 10/11 months old, but can I ask, has anyone had an issue with trying to set the target temp from HA for these, and have the TRV see, to revert after a few seconds to the prior setting ?

I experimented the same with 1 of my 8 valves. It’s the one that has lower linkquality signal, it is around 30. So I believe this is related to my coverage and probably we just tried to set the temperature but as the valve is not connected, the new temperature value cannot be saved. How is your signal? Probably it should be the reason.
Hope it helps!