Anyone build an automation where an actionable notifications is sent to a mobile device warning when a light has been left on for x hours and it’s still daylight?
Something like this?
trigger:
- platform: state
entity_id: light.your_light
from: 'off'
to: 'on'
for: '02:00:00'
condition:
- condition: time
after: '06:00'
before: '16:00'
action:
- alias: Set up variables for the actions
variables:
action_accept: >-
{{ 'ACCEPT_' ~ context.id }}
action_decline: >-
{{ 'DECLINE_' ~ context.id }}
- alias: Ask to turn off the lights
service: notify.mobile_app_your_name
data:
message: >-
Living Room Lights is ON for more than 2 hour. Do you want to turn it off?
data:
actions:
- action: >-
{{ action_accept }}
title: 'Yes'
- action: >-
{{ action_decline }}
title: 'No'
- alias: Wait for a response to turn off the lights
wait_for_trigger:
- platform: event
event_type: mobile_app_notification_action
event_data:
action: >-
{{ action_accept }}
- platform: event
event_type: mobile_app_notification_action
event_data:
action: >-
{{ action_decline }}
timeout: '60'
continue_on_timeout: false
- alias: Perform the action
choose:
- conditions:
- condition: template
value_template: >-
{{ wait.trigger.event.data.action == action_accept }}
sequence:
- service: light.turn_off
target:
entity_id: light.your_light
default: []
mode: restart
Note: Just a suggestion, if you can purchase a motion sensor, it can act as “occupancy” sensor which can be used as a trigger to turn off your lamp if it is ON and no motion is detected.
Excellent, many thanks