Hi all,
I have an actionable notification working which will fire when a light has been left on for 30 minutes, and the action takes me to a dashboard where I can turn off the light. However it’s currently got a few issues:
- It tells me all the lights that are currently on, not those that have been on for the set time
- I’d like to be able to turn the offending light off using the notification, without having to go into the app
I have a feeling this will need templates and whilst I’ve built a few to support my automations, I’ve not done any time-based ones so not sure where to begin!
My current automation (simplified to not have all my lights in as triggers) is:
alias: Lights Left On - Notification
description: ""
trigger:
- platform: device
type: turned_on
device_id: 4e5ba4fe7a391c7f8f18de7ac8a98cf4
entity_id: light.dining_room_lights
domain: light
for:
hours: 0
minutes: 30
seconds: 0
- platform: device
type: turned_on
device_id: d1afa681e9d78c626e0c81311fe967de
entity_id: light.downstairs_toilet_lights
domain: light
for:
hours: 0
minutes: 30
seconds: 0
condition: []
action:
- service: notify.notify
data:
message: |-
{{ expand('light.lights')
| selectattr('state', 'eq', 'on')
| map(attribute='name')
| list
| join (', ')
}}
title: Lights On For 30 Mins+
data:
ttl: 0
priority: high
actions:
- action: URI
title: Open Lights Dashboard
uri: /lovelace-mushroom/lightson
tag: lights-on
- wait_for_trigger:
- platform: state
entity_id:
- sensor.pixel_6_pro_app_importance
to: foreground
- service: notify.notify
data:
message: clear_notification
data:
ttl: 0
priority: high
tag: lights-on
mode: single