Skip to content

Instantly share code, notes, and snippets.

@Blackshome
Last active May 11, 2024 10:36
Show Gist options
  • Save Blackshome/180ca4a24af81cd5d843acfc039039bc to your computer and use it in GitHub Desktop.
Save Blackshome/180ca4a24af81cd5d843acfc039039bc to your computer and use it in GitHub Desktop.
notifications-and-announcements.yaml
blueprint:
name: Notifications & Announcements
description: >
# 📢 Notifications & Announcements
**Version: 1.0**
State your trigger and spread the word 💬 🔉
**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) 🙂
<details>
<summary><b>The Automation Process:</b> - Click here to expand</summary>
- **Trigger Options:**
- Specify the state change of one or more entities that will initiate the automation from a dropdown list. You can also specify your own custom state if it is not available from the dropdown list.
- State Change Options: The available state changes include:
- **General States:** Button or any state, ON, OFF, Unavailable or Unknown
- **Location-Based States:** Home or Not Home
- **Numeric States:** Numeric state above, Numeric state below or Numeric state above & below
- **Notification Options:**
- Opt to send messages to one or multiple devices. Compatible with Apple iOS and Android devices.
- Opt to display your notifications directly within the Home Assistant user interface (UI).
- Opt to send Text-to-Speech Announcement to your selected media players.
- **Time-Based Automation:**
- Specify precise start and end times along with weekday selections to define when the automation can run.
- **Custom Conditions:**
- Enter any custom conditions to further customize the automation process.
</details>
Need help? See our FAQ: [Click Here](https://community.home-assistant.io/t/notifications-announcements/728100/2?u=blacky)
Let us know what you think of this blueprint and for community support including updates: [Click Here](https://community.home-assistant.io/t/notifications-announcements/728100?u=blacky)
Required = *
domain: automation
input:
trigger_state:
name: Trigger - State *
description: Please select what state you would like for your trigger.
You can choose from ten options available in the dropdown menu.
If your option is not in the dropdown menu then just type the state you would like to use in and click the save button.
1 - Button Or Any State
2 - ON
3 - OFF
4 - Unavailable
5 - Unknown
6 - Home
7 - Not Home
8 - Numeric State - Above
9 - Numeric State - Below
10 - Numeric State - Above & Below
A numbering system has been implemented to facilitate navigation within the dropdown selections. Each number corresponds to a specific configuration,
aiding users in identifying and adjusting the settings used within each selection. For instance, when selecting "8 - Numeric State - Above"
as a dropdown option, settings marked "Used in options 8, 9 or 10" are required for that respective selection because number 8 is included in those options.
default: button_any_state
selector:
select:
custom_value: true
mode: dropdown
options:
- label: 1 - Button Or Any State
value: "button_any_state"
- label: 2 - ON
value: "on"
- label: 3 - OFF
value: "off"
- label: 4 - Unavailable
value: "unavailable"
- label: 5 - Unknown
value: "unknown"
- label: 6 - Home
value: "home"
- label: 7 - Not Home
value: "not_home"
- label: 8 - Numeric State - Above
value: "numeric_state_above"
- label: 9 - Numeric State - Below
value: "numeric_state_below"
- label: 10 - Numeric State - Above & Below
value: "numeric_state_above_below"
trigger_state_entity:
name: Trigger - State Entities
description: "**Used in options 1, 2, 3, 4, 5, 6 or 7** - Enter the entities that will trigger the automation on state change."
default: []
selector:
entity:
multiple: true
trigger_numeric_entity:
name: Trigger - Numeric State Entities
description: "**Used in options 8, 9 or 10** - Enter the entities that will trigger the automation numeric state change."
default: []
selector:
entity:
multiple: true
above_state:
name: Trigger - Numeric State Above Option
description: "**Used in options 8, or 10** - Set the above value. The numeric state trigger will be when the value crosses over to above the set value."
default: 0
selector:
number:
min: -20
max: 100
step: 1
unit_of_measurement: value
below_state:
name: Trigger - Numeric State Below Option
description: "**Used in options 9 or 10** - Set the below value. The numeric state trigger will be when the value crosses over to below the set value."
default: 0
selector:
number:
min: -20
max: 100
step: 1
unit_of_measurement: value
time_delay_state:
name: Trigger - Time Delay
description: "**Used in options 1, 2, 3, 4, 5, 6, 7, 8, 9 or 10** - The state trigger will only fire if the state holds for the set time delay. It is used as a buffer to stop false triggers."
default: 0
selector:
number:
min: 0
max: 10
step: 0.5
unit_of_measurement: minutes
include_notify:
name: Use The Mobile App Notify Opion (Optional)
description: Enabling this option will send notifications to the selected devices below.
default: disable_mobile_app_notify
selector:
select:
options:
- label: Enable Mobile App Notify Opion
value: "enable_mobile_app_notify"
- label: Disable Mobile App Notify Opion
value: "disable_mobile_app_notify"
notify_device:
name: Mobile App Notify - Devices Notified When Started
description: Select the devices to be notified when the automation is triggered.
default: []
selector:
device:
filter:
- integration: mobile_app
multiple: true
notify_title:
name: Mobile App Notify - Title
description: Enter in the title of your notification.
default: 📢 Enter Notify Title Here
selector:
text:
notify_message:
name: Mobile App Notify - Message
description: Enter in the message of your notification.
default: Enter Notify Message Here 🙂
selector:
text:
include_persistent_notification:
name: Use The UI Notification Option (Optional)
description: Enabling this option will display notifications directly within the Home Assistant user interface (UI).
default: disabled_persistent_notification
selector:
select:
options:
- label: Enable UI Notification
value: "enable_persistent_notification"
- label: Disable UI Notification
value: "disabled_persistent_notification"
persistent_title:
name: UI Notification - Title
description: Enter in the title of your UI notification.
default: 📢 Enter UI Title Here
selector:
text:
persistent_message:
name: UI Notification - Message
description: Enter in the message of your UI notification.
default: Enter UI Message Here 🙂
selector:
text:
include_tts_announcement:
name: Use The Text-to-Speech Announcement Option (Optional)
description: Enabling this option will send a Text-to-Speech notification to the selected Media Players below.
default: disable_tts_announcement
selector:
select:
options:
- label: Enable Text-to-Speech Notify Opions
value: "enable_tts_announcement"
- label: Disable Text-to-Speech Notify Opions
value: "disable_tts_announcement"
text_to_speech_engine:
name: Text-to-Speech Service Provider
description: Select the Text-to-Speech service provider.
default: []
selector:
entity:
domain: tts
media_player:
name: Media Player
description: Select the Media Player/s that will play your Text-to-Speech announcement message.
default: []
selector:
entity:
domain: media_player
multiple: true
notify_tts_message:
name: Announcement Message
description: Enter in the message of your Text-to-Speech announcement.
default: Enter TTS Message Here
selector:
text:
multiline: true
include_time:
name: Use The Time Options (Optional)
description: Use the "Start Time", "End Time" and the "Weekdays" values to only run the automation between the time periods.
This option allows you to disable the automation during sleeping hours to avoid disturbing anyone.
Another example is setting the time between 5pm and 9pm for the 'dinner is ready' call.
This way, if you accidentally activate the trigger outside these hours, the automation will not run.
default: time_disabled
selector:
select:
options:
- label: Enable the time options
value: "time_enabled"
- label: Disable the time options
value: "time_disabled"
after_time:
name: Start Time
description: Set the start time.
default: 00:00:00
selector:
time:
before_time:
name: End Time
description: Set the end time.
default: 00:00:00
selector:
time:
weekday_options:
name: Weekdays
description: Select the days of the week you would like the automation to run.
You must select "Enable the time options" above for the weekdays selections to work.
default:
- mon
- tue
- wed
- thu
- fri
- sat
- sun
selector:
select:
multiple: true
mode: list
options:
- label: Monday
value: "mon"
- label: Tuesday
value: "tue"
- label: Wednesday
value: "wed"
- label: Thursday
value: "thu"
- label: Friday
value: "fri"
- label: Saturday
value: "sat"
- label: Sunday
value: "sun"
global_conditions:
name: Global Conditions
description: Enter any global conditions you would like to apply to the automation.
default: []
selector:
condition:
mode: single
max_exceeded: silent
variables:
trigger_state: !input trigger_state
trigger_state_entity: !input trigger_state_entity
trigger_numeric_entity: !input trigger_numeric_entity
above_state: !input above_state
below_state: !input below_state
time_delay_state: !input time_delay_state
include_notify: !input include_notify
notify_device: !input notify_device
notify_title: !input notify_title
notify_message: !input notify_message
include_persistent_notification: !input include_persistent_notification
persistent_title: !input persistent_title
persistent_message: !input persistent_message
include_tts_announcement: !input include_tts_announcement
text_to_speech_engine: !input text_to_speech_engine
media_player: !input media_player
notify_tts_message: !input notify_tts_message
include_time: !input include_time
after_time: !input after_time
before_time: !input before_time
weekday_options: !input weekday_options
global_conditions: !input global_conditions
trigger:
- platform: state
id: "t0"
entity_id: !input trigger_state_entity
for:
minutes: !input time_delay_state
- platform: state
id: "t1"
entity_id: !input trigger_state_entity
to: !input trigger_state
for:
minutes: !input time_delay_state
- platform: numeric_state
id: "t2"
entity_id: !input trigger_numeric_entity
above: !input above_state
for:
minutes: !input time_delay_state
- platform: numeric_state
id: "t3"
entity_id: !input trigger_numeric_entity
below: !input below_state
for:
minutes: !input time_delay_state
# All Conditions
condition:
#Trigger conditions
- condition: or
conditions:
- condition: and # trigger for button or any state
conditions:
- condition: trigger
id: 't0'
- "{{ trigger_state == 'button_any_state' }}"
- condition: and # trigger not for button or any state
conditions:
- condition: trigger
id: 't1'
- "{{ (trigger_state != 'button_any_state') or (trigger_state != 'numeric_state_above') or (trigger_state != 'numeric_state_below') or (trigger_state != 'numeric_state_above_below') }}"
- condition: and # trigger for numeric above state
conditions:
- condition: trigger
id: 't2'
- "{{ (trigger_state == 'numeric_state_above') or (trigger_state == 'numeric_state_above_below') }}"
- condition: and # trigger for numeric below state
conditions:
- condition: trigger
id: 't3'
- "{{ (trigger_state == 'numeric_state_below') or (trigger_state == 'numeric_state_above_below') }}"
# Check The Time Options
- condition: or
conditions:
- "{{ include_time == 'time_disabled' }}"
- condition: and
conditions:
- condition: time
after: !input after_time
before: !input before_time
weekday: !input weekday_options
- "{{ include_time == 'time_enabled' }}"
# Global Conditions
- condition: and
conditions: !input global_conditions
action:
- choose:
- alias: "Check if notification is enabled"
conditions:
- "{{ include_notify == 'enable_mobile_app_notify' }}"
sequence:
- alias: Send a notification to each device
repeat:
for_each: !input notify_device
sequence:
- service: "notify.mobile_app_{{ device_attr(repeat.item, 'name') | slugify }}"
data:
title: !input notify_title
message: !input notify_message
- choose:
- alias: "Use the persistent notification is enabled"
conditions:
- condition: template
value_template: "{{ include_persistent_notification == 'enable_persistent_notification' }}"
sequence:
- service: persistent_notification.create
data:
title: !input persistent_title
message: !input persistent_message
- choose:
- alias: "Check if tts announcement is enabled"
conditions:
- "{{ include_tts_announcement == 'enable_tts_announcement' }}"
sequence:
- service: tts.speak
target:
entity_id: !input text_to_speech_engine
data:
media_player_entity_id: !input media_player
message: !input notify_tts_message
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment