mirror of
https://github.com/CeeWeasel/fresh-home.git
synced 2026-08-09 18:40:14 -04:00
initial push
This commit is contained in:
@@ -0,0 +1,64 @@
|
||||
alias: Notification Action Script
|
||||
sequence:
|
||||
# inside a automation actions or script sequence
|
||||
- alias: "Set up variables for the actions"
|
||||
variables:
|
||||
# Including an id in the action allows us to identify this script run
|
||||
# and not accidentally trigger for other notification actions
|
||||
action_open: "{{ 'OPEN_' ~ context.id }}"
|
||||
action_close: "{{ 'CLOSE_' ~ context.id }}"
|
||||
- alias: "Ask to close or open the garage"
|
||||
choose:
|
||||
- conditions:
|
||||
- condition: state
|
||||
entity_id: cover.garage_door
|
||||
state: 'closed'
|
||||
sequence:
|
||||
service: notify.mobile_app_pixel_7
|
||||
data:
|
||||
message: "The garage is closed. Do you want to adjust this?"
|
||||
data:
|
||||
actions:
|
||||
- action: "{{ action_open }}"
|
||||
title: Open
|
||||
- action: "{{ action_close }}"
|
||||
title: Close
|
||||
- conditions:
|
||||
- condition: state
|
||||
entity_id: cover.garage_door
|
||||
state: 'open'
|
||||
sequence:
|
||||
service: notify.mobile_app_pixel_7
|
||||
data:
|
||||
message: "The garage is open. Do you want to adjust this?"
|
||||
data:
|
||||
actions:
|
||||
- action: "{{ action_open }}"
|
||||
title: Open
|
||||
- action: "{{ action_close }}"
|
||||
title: Close
|
||||
|
||||
- alias: "Wait for a response"
|
||||
wait_for_trigger:
|
||||
- platform: event
|
||||
event_type: mobile_app_notification_action
|
||||
event_data:
|
||||
# waiting for the specific action avoids accidentally continuing
|
||||
# for another script/automation's notification action
|
||||
action: "{{ action_open }}"
|
||||
- platform: event
|
||||
event_type: mobile_app_notification_action
|
||||
event_data:
|
||||
action: "{{ action_close }}"
|
||||
- alias: "Perform the action"
|
||||
choose:
|
||||
- conditions: "{{ wait.trigger.event.data.action == action_open }}"
|
||||
sequence:
|
||||
- service: cover.open_cover
|
||||
target:
|
||||
entity_id: cover.garage_door
|
||||
- conditions: "{{ wait.trigger.event.data.action == action_close }}"
|
||||
sequence:
|
||||
- service: cover.close_cover
|
||||
target:
|
||||
entity_id: cover.garage_door
|
||||
Reference in New Issue
Block a user