Hi, so i configured a nmap device_tracker in configuration.yaml to track if im home or not.
Now i wanna try to turn on some lights when i get back home. I added a time condition to ignore the rare false positive or network instability. Thats were im stuck i cant make my condition to work, if anyone have tried something similar im interested. Here’s my code atm.
alias: When i get home
description: ''
trigger:
- platform: state
entity_id: person.me
to: home
condition:
- condition: state
entity_id: person.me
state: not_home
for: '00:30:00'
action:
- type: turn_on
device_id: eace4c11d5b2d8bcd6fd2b98a52371dc
entity_id: light.yeelight_color_0x0000000004566673
domain: light
mode: single
Then you have a condition that says only continue if I haven’t been home for 30 minutes (i.e., the state of person.me has been not_home for 30 minutes).
So if the scenario is to turn on a light when you get home, then this won’t work (you can’t be home and not_home at the same time - by the time the condition is checked, the state of person.me has already changed to home).
My understanding is that you have the condition to prevent false positives. Assuming those false positives only happen for a second or two, a possible approach is to add a for condition (I made it 30 seconds - adjust to what works for you) to the trigger as well as a from condition to make sure the automation doesn’t trigger if the state goes to unknown and then back to home for a second or so):
alias: When i get home
description: ''
trigger:
- platform: state
entity_id: person.me
to: home
from: not_home
for: '00:00:30'
action:
- type: turn_on
device_id: eace4c11d5b2d8bcd6fd2b98a52371dc
entity_id: light.yeelight_color_0x0000000004566673
domain: light
mode: single
It shouldn’t trigger unless person.me stays in the not-home state for at least 30 seconds. It’s kind of like a delay. In this case, the state needs to stay in not_home for 30 s in order to trigger.
Another option is to use a router to check if you are home. I have that configured, and then as long as one of them says I’m home, then my state is home. That tends to smooth out some of the false positives.