Hi,
I’ve been struggling with an actionable notification to turn off a specific light.
I have three bathroom lights using Shelly switches, and have the following script:
alias: Bathroom Lights Left On
description: >-
Notify and offer to turn off any of the bathroom lights left on longer than
20min
trigger:
- platform: state
entity_id: >-
switch.shelly_shsw_pm_d8bfc019b60d, switch.shelly_shsw_pm_8caab574c685,
switch.shelly_shsw_pm_98cdac1e2737
from: 'off'
to: 'on'
for:
hours: 0
minutes: 0
seconds: 2
condition: []
action:
- data_template:
message: '{{ trigger.to_state.name }} has been left on'
title: Bathroom light left on!
data:
actions:
- action: turn_off_bathroom_light
title: Turn off {{ trigger.to_state.name }}
service: notify.mobile_app_nick
- wait_for_trigger:
- platform: event
event_type: ios.notification_action_fired
event_data:
actionName: turn_off_bathroom_light
continue_on_timeout: false
- service: switch.turn_off
data: {}
target:
- entity_id: '{{ trigger.to_state.name }}'
mode: single
I get the correct friendly_name in my notification, but I’m then wondering how to turn off the light that triggered the automation?
Currently I’m getting a ‘Message malformed: expected a dictionary for dictionary value @ data[‘action’][2][‘target’]’ error but not sure how to address it.
Can anyone advise?