Hi all, i’d like my home next hub say something when I came into home.
I have a door sensor.
I’d like it to speak when i open the door and for example my wifi is connected form few seconds and the track of my phone is changed from not_home to home from few minutes.
automation:
- alias: "Welcome home"
trigger:
# Front door opens
- platform: state
entity_id: binary_sensor.front_door
to: 'on'
condition:
# You are home
- condition: state
entity_id: person.zola
state: 'home'
# But only became home in the last two minutes
- condition: template
value_template: >-
{{ ((now() - states.person.zola.last_changed).seconds < 120 ) }}
action:
- service: tts.cloud_say
data:
entity_id: media_player.whatever
message: "Welcome home"
You’ll need to update all the entities in there to reflect your own. This also won’t cause a Welcome home if you aren’t home when the front door opens. Handling that is another step.
Thanks sorry but it will trigger also if i’m at home from for example one hour and I open the door…
Is there the possibility to check the change from not_home to home in the last few minutes?
Thanks
Error evaluating condition in ‘Messaggio arrivo casa Ale’: In ‘condition’ (item 2 of 2): In ‘template’ condition: UndefinedError: ‘None’ has no attribute ‘last_changed’
- id: '1620554892604'
alias: Messaggio arrivo casa Ale
description: ''
trigger:
- type: opened
platform: device
device_id: 231e46a0ea1741c1b091ace46aa59a79
entity_id: binary_sensor.door_window_sensor_158d00033a9289
domain: binary_sensor
condition:
- condition: state
entity_id: person.ale
state: home
- condition: template
value_template: '{{ ((now() - states.person.zola.last_changed).seconds < 180 )
}}'
action:
- service: tts.google_say
data:
entity_id: media_player.nesthub
message: Ciao ben arrivato Alessandro
- service: notify.apertura_porta
data:
message: Ale è entrato in casa
title: Cambio stato porta di casa
mode: single