I was wondering if I could do something similar for my Honeywell thermostats. When I go to bed (set an input_boolean) is there a way to select all thermostats higher than X and set them to Y?
automation:
- alias: Turn down thermostats at night
trigger:
platform: state
entity_id: input_boolean.NAME
to: 'on'
condition:
condition: template
value_template: >
{{ states.climate|selectattr('attributes.temperature','gt',X)|list|count > 0 }}
action:
service: climate.set_temperature
data_template:
entity_id: >
{% for state in states.climate if state.attributes.temperature > X %}
{% if not loop.first %},{% endif %}{{ state.entity_id }}
{% endfor %}
temperature: Y
EDIT: Oops, forgot to handle the case where no thermostats are above X. Changed solution above accordingly.
Do you see the INFO line in home-assistant.log that shows the actual service call? And are there any errors about the service call in that log, that is, more than just the line that says it didn’t work?
Not sure what to make of this. But maybe it doesn’t like the extra newlines. If so, maybe this will work better:
automation:
- alias: Turn down thermostats at night
trigger:
platform: state
entity_id: input_boolean.NAME
to: 'on'
condition:
condition: template
value_template: >
{{ states.climate|selectattr('attributes.temperature','gt',X)|list|count > 0 }}
action:
service: climate.set_temperature
data_template:
entity_id: >
{% for state in states.climate if state.attributes.temperature > X -%}
{% if not loop.first %},{% endif %}{{ state.entity_id }}
{%- endfor %}
temperature: Y
Just read there was an issue with Honeywell servers. Ran the code again today and it seems to be working. Thanks for the feedback guys, much appreciated!