I’m pretty sure I’m making this more complicated than it needs to be - any suggestions / advice would be welcome.
I’ve just started playing with this TRV: TuYa TS0601_thermostat control via MQTT | Zigbee2MQTT and I’m just using it in force: open and force:close modes, controlled by a simple thermostat:
In switch.yaml, I define the TRV as a switch:
- platform: template
switches:
martin_office_trv:
turn_on:
service: mqtt.publish
data:
topic: zigbee2mqtt/TRV Martin Office/set
payload: "{\"force\":\"open\"}"
turn_off:
service: mqtt.publish
data:
topic: zigbee2mqtt/TRV Martin Office/set
payload: "{\"force\":\"close\"}"
And in my climate.yaml, I define a thermostat for the TRV with an external / room temperature sensor:
- platform: generic_thermostat
name: Martin office TRV
heater: switch.martin_office_trv
target_sensor: sensor.martin_office_temperature_temperature
target_temp: 20.5
initial_hvac_mode: "heat"
hot_tolerance: 0
So far, so good. This basically works fine. My lovelace card looks like this:
type: vertical-stack
cards:
- type: custom:simple-thermostat
entity: climate.martin_office_trv
header:
name: Martin office
icon:
heating: mdi:power
'off': mdi:power-off
idle: mdi:sleep
control:
hvac:
heat:
icon: mdi:power
'off':
icon: mdi:power-off
hide:
state: true
temperature: true
sensors:
- attribute: current_temperature
icon: mdi:thermometer
layout:
step: row
mode:
headings: false
names: false
decimals: 1
step_size: 0.5
- type: entities
entities:
- entity: switch.martin_office_trv
name: TRV switch
icon: mdi:pipe-valve
- entity: sensor.trv_martin_office_position
- entity: binary_sensor.martin_office_trv_error
I added the last binary error sensor into my sensor.yaml because I had a situation where the open / close MQTT command didn’t work and the switch status and valve position got out of sync:
- platform: template
sensors:
martin_office_trv_error:
friendly_name: Martin Office TRV Error
delay_on:
seconds: 60
value_template: >
{% if is_state('sensor.trv_martin_office_position', '100') and is_state('switch.martin_office_trv', 'on') %} Off
{% elif is_state('sensor.trv_martin_office_position', '0') and is_state('switch.martin_office_trv', 'off') %} Off
{% else %} On
{% endif %}
This seems like a lot of moving parts to me for just one TRV. Is there a more simple method to control a TRV and get feedback about its position?
I played with MQTT Switch - Home Assistant for a while which seems to have state and availability built-in - but I couldn’t figure out the MQTT topics to make it work at all.