I have a set of thermostats (Better Thermostat, but it doesn’t matter) and i want to create an automation so that when all of them are in “off” a specific MQTT topic is published, and if any one of them is “on”, then a different MQTT automation is published. Bonus point, i want to collect this info (all off, at least one on) in an helper so that i can use it with other automations.
This is what i use now:
alias: Send MQTT topic
description: send topic
triggers:
- trigger: state
entity_id:
- sensor.termo_box_hvac_action
- trigger: state
entity_id:
- sensor.termo_cucina_hvac_action
- trigger: state
entity_id:
- sensor.termo_disimpegno_hvac_action
- trigger: state
entity_id:
- sensor.termo_bagno_sopra_hvac_action
- trigger: state
entity_id:
- sensor.termo_bagno_sotto_hvac_action
- trigger: state
entity_id:
- sensor.scaldasalviette_bagno_sopra_hvac_action
- trigger: state
entity_id:
- schedule.sempre
- trigger: state
entity_id:
- input_boolean.quick_heat
- trigger: state
entity_id:
- input_boolean.usa_pellet
- trigger: state
entity_id:
- sensor.termo_camera_eli_hvac_action
- trigger: state
entity_id:
- sensor.termo_camera_ale_hvac_action
- trigger: state
entity_id:
- sensor.termo_bagno_eli_hvac_action
actions:
- action: mqtt.publish
data:
payload: >-
{{ is_state('sensor.termo_box_hvac_action', 'heating') or
is_state('sensor.termo_cucina_hvac_action', 'heating') or
is_state('sensor.termo_disimpegno_hvac_action', 'heating') or
is_state('sensor.termo_bagno_sopra_hvac_action', 'heating') or
is_state('sensor.termo_bagno_sotto_hvac_action', 'heating') or
is_state('sensor.termo_camera_eli_hvac_action', 'heating') or
is_state('sensor.termo_camera_ale_hvac_action', 'heating') or
is_state('termo_bagno_eli_hvac_action', 'heating') or
is_state('sensor.scaldasalviette_bagno_sopra_hvac_action', 'heating') }}
topic: riscaldamento/feedback
retain: true
- action: mqtt.publish
metadata: {}
data:
evaluate_payload: false
qos: 0
retain: true
topic: riscaldamento/usegas
payload: |-
{{ is_state('input_boolean.usa_pellet', 'off') or
is_state('input_boolean.quick_heat', 'on') }}
- action: mqtt.publish
metadata: {}
data:
evaluate_payload: false
qos: 0
retain: true
topic: riscaldamento/usepellet
payload: |-
{{ is_state('schedule.sempre', 'on') and
is_state('input_boolean.usa_pellet', 'on') }}
mode: single
But there are a few issues:
- Adding more thermostats require a script modification
- if i want to know the combined status outside the script, i cannot
What is a better approach? I tried creating an helper to group the thermostats, but with no luck.