Hi,
I have created automation that closes all lights and media if nobody is home but for some odd reason automation wont trigger every time when someone leaves house. Automation itself works but it just wont trigger always.
Here are my automation from automation.yaml
- id: '1633591556985'
alias: Close all lights and media if nobody home
description: ''
trigger:
- platform: state
entity_id: device_tracker.alex_puhelin
to: not_home
- platform: state
entity_id: device_tracker.cassandras_iphone
to: not_home
condition:
- condition: state
entity_id: device_tracker.alex_puhelin
state: not_home
- condition: state
entity_id: device_tracker.cassandras_iphone
state: not_home
action:
- service: homeassistant.turn_off
target:
entity_id: light.house_lights
device_id: 1bf652e9ccba21fc9dc2a45de3a1250c
mode: single
and here are few proof that automation did not trigger when I left home and thus did not close light and media
Examine the automation’s trace to understand why it didn’t work the way you expected.
I suspect it triggered but its condition prevented execution of the action. However, the trace will reveal the actual cause.
You may wish to consider creating a group containing both device_trackers. The group’s state will be not_home only when both device_trackers are not_home. That will allow you to simplify the automation:
- id: '1633591556985'
alias: Close all lights and media if nobody home
description: ''
trigger:
- platform: state
entity_id: group.all_trackers
from: 'home'
to: 'not_home'
condition: []
action:
- service: homeassistant.turn_off
target:
entity_id: light.house_lights
mode: single
I would say it is more about that i did not even trigger automation and thus not continue to conditions and actions. I will make group for my device tracker and see it it helps. Just updated HA so lost all trace but should get it tomorrow.
You can confirm that by checking if a trace was produced at the time when it should have triggered. Alternately, you can check the “Last triggered” time shown next to the automation’s name in Configuration > Automations.
You can see from 2nd picture that automation has last triggered 1:41 pm and I left house 7:17 pm. Screenshots are taken 7:27 pm so seems that I did not even trigger.