Does anyone know or have any good example of this kind of scenario. I am using a BLE for presence detection and it works great however, the range of my BLE device is fairly large around 30 feet or so. So as I am walking to the room it triggers the automation before I actually reach the room. I would like to incorporate my room motion sensor as either a secondary condition or combined trigger event but I’m not sure how to do that. Any thoughts on this? Ive been scratching my head on this for the past few days.
entity_id: binary_sensor.bedroom_sensor
from: 'off'
to: 'on'
- id: welcome_message
alias: Welcome Message
initial_state: 'on'
trigger:
- platform: state
entity_id: sensor.keys
from: 'not_home'
to: 'Bedroom'
for:
seconds: 5
condition:
- condition: template
value_template: "{% if as_timestamp(now()) - as_timestamp(states.automation.welcome_message.last_updated) > 900%}true{% else %}false{% endif %}"
action:
service: tts.amazon_polly_say
entity_id: media_player.boss
data_template:
message: >-
{{ [
"Hello Andrew. " ,
"Good evening. " ,
"Welcome home. " ,
"Hey there. " ,
"Nice to see you again. "
] |random }}
just add and to your condition. for example
{% elif is_state('input_boolean.juanhome', 'on') and is_state('switch.fan_to_medium', 'off') and states('sensor.office_temperature') | float > 25 and states('sensor.office_temperature') | float < 27.1 %}
1 Like
Have a look at wait_template.
firstof9
(firstof9)
February 8, 2018, 7:06pm
4
Based off your automation something like this:
- id: welcome_message
alias: Welcome Message
initial_state: 'on'
trigger:
- platform: state
entity_id: sensor.keys
from: 'not_home'
to: 'Bedroom'
for:
seconds: 5
condition:
condition: and
conditions:
- condition: state
entity_id: binary_sensor.bedroom_sensor
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: tts.amazon_polly_say
entity_id: media_player.boss
data_template:
message: >-
{{ [
"Hello Andrew. " ,
"Good evening. " ,
"Welcome home. " ,
"Hey there. " ,
"Nice to see you again. "
] |random }}
1 Like
Can anyone confirm that this is how i am supposed to use the wait_template???
- id: welcome_message
alias: Welcome Message
initial_state: 'on'
trigger:
- platform: state
entity_id: sensor.keys
from: 'not_home'
to: 'Bedroom'
condition:
- 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:00:12
- service: tts.amazon_polly_say
entity_id: media_player.boss
data_template:
message: >-
{{ [
"Hello Andrew. " ,
"Good evening. " ,
"Welcome home. " ,
"Hey there. " ,
"Nice to see you again. "
] |random }}
Looks about right, although I’d have the contents of the script as the action of the automation for neatness.
Im not quite sure what you mean? would be be so kind as to show me? i did not know we could do a script in the action of the automation… @anon43302295
The action of the automation is a script…
id: welcome_message
alias: Welcome Message
initial_state: 'on'
trigger:
- platform: state
entity_id: sensor.keys
from: 'not_home'
to: 'Bedroom'
condition:
- condition: template
value_template: "{% if as_timestamp(now()) - as_timestamp(states.automation.welcome_message.last_updated) > 900%}true{% else %}false{% endif %}"
action:
- wait_template: "{{is_state('binary_sensor.bedroom_sensor', 'on')}}"
timeout: 00:00:12
- service: tts.amazon_polly_say
entity_id: media_player.boss
data_template:
message: >-
{{ [
"Hello Andrew. " ,
"Good evening. " ,
"Welcome home. " ,
"Hey there. " ,
"Nice to see you again. "
] |random }}
1 Like