Hey all!
I’m struggling with my understanding of this and looking for a little help, can’t seem to get what i need through searching and chatGPT and the like.
I’m trying to create a template sensor that is a delay in one direction, but not in the other.
Use Case:
I’m using arpscan on my wife’s phone’s mac to determine when her phone is home. It works relatively well but goes in and out quite a bit. So i want to make an adjacent sensor that has a 6-10 minute delay moving into the “away” state. This would reduce “away” false positives. The “home” side never has a false positive, because when it is in the “home” state it means the mac is on the network. So I would like the “home” to move immediately but the “away” to have a timed “for:” condition.
I tried this yaml below and i’m getting duplicate key errors, so it’s relatively close but not correct:
template:
- trigger:
trigger: state
entity_id: device_tracker.wifePhone
to: not_home
for: "00:06:00"
trigger: state
entity_id: device_tracker.wifePhone
to: home
sensor:
- name: ea52_state_delay
state: >
{% if is_state('device_tracker.wifePhone', 'not_home') %}
not_home
{% else %}
{{ states('device_tracker.wifePhone') }}
{% endif %}
Thanks for any help or thoughts!