What i am trying to accomplish here is a presence detection trigger ‘welcome message’ based on presence and motion conditions being true. However I don’t want it to trigger every time I leave the room for less then 10 minutes… I don’t think my logic is correct and if anyone can help me on this i would be much appropriated.
I read this blog entry from @philhawthorne a little while ago and thought about implementing something like it - haven’t gotten aroud to it just yet, but that might be an approach for your problem as well:
I believe i solved my logic issue with an input_boolean… my BLE device tends to drop status a few times a day so i don’t want a trigger every time the state changes from ‘not_home’ to ‘home’…
here is how i did that… preliminary testing seems to be successful maybe someone has a better idea?
**configuration:**
input_boolean:
not_home:
name: Not Home
initial: off
**automation**
- id: not_home_boolean
alias: 'Not home boolean'
trigger:
platform: state
entity_id: sensor.keys
to: 'not_home'
for:
minutes: 15
action:
service: input_boolean.turn_on
entity_id: input_boolean.not_home
- id: welcome_message
alias: Welcome Message
initial_state: 'on'
trigger:
- platform: state
entity_id: sensor.keys
from: 'not_home'
to: 'Bedroom'
condition:
- condition: state
entity_id: input_boolean.not_home
state: 'on'
#- condition: template
#value_template: "{% if as_timestamp(now()) - as_timestamp(states.automation.welcome_message.last_updated) > 900%}true{% else %}false{% endif %}"
action:
service: script.turn_on
entity_id: script.room_presence
**script:**
room_presence:
sequence:
- wait_template: "{{is_state('binary_sensor.bedroom_sensor', 'on')}}"
timeout: 00:10:00
- service: input_boolean.turn_off
entity_id: input_boolean.not_home
- service: tts.amazon_polly_say
entity_id: media_player.anker
data_template:
message: >-
{{ [
"Hello Andrew. " ,
"Good evening. " ,
"Welcome home. " ,
"Hey there. " ,
"Nice to see you again. "
] |random }}
Mine is based on that article but with modifications (I use a binary_sensor and I removed all time-frame checks from it among other things… I posted a link to pastebin where you can see how I did it… I should probably toss it up on my github account…) I see your condition is still the same though
I think I’ll upload my current config to github in the morning to make it easier to peruse (there’s a pastebin link contained in the post above but it’s not the prettiest…)