I have an automation that is triggered by a device tracker group. The light.lr_light and group.lights below work, but the thermostat isn’t being triggered. How do I make it so when the group.tracker is not home, it will set the hvac mode to auto and when group.tracker is home it will set the hvac mode to cool? Thanks
- id: presence
alias: Presence Detection
trigger:
- platform: state
entity_id: group.tracker
condition:
- condition: template
value_template: >
{{ trigger.to_state.state in ['home','not_home'] and trigger.to_state.state != trigger.from_state.state }}
action:
- service: light.turn_{{ 'on' if is_state('group.tracker', 'home') else 'off' }}
entity_id: light.lr_light
- service: homeassistant.turn_{{ 'off' if is_state('group.tracker', 'not_home') }}
entity_id: group.lights
- service: climate.set_hvac_mode
data_template:
entity_id: climate.hallway
hvac_mode: >
{% if is_state("group.tracker", "not_home") %}
auto
{% else %}
cool
{% endif %}