frelev
October 21, 2016, 3:32pm
1
I want to trigger a notify when my alarm is in a status for 2 minutes and is not None or unknown.
I expected it to trigger 9.03 when it went from Outside Wire (9.01)
Automation.
alias: Send push if mower stops
trigger:
platform: template
value_template: "{% if not is_state('sensor.mower_alarm', 'None') and not is_state('sensor.mower_alarm', 'unknown') and relative_time(states.sensor.mower_alarm.last_updated) == '2 minutes' %}true{% endif %}"
action:
service: notify.html5
data_template:
message: "Mower stopped with alarm: {{ states('sensor.mower_alarm') }}."
data:
data:
tag: 'notification-about-sensor'
Anyone got an idea?
automation:
trigger:
platform: state
entity_id: device_tracker.paulus, device_tracker.anne_therese
# Optional
from: ‘not_home’
to: ‘home’
# Alias for 'to'
state: 'home'
# If given, will trigger when state has been the to state for X time.
for:
hours: 1
minutes: 10
seconds: 5
Add for to your trigger.
1 Like
frelev
October 22, 2016, 3:20pm
3
Hi
I tried this but it won´t work:
alias: Send push if mower stops
trigger:
platform: template
value_template: "{% if not is_state('sensor.mower_alarm', 'None') and not is_state('sensor.mower_alarm', 'unknown') %}true{% endif %}"
for:
hours: 0
minutes: 2
seconds: 0
action:
service: notify.html5
data_template:
message: "`Mower alert: {{ states('sensor.mower_alarm') }}."
data:
data:
tag: 'notification-about-sensor'
Maybe the for argument is not working with template trigger?
PtP
(Mike)
October 23, 2016, 5:58am
4
Try making a template sensor that counts the time since it’s last update. There should be some info in this thread. Relative_time template extension
Once the template sensor works (test it in dev tools) you can create an automation with a template trigger. Something like if state of template sensor is greater than x run action.
Example:
- platform: time_date
display_options:
- 'time'
- 'date'
- platform: template
sensors:
derick_location_for:
value_template: "{% if states.device_tracker.derick_nexus_6p %}{{(as_timestamp(now())-as_timestamp(states.device_tracker.derick_nexus_6p.last_updated)) // 60 }} Minutes{% else %}??{% endif %}"
entity_id:
- sensor.time
#Automation
- alias: trigger after last update reaches a time
trigger:
platform: template
value_template: “{% if is_state(‘derick_location_for’, ‘2 minutes’) %}true{% endif %}”
action:
service: persistent_notification.create
data:
notification_id: “1234”
message: “Sensor is Down”
title: “Test”