Skip to content

Instantly share code, notes, and snippets.

@Blackshome
Last active April 16, 2024 18:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save Blackshome/40bfd92fb1fe6a9a9189325704a3c81b to your computer and use it in GitHub Desktop.
Save Blackshome/40bfd92fb1fe6a9a9189325704a3c81b to your computer and use it in GitHub Desktop.
calendar-notifications-and-actions.yaml
blueprint:
name: Calendar Notifications & Actions
description: >
# 📅 Calendar Notifications & Actions
**Version: 1.3**
Let us know what you think of this blueprint and for community support including updates: [Click Here](https://community.home-assistant.io/t/calendar-notifications-actions/612326?u=blacky)
**The Automation Process:**
- Can be triggered on a key word in a calendar event or triggered on all calendar events.
- You have the option to trigger at the start and end of a calendar event with time offsets.
- When triggered, you have the option to send notifications to one or multiple devices. The notification has options to include 3 action buttons + a cancel button. You also have the option to send a confirmation message when an action button is pressed. This can be useful when sending notifications to multiple devices as it will let the other devices know when an action has been pressed.
- Notifications can work with Apple IOS and Android devices. One for all, and all for one.
- When triggered, you have the option to set 3 different action groups. Each action group can have as many actions you like.
Note - The calendar event must be added at least 15 minutes before the trigger or the automation will not run.
Required = *
The Settings & Best Practice Guidelines: [Click Here](https://community.home-assistant.io/t/calendar-notifications-actions/612326/3?u=blacky)
Need help? See our FAQ: [Click Here](https://community.home-assistant.io/t/calendar-notifications-actions/612326/2?u=blacky)
**If you like my blueprints, and would like to show your support or just say thank you?** [Click Here](https://www.paypal.com/donate/?hosted_button_id=WAZS3QSDTPGA8) 🙂
domain: automation
input:
# Trigger
calendar:
name: Calendar *
description: Calendar to be used.
default: {}
selector:
entity:
filter:
domain: calendar
include_calendar_trigger:
name: Use The Calendar Trigger - Key Word (Optional)
description: Choose if you would like to use a "Key Word" to trigger the automation.
**Note** - If you choose not to use a "Key Word", then all calendar events will be triggered.
default: enable_key_word
selector:
select:
options:
- label: Don't use "Key Word" in calendar
value: "disable_key_word"
- label: Use "Key Word" in calendar
value: "enable_key_word"
calendar_trigger:
name: Calendar Trigger - Key Word In Calendar Summary & / or Description
description: Input a key word that is in the calendar event summary and or the calendar event description. This links the calendar event to this automation as the trigger.
A key word can contain letters, numbers & symbols similar to a password.
Be mindful of the key word you use as it will trigger on every event with the key word in the selected calendar summary and or description.
I prefer to use the "@" or "#" symbols followed by the key word in a calendar event, example "@bins" or "#bins" to prevent false triggers.
For more information on how to use Trigger Key Words [Click Here](https://community.home-assistant.io/t/calendar-notifications-actions/612326/4?u=blacky)
default: []
selector:
text:
start_calendar_offset:
name: Calendar Start - Offset
description: The offset from the start of the calendar event when the trigger will be triggered.
If you would like to send a trigger before the start of a calendar event, then you will need to put a minus "-" then the time value.
default:
days: 0
hours: 0
minutes: 0
seconds: 0
selector:
duration:
enable_day: true
end_calendar_offset:
name: Calendar End - Offset
description: The offset from the end of the calendar event when the trigger will be triggered.
If you would like to send a trigger before the end of a calendar event, then you will need to put a minus "-" then the time value.
default:
days: 0
hours: 0
minutes: 0
seconds: 0
selector:
duration:
enable_day: true
global_conditions:
name: Global Conditions
description: Enter any global conditions you would like to apply to the automation.
default: []
selector:
condition:
include_start_notify:
name: Use The Start Notify Options (Optional)
description: Select enable if you would like to be notified at the start of the calendar event.
default: disable_start_notify_options
selector:
select:
options:
- label: Enable Start Notify Options
value: "enable_start_notify_options"
- label: Disable Start Notify Options
value: "disable_start_notify_options"
start_notify_device:
name: Start Notify - Devices To Notify
description: Select the devices to be notified at the start of a calendar event.
default: []
selector:
device:
filter:
- integration: mobile_app
multiple: true
start_title:
name: Start Notify - Title
description: The notification title at the start of the calendar event.
default: "{{ trigger.calendar_event.summary }}"
selector:
text:
start_message:
name: Start Notify - Message
description: The notification message at the start of the calendar event.
default: "{{ trigger.calendar_event.description }}"
selector:
text:
include_start_action_buttons:
name: Start Notify - Action Buttons Options (Optional)
description: Enable the action buttons you would like to use. Action buttons will be shown in the notification, allowing you to perform the action when you click on the button.
**NOTE** - You do not need to select any notification action buttons to run an action.
default: []
selector:
select:
options:
- label: Enable action button 1
value: "enable_start_action_button_1"
- label: Enable action button 2
value: "enable_start_action_button_2"
- label: Enable action button 3
value: "enable_start_action_button_3"
multiple: true
start_action_button_1:
name: Start Notify - Action Button 1
description: Enter the button name to be displayed in the notification.
This button runs all the actions entered into "Start - Action 1" input below.
default: []
selector:
text:
start_action_button_2:
name: Start Notify - Action Button 2
description: Enter the button name to be displayed in the notification.
This button runs all the actions entered into "Start - Action 2" input below.
default: []
selector:
text:
start_action_button_3:
name: Start Notify - Action Button 3
description: Enter the button name to be displayed in the notification.
This button runs all the actions entered into "Start - Action 3" input below.
default: []
selector:
text:
start_action_button_stop:
name: Start Notify - CANCEL Action Button
description: Enter the CANCEL button name to be displayed in the notification.
This button will cancel all actions and stop the automation.
It will be automatically included in the notification if you have enabled an action button above.
default: []
selector:
text:
start_time_delay:
name: Start Notify - Time Delay
description: The time delay after which the automation will continue its execution if an action button has not been pressed.
default:
hours: 0
minutes: 30
seconds: 0
selector:
duration:
include_start_action_button_confirmation:
name: Start Notify - Action Button Confirmation Option (Optional)
description: Select enable if you would like to notify all the devices when an action button has been pressed.
This is handy when notifying multiple devices. It lets the other devices know that an action has been pressed.
default: disable_start_action_button_confirmation
selector:
select:
options:
- label: Enable Action Button Confirmation
value: "enable_start_action_button_confirmation"
- label: Disable Action Button Confirmation
value: "disable_start_action_button_confirmation"
start_action_button_confirmation_title:
name: Start Notify - Action Button Confirmation Title
description: The notification title when an action button is pressed or the time delay has passed.
default: []
selector:
text:
start_action_button_confirmation_message:
name: Start Notify - Action Button Confirmation Message
description: The notification message when an action button is pressed.
default: []
selector:
text:
start_time_delay_confirmation_message:
name: Start Notify - Time Delay Confirmation Message
description: The notification message when the time delay has passed.
default: []
selector:
text:
include_start_auto_actions:
name: Use The Start Auto Action Options (Optional)
description: Enabling an auto option will allow the "Start Actions" below to run when the calendar event is triggered.
When using action buttons in a notification, you do not need to enable these options for the start actions to work.
If you miss the notification and didn't press an action button, then enabling a start auto action option will make sure the action still runs.
default: []
selector:
select:
options:
- label: Enable start auto action 1
value: "enable_start_action_1"
- label: Enable start auto action 2
value: "enable_start_action_2"
- label: Enable start auto action 3
value: "enable_start_action_3"
multiple: true
start_action_1:
name: Start Action - Action 1
description: Enter the actions you would like to run at the start of a calendar event.
This action is also linked to "Start Notify - Action Button 1" in the start notifications.
default: []
selector:
action:
start_action_2:
name: Start Action - Action 2
description: Enter the actions you would like to run at the start of a calendar event.
This action is also linked to "Start Notify - Action Button 2" in the start notifications.
default: []
selector:
action:
start_action_3:
name: Start Action - Action 3
description: Enter the actions you would like to run at the start of a calendar event.
This action is also linked to "Start Notify - Action Button 3" in the start notifications.
default: []
selector:
action:
include_end_notify:
name: Use The End Notify Options (Optional)
description: Select enable if you would like to be notified at the end of the calendar event.
default: disable_end_notify_options
selector:
select:
options:
- label: Enable End Notify Options
value: "enable_end_notify_options"
- label: Disable End Notify Options
value: "disable_end_notify_options"
end_notify_device:
name: End Notify - Devices To Notify
description: Select the devices to be notified at the end of a calendar event.
default: []
selector:
device:
filter:
- integration: mobile_app
multiple: true
end_title:
name: End Notify - Title
description: The notification title at the end of the calendar event.
default: "{{ trigger.calendar_event.summary }}"
selector:
text:
end_message:
name: End Notify - Message
description: The notification message at the end of the calendar event.
default: "{{ trigger.calendar_event.description }}"
selector:
text:
include_end_action_buttons:
name: End Notify - Action Buttons Options (Optional)
description: Enable the action buttons you would like to use. Action buttons will be shown in the notification, allowing you to perform the action when you click on the button.
**NOTE** - You do not need to select any notification action buttons to run an action.
default: []
selector:
select:
options:
- label: Enable action button 1
value: "enable_end_action_button_1"
- label: Enable action button 2
value: "enable_end_action_button_2"
- label: Enable action button 3
value: "enable_end_action_button_3"
multiple: true
end_action_button_1:
name: End Notify - Action Button 1
description: Enter the button name to be displayed in the notification.
This button runs all the actions entered into "End - Action 1" input below.
default: []
selector:
text:
end_action_button_2:
name: End Notify - Action Button 2
description: Enter the button name to be displayed in the notification.
This button runs all the actions entered into "End - Action 2" input below.
default: []
selector:
text:
end_action_button_3:
name: End Notify - Action Button 3
description: Enter the button name to be displayed in the notification.
This button runs all the actions entered into "End - Action 3" input below.
default: []
selector:
text:
end_action_button_stop:
name: End Notify - CANCEL Action Button
description: Enter the CANCEL button name to be displayed in the notification.
This button will cancel all actions and stop the automation.
It will be automatically included in the notification if you have enabled an action button above.
default: []
selector:
text:
end_time_delay:
name: End Notify - Time Delay
description: The time delay after which the automation will continue its execution if an action button has not been pressed.
default:
hours: 0
minutes: 30
seconds: 0
selector:
duration:
include_end_action_button_confirmation:
name: End Notify - Action Button Confirmation Option (Optional)
description: Select enable if you would like to notify all the devices when an action button has been pressed.
This is handy when notifying multiple devices. It lets the other devices know that an action has been pressed.
default: disable_end_action_button_confirmation
selector:
select:
options:
- label: Enable Action Button Confirmation
value: "enable_end_action_button_confirmation"
- label: Disable Action Button Confirmation
value: "disable_end_action_button_confirmation"
end_action_button_confirmation_title:
name: End Notify - Action Button Confirmation Title
description: The notification title when an action button is pressed or the time delay has passed.
default: []
selector:
text:
end_action_button_confirmation_message:
name: End Notify - Action Button Confirmation Message
description: The notification message when an action button is pressed.
default: []
selector:
text:
end_time_delay_confirmation_message:
name: End Notify - Time Delay Confirmation Message
description: The notification message when the time delay has passed.
default: []
selector:
text:
include_end_auto_actions:
name: Use The End Auto Action Options (Optional)
description: Enabling an auto option will allow the "End Actions" below to run when the calendar event is triggered.
When using action buttons in a notification, you do not need to enable these options for the end actions to work.
If you miss the notification and didn't press an action button, then enabling an end auto action option will make sure the action still runs.
default: []
selector:
select:
options:
- label: Enable auto end action 1 option
value: "enable_end_action_1"
- label: Enable auto end action 2 option
value: "enable_end_action_2"
- label: Enable auto end action 3 option
value: "enable_end_action_3"
multiple: true
end_action_1:
name: End Action - Action 1
description: Enter the actions you would like to run at the end of a calendar event.
This action is also linked to "End Notify - Action Button 1" in the end notifications.
default: []
selector:
action:
end_action_2:
name: End Action - Action 2
description: Enter the actions you would like to run at the end of a calendar event.
This action is also linked to "End Notify - Action Button 2" in the end notifications.
default: []
selector:
action:
end_action_3:
name: End Action - Action 3
description: Enter the actions you would like to run at the end of a calendar event.
This action is also linked to "End Notify - Action Button 3" in the end notifications.
default: []
selector:
action:
mode: restart
max_exceeded: silent
variables:
calendar: !input calendar
include_calendar_trigger: !input include_calendar_trigger
calendar_trigger: !input calendar_trigger
start_calendar_offset: !input start_calendar_offset
end_calendar_offset: !input end_calendar_offset
global_conditions: !input global_conditions
include_start_notify: !input include_start_notify
start_notify_device: !input start_notify_device
start_title: !input start_title
start_message: !input start_message
include_start_action_buttons: !input include_start_action_buttons
start_action_button_1: !input start_action_button_1
start_action_button_2: !input start_action_button_2
start_action_button_3: !input start_action_button_3
start_action_button_stop: !input start_action_button_stop
start_time_delay: !input start_time_delay
include_start_action_button_confirmation: !input include_start_action_button_confirmation
start_action_button_confirmation_title: !input start_action_button_confirmation_title
start_action_button_confirmation_message: !input start_action_button_confirmation_message
start_time_delay_confirmation_message: !input start_time_delay_confirmation_message
include_start_auto_actions: !input include_start_auto_actions
start_action_1: !input start_action_1
start_action_2: !input start_action_2
start_action_3: !input start_action_3
include_end_notify: !input include_end_notify
end_notify_device: !input end_notify_device
end_title: !input end_title
end_message: !input end_message
include_end_action_buttons: !input include_end_action_buttons
end_action_button_1: !input end_action_button_1
end_action_button_2: !input end_action_button_2
end_action_button_3: !input end_action_button_3
end_action_button_stop: !input end_action_button_stop
end_time_delay: !input end_time_delay
include_end_action_button_confirmation: !input include_end_action_button_confirmation
end_action_button_confirmation_title: !input end_action_button_confirmation_title
end_action_button_confirmation_message: !input end_action_button_confirmation_message
end_time_delay_confirmation_message: !input end_time_delay_confirmation_message
include_end_auto_actions: !input include_end_auto_actions
end_action_1: !input end_action_1
end_action_2: !input end_action_2
end_action_3: !input end_action_3
trigger:
- platform: calendar
id: "t0"
event: start
entity_id: !input calendar
offset: !input start_calendar_offset
- platform: calendar
id: "t1"
event: end
entity_id: !input calendar
offset: !input end_calendar_offset
# All Conditions
condition:
#Trigger conditions
- condition: or
conditions:
- condition: and # trigger by start of event
conditions:
- condition: trigger
id: 't0'
- condition: template
value_template: "{{ ('enable_start_notify_options' in include_start_notify) or ('enable_start_action_1' in include_start_auto_actions) or ('enable_start_action_2' in include_start_auto_actions) or ('enable_start_action_3' in include_start_auto_actions) }}"
- condition: and # trigger by end of event
conditions:
- condition: trigger
id: 't1'
- condition: template
value_template: "{{ ('enable_end_notify_options' in include_end_notify) or ('enable_end_action_1' in include_end_auto_actions) or ('enable_end_action_2' in include_end_auto_actions) or ('enable_end_action_3' in include_end_auto_actions) }}"
# Event key word in calendar summary
- condition: or
conditions:
- condition: template
value_template: "{{ calendar_trigger in trigger.calendar_event.summary }}"
- condition: template
value_template: "{{ calendar_trigger in trigger.calendar_event.description }}"
- condition: template
value_template: "{{ include_calendar_trigger == 'disable_key_word' }}"
# Global Conditions
- condition: and
conditions: !input global_conditions
action:
# Actions Variables
- alias: "Set up variables for the actions"
variables:
action_button_1: "{{ 'BUTTON_1_' ~ context.id }}"
action_button_2: "{{ 'BUTTON_2_' ~ context.id }}"
action_button_3: "{{ 'BUTTON_3_' ~ context.id }}"
action_button_stop: "{{ 'BUTTON_STOP_' ~ context.id }}"
# Automation
- choose:
- alias: "Start trigger"
conditions:
- condition: trigger
id: 't0'
sequence:
- choose:
- alias: "Check if the start of notification is enabled"
conditions:
- condition: template
value_template: "{{ 'enable_start_notify_options' in include_start_notify }}"
sequence:
- choose:
- alias: "Check the selected notification action buttons"
conditions:
- condition: template
value_template: "{{ ('enable_start_action_button_1' in include_start_action_buttons) and ('enable_start_action_button_2' in include_start_action_buttons) and ('enable_start_action_button_3' in include_start_action_buttons) }}"
sequence:
- alias: "Send a notification to each device"
repeat:
for_each: !input start_notify_device
sequence:
- service: "notify.mobile_app_{{ device_attr(repeat.item, 'name') | slugify }}"
data:
title: !input start_title
message: !input start_message
data:
sticky: "true"
actions:
- action: "{{ action_button_1 }}"
title: !input start_action_button_1
- action: "{{ action_button_2 }}"
title: !input start_action_button_2
- action: "{{ action_button_3 }}"
title: !input start_action_button_3
- action: "{{ action_button_stop }}"
title: !input start_action_button_stop
- alias: "Check the selected notification action buttons"
conditions:
- condition: template
value_template: "{{ ('enable_start_action_button_1' in include_start_action_buttons) and ('enable_start_action_button_2' in include_start_action_buttons) and ('enable_start_action_button_3' not in include_start_action_buttons) }}"
sequence:
- alias: Send a notification to each device
repeat:
for_each: !input start_notify_device
sequence:
- service: "notify.mobile_app_{{ device_attr(repeat.item, 'name') | slugify }}"
data:
title: !input start_title
message: !input start_message
data:
sticky: "true"
actions:
- action: "{{ action_button_1 }}"
title: !input start_action_button_1
- action: "{{ action_button_2 }}"
title: !input start_action_button_2
- action: "{{ action_button_stop }}"
title: !input start_action_button_stop
- alias: "Check the selected notification action buttons"
conditions:
- condition: template
value_template: "{{ ('enable_start_action_button_1' in include_start_action_buttons) and ('enable_start_action_button_2' not in include_start_action_buttons) and ('enable_start_action_button_3' in include_start_action_buttons) }}"
sequence:
- alias: Send a notification to each device
repeat:
for_each: !input start_notify_device
sequence:
- service: "notify.mobile_app_{{ device_attr(repeat.item, 'name') | slugify }}"
data:
title: !input start_title
message: !input start_message
data:
sticky: "true"
actions:
- action: "{{ action_button_1 }}"
title: !input start_action_button_1
- action: "{{ action_button_3 }}"
title: !input start_action_button_3
- action: "{{ action_button_stop }}"
title: !input start_action_button_stop
- alias: "Check the selected notification action buttons"
conditions:
- condition: template
value_template: "{{ ('enable_start_action_button_1' in include_start_action_buttons) and ('enable_start_action_button_2' not in include_start_action_buttons) and ('enable_start_action_button_3' not in include_start_action_buttons) }}"
sequence:
- alias: Send a notification to each device
repeat:
for_each: !input start_notify_device
sequence:
- service: "notify.mobile_app_{{ device_attr(repeat.item, 'name') | slugify }}"
data:
title: !input start_title
message: !input start_message
data:
sticky: "true"
actions:
- action: "{{ action_button_1 }}"
title: !input start_action_button_1
- action: "{{ action_button_stop }}"
title: !input start_action_button_stop
- alias: "Check the selected notification action buttons"
conditions:
- condition: template
value_template: "{{ ('enable_start_action_button_1' not in include_start_action_buttons) and ('enable_start_action_button_2' in include_start_action_buttons) and ('enable_start_action_button_3' in include_start_action_buttons) }}"
sequence:
- alias: Send a notification to each device
repeat:
for_each: !input start_notify_device
sequence:
- service: "notify.mobile_app_{{ device_attr(repeat.item, 'name') | slugify }}"
data:
title: !input start_title
message: !input start_message
data:
sticky: "true"
actions:
- action: "{{ action_button_2 }}"
title: !input start_action_button_2
- action: "{{ action_button_3 }}"
title: !input start_action_button_3
- action: "{{ action_button_stop }}"
title: !input start_action_button_stop
- alias: "Check the selected notification action buttons"
conditions:
- condition: template
value_template: "{{ ('enable_start_action_button_1' not in include_start_action_buttons) and ('enable_start_action_button_2' in include_start_action_buttons) and ('enable_start_action_button_3' not in include_start_action_buttons) }}"
sequence:
- alias: Send a notification to each device
repeat:
for_each: !input start_notify_device
sequence:
- service: "notify.mobile_app_{{ device_attr(repeat.item, 'name') | slugify }}"
data:
title: !input start_title
message: !input start_message
data:
sticky: "true"
actions:
- action: "{{ action_button_2 }}"
title: !input start_action_button_2
- action: "{{ action_button_stop }}"
title: !input start_action_button_stop
- alias: "Check the selected notification action buttons"
conditions:
- condition: template
value_template: "{{ ('enable_start_action_button_1' not in include_start_action_buttons) and ('enable_start_action_button_2' not in include_start_action_buttons) and ('enable_start_action_button_3' in include_start_action_buttons) }}"
sequence:
- alias: Send a notification to each device
repeat:
for_each: !input start_notify_device
sequence:
- service: "notify.mobile_app_{{ device_attr(repeat.item, 'name') | slugify }}"
data:
title: !input start_title
message: !input start_message
data:
sticky: "true"
actions:
- action: "{{ action_button_3 }}"
title: !input start_action_button_3
- action: "{{ action_button_stop }}"
title: !input start_action_button_stop
- alias: "Check the selected notification action buttons"
conditions:
- condition: template
value_template: "{{ ('enable_start_action_button_1' not in include_start_action_buttons) and ('enable_start_action_button_2' not in include_start_action_buttons) and ('enable_start_action_button_3' not in include_start_action_buttons) }}"
sequence:
- alias: Send a notification to each device
repeat:
for_each: !input start_notify_device
sequence:
- service: "notify.mobile_app_{{ device_attr(repeat.item, 'name') | slugify }}"
data:
title: !input start_title
message: !input start_message
data:
sticky: "true"
- choose:
- alias: "Check if any start action buttons are enabled"
conditions:
- condition: template
value_template: "{{ ('enable_start_action_button_1' in include_start_action_buttons) or ('enable_start_action_button_2' in include_start_action_buttons) or ('enable_start_action_button_3' in include_start_action_buttons) }}"
sequence:
- alias: "Wait for a response from the action button"
wait_for_trigger:
- platform: event
event_type: mobile_app_notification_action
event_data:
action: "{{ action_button_1 }}"
- platform: event
event_type: mobile_app_notification_action
event_data:
action: "{{ action_button_2 }}"
- platform: event
event_type: mobile_app_notification_action
event_data:
action: "{{ action_button_3 }}"
- platform: event
event_type: mobile_app_notification_action
event_data:
action: "{{ action_button_stop }}"
timeout: !input start_time_delay
- choose:
- alias: "Check if confirmation message is enabled"
conditions:
- condition: template
value_template: "{{ 'enable_start_action_button_confirmation' in include_start_action_button_confirmation }}"
sequence:
- if:
- alias: "Confirmation from the actions buttons"
condition: template
value_template: "{{ wait.trigger.idx is defined }}"
then:
- alias: Send a notification to each device
repeat:
for_each: !input start_notify_device
sequence:
- service: "notify.mobile_app_{{ device_attr(repeat.item, 'name') | slugify }}"
data:
title: !input start_action_button_confirmation_title
message: !input start_action_button_confirmation_message
- alias: "Perform the action button selected action"
choose:
- conditions: "{{ wait.trigger.event.data.action == action_button_1 }}"
sequence: !input start_action_1
- conditions: "{{ wait.trigger.event.data.action == action_button_2 }}"
sequence: !input start_action_2
- conditions: "{{ wait.trigger.event.data.action == action_button_3 }}"
sequence: !input start_action_3
- conditions: "{{ wait.trigger.event.data.action == action_button_stop }}"
sequence:
- stop: "Stop the automation"
else:
- alias: Send a notification to each device
repeat:
for_each: !input start_notify_device
sequence:
- service: "notify.mobile_app_{{ device_attr(repeat.item, 'name') | slugify }}"
data:
title: !input start_action_button_confirmation_title
message: !input start_time_delay_confirmation_message
- alias: "Check if confirmation message is disabled"
conditions:
- condition: template
value_template: "{{ 'disable_start_action_button_confirmation' in include_start_action_button_confirmation }}"
sequence:
- if:
- alias: "Confirmation from the actions buttons"
condition: template
value_template: "{{ wait.trigger.idx is defined }}"
then:
- alias: "Perform the action button selected action"
choose:
- conditions: "{{ wait.trigger.event.data.action == action_button_1 }}"
sequence: !input start_action_1
- conditions: "{{ wait.trigger.event.data.action == action_button_2 }}"
sequence: !input start_action_2
- conditions: "{{ wait.trigger.event.data.action == action_button_3 }}"
sequence: !input start_action_3
- conditions: "{{ wait.trigger.event.data.action == action_button_stop }}"
sequence:
- stop: "Stop the automation"
- choose:
- alias: "Check if auto action 1 is enabled"
conditions:
- condition: template
value_template: "{{ 'enable_start_action_1' in include_start_auto_actions }}"
sequence: !input start_action_1
- choose:
- alias: "Check if auto action 2 is enabled"
conditions:
- condition: template
value_template: "{{ 'enable_start_action_2' in include_start_auto_actions }}"
sequence: !input start_action_2
- choose:
- alias: "Check if auto action 3 is enabled"
conditions:
- condition: template
value_template: "{{ 'enable_start_action_3' in include_start_auto_actions }}"
sequence: !input start_action_3
default:
- choose:
- alias: "End Trigger"
conditions:
- condition: trigger
id: 't1'
sequence:
- choose:
- alias: "Check if end of notification is enabled"
conditions:
- condition: template
value_template: "{{ include_end_notify == 'enable_end_notify_options' }}"
sequence:
- choose:
- alias: "Check the selected notification action buttons"
conditions:
- condition: template
value_template: "{{ ('enable_end_action_button_1' in include_end_action_buttons) and ('enable_end_action_button_2' in include_end_action_buttons) and ('enable_end_action_button_3' in include_end_action_buttons) }}"
sequence:
- alias: Send a notification to each device
repeat:
for_each: !input end_notify_device
sequence:
- service: "notify.mobile_app_{{ device_attr(repeat.item, 'name') | slugify }}"
data:
title: !input end_title
message: !input end_message
data:
sticky: "true"
actions:
- action: "{{ action_button_1 }}"
title: !input end_action_button_1
- action: "{{ action_button_2 }}"
title: !input end_action_button_2
- action: "{{ action_button_3 }}"
title: !input end_action_button_3
- action: "{{ action_button_stop }}"
title: !input end_action_button_stop
- alias: "Check the selected notification action buttons"
conditions:
- condition: template
value_template: "{{ ('enable_end_action_button_1' in include_end_action_buttons) and ('enable_end_action_button_2' in include_end_action_buttons) and ('enable_end_action_button_3' not in include_end_action_buttons) }}"
sequence:
- alias: Send a notification to each device
repeat:
for_each: !input end_notify_device
sequence:
- service: "notify.mobile_app_{{ device_attr(repeat.item, 'name') | slugify }}"
data:
title: !input end_title
message: !input end_message
data:
sticky: "true"
actions:
- action: "{{ action_button_1 }}"
title: !input end_action_button_1
- action: "{{ action_button_2 }}"
title: !input end_action_button_2
- action: "{{ action_button_stop }}"
title: !input end_action_button_stop
- alias: "Check the selected notification action buttons"
conditions:
- condition: template
value_template: "{{ ('enable_end_action_button_1' in include_end_action_buttons) and ('enable_end_action_button_2' not in include_end_action_buttons) and ('enable_end_action_button_3' in include_end_action_buttons) }}"
sequence:
- alias: Send a notification to each device
repeat:
for_each: !input end_notify_device
sequence:
- service: "notify.mobile_app_{{ device_attr(repeat.item, 'name') | slugify }}"
data:
title: !input end_title
message: !input end_message
data:
sticky: "true"
actions:
- action: "{{ action_button_1 }}"
title: !input end_action_button_1
- action: "{{ action_button_3 }}"
title: !input end_action_button_3
- action: "{{ action_button_stop }}"
title: !input end_action_button_stop
- alias: "Check the selected notification action buttons"
conditions:
- condition: template
value_template: "{{ ('enable_end_action_button_1' in include_end_action_buttons) and ('enable_end_action_button_2' not in include_end_action_buttons) and ('enable_end_action_button_3' not in include_end_action_buttons) }}"
sequence:
- alias: Send a notification to each device
repeat:
for_each: !input end_notify_device
sequence:
- service: "notify.mobile_app_{{ device_attr(repeat.item, 'name') | slugify }}"
data:
title: !input end_title
message: !input end_message
data:
sticky: "true"
actions:
- action: "{{ action_button_1 }}"
title: !input end_action_button_1
- action: "{{ action_button_stop }}"
title: !input end_action_button_stop
- alias: "Check the selected notification action buttons"
conditions:
- condition: template
value_template: "{{ ('enable_end_action_button_1' not in include_end_action_buttons) and ('enable_end_action_button_2' in include_end_action_buttons) and ('enable_end_action_button_3' in include_end_action_buttons) }}"
sequence:
- alias: Send a notification to each device
repeat:
for_each: !input end_notify_device
sequence:
- service: "notify.mobile_app_{{ device_attr(repeat.item, 'name') | slugify }}"
data:
title: !input end_title
message: !input end_message
data:
sticky: "true"
actions:
- action: "{{ action_button_2 }}"
title: !input end_action_button_2
- action: "{{ action_button_3 }}"
title: !input end_action_button_3
- action: "{{ action_button_stop }}"
title: !input end_action_button_stop
- alias: "Check the selected notification action buttons"
conditions:
- condition: template
value_template: "{{ ('enable_end_action_button_1' not in include_end_action_buttons) and ('enable_end_action_button_2' in include_end_action_buttons) and ('enable_end_action_button_3' not in include_end_action_buttons) }}"
sequence:
- alias: Send a notification to each device
repeat:
for_each: !input end_notify_device
sequence:
- service: "notify.mobile_app_{{ device_attr(repeat.item, 'name') | slugify }}"
data:
title: !input end_title
message: !input end_message
data:
sticky: "true"
actions:
- action: "{{ action_button_2 }}"
title: !input end_action_button_2
- action: "{{ action_button_stop }}"
title: !input end_action_button_stop
- alias: "Check the selected notification action buttons"
conditions:
- condition: template
value_template: "{{ ('enable_end_action_button_1' not in include_end_action_buttons) and ('enable_end_action_button_2' not in include_end_action_buttons) and ('enable_end_action_button_3' in include_end_action_buttons) }}"
sequence:
- alias: Send a notification to each device
repeat:
for_each: !input end_notify_device
sequence:
- service: "notify.mobile_app_{{ device_attr(repeat.item, 'name') | slugify }}"
data:
title: !input end_title
message: !input end_message
data:
sticky: "true"
actions:
- action: "{{ action_button_3 }}"
title: !input end_action_button_3
- action: "{{ action_button_stop }}"
title: !input end_action_button_stop
- alias: "Check the selected notification action buttons"
conditions:
- condition: template
value_template: "{{ ('enable_end_action_button_1' not in include_end_action_buttons) and ('enable_end_action_button_2' not in include_end_action_buttons) and ('enable_end_action_button_3' not in include_end_action_buttons) }}"
sequence:
- alias: Send a notification to each device
repeat:
for_each: !input end_notify_device
sequence:
- service: "notify.mobile_app_{{ device_attr(repeat.item, 'name') | slugify }}"
data:
title: !input end_title
message: !input end_message
data:
sticky: "true"
- choose:
- alias: "Check if any start action buttons are enabled"
conditions:
- condition: template
value_template: "{{ ('enable_end_action_button_1' in include_end_action_buttons) or ('enable_end_action_button_2' in include_end_action_buttons) or ('enable_end_action_button_3' in include_end_action_buttons) }}"
sequence:
- alias: "Wait for a response from the action button"
wait_for_trigger:
- platform: event
event_type: mobile_app_notification_action
event_data:
action: "{{ action_button_1 }}"
- platform: event
event_type: mobile_app_notification_action
event_data:
action: "{{ action_button_2 }}"
- platform: event
event_type: mobile_app_notification_action
event_data:
action: "{{ action_button_3 }}"
- platform: event
event_type: mobile_app_notification_action
event_data:
action: "{{ action_button_stop }}"
timeout: !input end_time_delay
- choose:
- alias: "Check if confirmation message is enabled"
conditions:
- condition: template
value_template: "{{ 'enable_end_action_button_confirmation' in include_end_action_button_confirmation }}"
sequence:
- if:
- alias: "Confirmation from the actions buttons"
condition: template
value_template: "{{ wait.trigger.idx is defined }}"
then:
- alias: Send a notification to each device
repeat:
for_each: !input end_notify_device
sequence:
- service: "notify.mobile_app_{{ device_attr(repeat.item, 'name') | slugify }}"
data:
title: !input end_action_button_confirmation_title
message: !input end_action_button_confirmation_message
- alias: "Perform the action button selected action"
choose:
- conditions: "{{ action_button_1 in wait.trigger.event.data.action }}"
sequence: !input end_action_1
- conditions: "{{ action_button_2 in wait.trigger.event.data.action }}"
sequence: !input end_action_2
- conditions: "{{ action_button_3 in wait.trigger.event.data.action }}"
sequence: !input end_action_3
- conditions: "{{ action_button_stop in wait.trigger.event.data.action }}"
sequence:
- stop: "Stop the automation"
else:
- alias: Send a notification to each device
repeat:
for_each: !input end_notify_device
sequence:
- service: "notify.mobile_app_{{ device_attr(repeat.item, 'name') | slugify }}"
data:
title: !input end_action_button_confirmation_title
message: !input end_time_delay_confirmation_message
- alias: "Check if confirmation message is disabled"
conditions:
- condition: template
value_template: "{{ 'disable_end_action_button_confirmation' in include_end_action_button_confirmation }}"
sequence:
- if:
- alias: "Perform the action button selected action"
condition: template
value_template: "{{ wait.trigger.idx is defined }}"
then:
- alias: "Perform the action"
choose:
- conditions: "{{ action_button_1 in wait.trigger.event.data.action }}"
sequence: !input end_action_1
- conditions: "{{ action_button_2 in wait.trigger.event.data.action }}"
sequence: !input end_action_2
- conditions: "{{ action_button_3 in wait.trigger.event.data.action }}"
sequence: !input end_action_3
- conditions: "{{ action_button_stop in wait.trigger.event.data.action }}"
sequence:
- stop: "Stop the automation"
- choose:
- alias: "Check if auto action 1 is enabled"
conditions:
- condition: template
value_template: "{{ 'enable_end_action_1' in include_end_auto_actions }}"
sequence: !input end_action_1
- choose:
- alias: "Check if auto action 2 is enabled"
conditions:
- condition: template
value_template: "{{ 'enable_end_action_2' in include_end_auto_actions }}"
sequence: !input end_action_2
- choose:
- alias: "Check if auto action 3 is enabled"
conditions:
- condition: template
value_template: "{{ 'enable_end_action_3' in include_end_auto_actions }}"
sequence: !input end_action_3
@denselm
Copy link

denselm commented Jan 5, 2024

Thank you for the blueprint. I cannot submit a PR to a gist so commenting here: if we replace the string compare at https://gist.github.com/Blackshome/40bfd92fb1fe6a9a9189325704a3c81b#file-calendar-notifications-and-actions-yaml-L485 and L487 with a regex match value template such as

value_template: "{{ trigger.calendar_event.description is search(calendar_trigger, ignorecase=True) }}"

then I believe users can use a regex in calendar_trigger to match advanced conditions instead of cloning the automation several times for each word they want to match in the summary/description (and it can be case insensitive too)

@yey3men2
Copy link

Hello, thank you for creating this awesome blueprint, I'm having an issue and maybe you can help me resolve it. I created an automation using this blueprint and is working perfectly on iPhone and iPad but not on Android phone. I can get it to send the notification to android only if I disable the Action Buttons Options, any idea why?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment