Last active
December 27, 2024 10:47
-
-
Save Blackshome/4010fb83bb8c19b5fa1425526c6ff0e2 to your computer and use it in GitHub Desktop.
low-battery-notifications-and-actions.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
blueprint: | |
name: Low Battery Notifications & Actions | |
description: > | |
# 🪫 Low Battery Notifications & Actions | |
**Version: 2.8** | |
🚀 Stay Charged, Stay Smart! Let's automate and take charge of your battery maintenance!🔋⚡ | |
**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> 👈</summary> | |
- **Trigger Options:** | |
- **Button Helper:** Press a button in the user interface (UI) to check battery levels. | |
- **Time & Day:** Automatically periodically checks battery levels on any given time and day. | |
- **Battery Sensors:** | |
- Automatically detects all battery sensors used in Home Assistant. | |
- Set a battery low warning percentage to identify all batteries below this level. | |
- Detects Low, unavailable & unknown batteries. | |
- Excludes specific battery sensors from notifications. | |
- Create a custom group of battery sensors with its own independent low battery warning percentage. | |
- **Notification Options:** | |
- Opt to send messages to one or multiple devices. | |
- Opt to display your notifications directly within the Home Assistant user interface (UI). | |
- Choose which battery sensors to use, and then select their states from one of three preset messages: | |
- Battery Low % Level + Low Battery Level + Unavailable + Unknown. | |
- Battery Low % Level & Low Battery Level. | |
- Unavailable or Unknown Sensors. | |
- Opt to receive a confirmation message if all batteries are okay. | |
- Opt to use action buttons in your device notification that allows you to add your low batteries to a To-Do list. | |
- Compatible with Apple iOS and Android devices. | |
- **Custom Actions:** | |
- Customize actions to suit your preferences and needs, enhancing the automations functionality. | |
- Utilize 10 custom predetermined battery sensors within the blueprint for more tailored and precise actions. | |
- Configure custom actions to include features like customizing notifications or playing announcements on platforms like The Voice (HA), Google, Alexa, TTS, etc. | |
- **Custom Conditions:** | |
- Enter any custom conditions to further customize the automation process. | |
</details> | |
Need help? | |
- FAQ: [Click Here](https://community.home-assistant.io/t/653754/2?u=blacky) | |
- Community Support Including Updates: [Click Here](https://community.home-assistant.io/t/653754) | |
Required = * | |
domain: automation | |
input: | |
trigger_settings: | |
name: "Triggers *" | |
icon: mdi:cog-outline | |
description: > | |
You must select at least one trigger * | |
collapsed: true | |
input: | |
include_button: | |
name: Use The Button Helper Trigger (Optional) | |
description: > | |
Select if you would like a button helper to trigger the automation. | |
This is useful if you would like to check the battery levels by pressing a button in the UI. | |
For more information on how to create a button helper [Click Here](https://community.home-assistant.io/t/653754/4) | |
default: disable_button_trigger | |
selector: | |
select: | |
options: | |
- label: Use a button trigger | |
value: "enable_button_trigger" | |
- label: Dont use a button trigger | |
value: "disable_button_trigger" | |
button_entity: | |
name: Button Helper | |
description: > | |
Input your button helper. | |
default: [] | |
selector: | |
entity: | |
filter: | |
domain: input_button | |
include_time: | |
name: Use The Time Trigger (Optional) | |
description: > | |
Select if you would like to use the time trigger. | |
This is useful if you would like to periodically check the battery levels on any given time and day. | |
default: time_disabled | |
selector: | |
select: | |
options: | |
- label: Enable the time options | |
value: "time_enabled" | |
- label: Disable the time options | |
value: "time_disabled" | |
time: | |
name: Time | |
description: > | |
Set the time you would like to run the automation. | |
default: '00:00:00' | |
selector: | |
time: | |
weekday_options: | |
name: Weekdays | |
description: > | |
Select the days of the week you would like the automation to run. | |
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" | |
battery_settings: | |
name: "Battery Settings" | |
icon: mdi:battery-alert-variant-outline | |
collapsed: true | |
input: | |
battery_level: | |
name: Battery Low Warning Level | |
description: > | |
Set the battery low warning percentage to identify all batteries below this level. | |
default: 20 | |
selector: | |
number: | |
min: 1 | |
max: 100 | |
step: 1 | |
unit_of_measurement: '%' | |
exclude_sensors: | |
name: Excluded Battery Sensors (Optional) | |
description: > | |
Choose the battery sensors to be excluded when the automation runs. | |
The automation will attempt to detect all battery sensors used in Home Assistant, including those of your phones, tablets, etc. | |
However, it may not always be necessary or desirable to monitor these batteries. | |
Selecting these batteries here will exclude them from your notifications. | |
**NOTE** - You can only use entities. Areas, devices and labels are not supported. | |
default: { entity_id: [] } | |
selector: | |
target: | |
entity: | |
device_class: battery | |
custom_group: | |
name: Battery Sensors - Custom Group (Optional) | |
description: > | |
You can select a custom group of battery sensors to be included in your notifications. | |
This custom group has its own independent 'Battery Low Warning Level' setting below. | |
When using all batteries along with the custom group in a single automation, it is recommended to exclude the custom group of batteries specified above in the 'Excluded Battery Sensors' section. | |
Excluded battery sensors are not linked to this custom group. | |
**NOTE** - You can only use entities. Areas, devices and labels are not supported. | |
default: { entity_id: [] } | |
selector: | |
target: | |
entity: | |
device_class: battery | |
custom_group_battery_level: | |
name: Custom Group - Battery Low Warning Level | |
description: > | |
Set the battery low warning percentage to identify all batteries below this level. | |
default: 20 | |
selector: | |
number: | |
min: 1 | |
max: 100 | |
step: 1 | |
unit_of_measurement: '%' | |
easy_notify_settings: | |
name: "Easy Notify" | |
icon: mdi:bell-check-outline | |
collapsed: true | |
input: | |
include_easy_notify: | |
name: Use The Easy Notify - Device Notification Options (Optional) | |
description: > | |
Enabling this option will send notifications to the selected devices below. | |
It allows you to choose which battery sensors to use, and then select their states from one of three preset messages. | |
You can also opt to receive a confirmation message if all batteries are okay. | |
For further customization or to integrate with voice assistants like HA, Google, Alexa, TTS, etc., please explore the custom action options below. | |
default: disabled_easy_notify | |
selector: | |
select: | |
options: | |
- label: Enable Device Notification | |
value: "enable_easy_notify" | |
- label: Enable Device Notification + Okay Confirmation Message | |
value: "enable_easy_okay_notify" | |
- label: Disable Device Notification | |
value: "disabled_easy_notify" | |
include_persistent_notification: | |
name: Use The Easy Notify - UI Notification Options (Optional) | |
description: > | |
Enabling this option will display notifications directly within the Home Assistant user interface (UI). | |
It allows you to choose which battery sensors to use, and then select their states from one of three preset messages. | |
You can also opt to receive a confirmation message in the UI if all batteries are okay. | |
For further customization or to integrate with voice assistants like HA, Google, Alexa, TTS, etc., please explore the custom action options below. | |
default: disabled_persistent_notification | |
selector: | |
select: | |
options: | |
- label: Enable UI Notification | |
value: "enable_persistent_notification" | |
- label: Enable UI Notification + Okay Confirmation Message | |
value: "enable_persistent_okay_notification" | |
- label: Disable UI Notification | |
value: "disabled_persistent_notification" | |
sensor_selection: | |
name: Sensor Selection | |
description: > | |
Please select which sensors you would like to include in your notifications. | |
default: enable_all_sensors | |
selector: | |
select: | |
options: | |
- label: Use Battery Sensors - Custom Group | |
value: "enable_battery_sensors_custom_group" | |
- label: Use All Battery Sensors Minus Excluded Battery Sensors | |
value: "enable_all_sensors" | |
- label: Use All Battery Sensors Minus Excluded Battery Sensors + Custom Group | |
value: "enable_all_and_custom_group_sensors" | |
notify_device: | |
name: Devices Notified (Optional) | |
description: > | |
If you've enabled device notifications above, please select the devices to receive the notifications. | |
default: [] | |
selector: | |
device: | |
filter: | |
- integration: mobile_app | |
multiple: true | |
notify_title: | |
name: Title | |
description: > | |
Enter in the notification title of your message. | |
default: Low Battery Notification | |
selector: | |
text: | |
notify_message: | |
name: Message | |
description: > | |
Choose one of the three preset messages from the dropdown menu. | |
**1 - Battery Low % Level + Low Battery Level + Unavailable + Unknown** | |
Includes sensors with battery percentages below the low warning level, in a low battery state, or marked as unavailable or unknown. | |
**2 - Battery Low % Level & Low Battery Level** | |
Includes sensors with battery percentages below the low warning level or in a low battery state. | |
**3 - Unavailable or Unknown Sensors** | |
Includes sensors that are unavailable or have an unknown state. | |
default: all_sensors | |
selector: | |
select: | |
mode: dropdown | |
options: | |
- label: 1 - Battery Low % Level + Low Battery Level + Unavailable + Unknown | |
value: "all_sensors" | |
- label: 2 - Battery Low % Level & Low Battery Level | |
value: "sensors" | |
- label: 3 - Unavailable or Unknown Sensors | |
value: "unavailable_sensors" | |
notify_okay_message: | |
name: Okay Confirmation Message | |
description: > | |
Enter in the notification message you would like to receive when all your batteries are okay. | |
default: YES! All batteries are okay :) | |
selector: | |
text: | |
notify_interruption_level: | |
name: Interruption Level - iOS Only | |
description: > | |
On devices running iOS 15 and later, you can configure the interruption level for your notifications to ensure they are delivered according to your preferences. | |
Choose the desired interruption level from the dropdown list. | |
Critical and time-sensitive notifications must be turned ON within the Home Assistant App, and time-sensitive notifications must be allowed in your Focus settings. | |
For more information on interruption levels [Click Here](https://community.home-assistant.io/t/653754/192?u=blacky) | |
default: active | |
selector: | |
select: | |
mode: dropdown | |
options: | |
- label: Default | |
value: "active" | |
- label: Critical Notifications | |
value: "critical" | |
- label: Time Sensitive Notifications | |
value: "time-sensitive" | |
- label: Quiet Notifications Without Waking Screen | |
value: "passive" | |
notify_sound: | |
name: Notification Sound - iOS Only | |
description: > | |
The Home Assistant app for iOS includes built-in notification sounds, and you can import sounds from your iOS device into the app. | |
Custom sounds can also be added via iTunes or from your cloud storage. | |
When entering a sound, ensure you use the full filename, including the extension. | |
For more information on using sounds in the Home Assistant app, [Click Here](https://community.home-assistant.io/t/653754/192?u=blacky) | |
default: [] | |
selector: | |
text: | |
notify_data: | |
name: Android Only Options (Optional) | |
description: > | |
**High Priority** notifications ensure that you receive important alerts immediately. | |
These notifications bypass normal delivery delays and are delivered instantly to your device. | |
**Sticky Notification** ensure that important alerts are not dismissed when selected. They remain on your notification screen until you actively clear or swipe them away, ensuring that critical information stays visible until addressed. | |
**Notification Channel** allow you to easily organize different notification settings, | |
including notification sounds, vibrations, and other device-specific features. | |
If you choose this option, please enter your desired channel name below. | |
default: [] | |
selector: | |
select: | |
multiple: true | |
options: | |
- label: High Priority | |
value: "high_priority" | |
- label: Sticky Notification | |
value: "sticky" | |
- label: Notification Channel | |
value: "channel" | |
notify_channel: | |
name: Notification Channel - Android Only | |
description: > | |
If you have chosen to use a notification channel, simply enter the name of an existing channel to apply its pre-configured settings. | |
If you don't have a channel yet, you can create a new one by entering a name here. | |
When your automation sends the first notification, it will create the channel on your device. | |
After the channel is created, you can customize its notification settings to your preference directly on your device. | |
For more information on notification channels [Click Here](https://community.home-assistant.io/t/653754/192?u=blacky) | |
default: [] | |
selector: | |
text: | |
action_buttons_settings: | |
name: "Action Buttons" | |
icon: mdi:gesture-tap-button | |
collapsed: true | |
input: | |
notify_action_buttons: | |
name: Easy Notify - Action Buttons (Optional) | |
description: > | |
Enhance your device notifications with an actionable To-Do list button feature. | |
With just a hold, release and tap, effortlessly add selected items from your low battery notification to any of your chosen To-Do lists. | |
Plus, for added assurance, you can opt to receive a confirmation message confirming the action. | |
default: disabled_notify_action_buttons | |
selector: | |
select: | |
options: | |
- label: Add To-Do List Action Buttons | |
value: "enable_to_do_list_button" | |
- label: Add To-Do List Action Buttons + Confirmation Message | |
value: "enable_to_do_list_button_and_confirmation" | |
- label: Disable Action Buttons | |
value: "disabled_notify_action_buttons" | |
to_do_list: | |
name: Easy Notify Action Buttons - To-Do List Selection | |
description: > | |
Choose the To-Do list where you'd like to add your task. | |
**Note** - The default shopping list isn't compatible due to its lack of description capability. | |
However, all other To-Do lists are fully supported. | |
default: [] | |
selector: | |
entity: | |
filter: | |
domain: todo | |
to_do_task_title: | |
name: Easy Notify Action Buttons - Task Title | |
description: > | |
When the action button is pressed, it will add a task to your chosen To-Do list. | |
Please enter the title you would like for your To-Do task | |
default: Batteries To Be Replaced | |
selector: | |
text: | |
action_button_to_do: | |
name: Easy Notify Action Buttons - Action Button | |
description: > | |
Please specify the name for the action button to be displayed in the notification. | |
When pressed this button effortlessly adds a task to your chosen To-Do list. | |
default: Add To To-Do List! | |
selector: | |
text: | |
action_button_cancel: | |
name: Easy Notify Action Buttons - Cancel Button | |
description: > | |
Please specify the name for the cancel button to be displayed in the notification. | |
This button allows you to cancel the task addition process. | |
default: Cancel | |
selector: | |
text: | |
action_button_confirmation_title: | |
name: Easy Notify Action Buttons - Action & Cancel Button Confirmation Title | |
description: > | |
Please enter in a title for the confirmation notification message when an action button or a cancel button is pressed. | |
default: Low Battery Confirmation | |
selector: | |
text: | |
action_button_confirmation_message: | |
name: Easy Notify Action Buttons - Action Button Confirmation Message | |
description: > | |
Please enter in the message for the confirmation notification message when the action button is pressed. | |
default: Your low batteries have been added to your To-Do list | |
selector: | |
text: | |
cancel_action_button_confirmation_message: | |
name: Easy Notify Action Buttons - Cancel Button Confirmation Message | |
description: > | |
Please enter in the message for the confirmation notification message when the cancel button is pressed. | |
default: Cancelled - Nothing was added to your To-Do list | |
selector: | |
text: | |
custom_actions_settings: | |
name: "Custom Actions" | |
icon: mdi:code-tags | |
collapsed: true | |
input: | |
include_custom_actions: | |
name: Use The Custom Action Options (Optional) | |
description: > | |
You can add any custom actions you'd like to run when the automation is triggered. | |
This can include customizing notifications or playing announcements on platforms like The Voice (HA), Google, Alexa, TTS, etc. | |
default: disabled_custom_actions | |
selector: | |
select: | |
options: | |
- label: Enable Custom Actions | |
value: "enable_custom_actions" | |
- label: Disable Custom Actions | |
value: "disabled_custom_actions" | |
custom_actions: | |
name: Custom Actions | |
description: > | |
Add your custom actions that you'd like to run when the automation is triggered. | |
Below are 10 sensors you can include in your actions, depending on your preferences. | |
**All Battery Sensors Minus Excluded** | |
1 - Use "{{all_sensors}}" for - Battery Low % Level + Low Battery Level + Unavailable + Unknown. | |
2 - Use "{{sensors}}" for - Battery Low % Level & Low Battery Level. | |
3 - Use "{{unavailable_sensors}}" for - Unavailable or Unknown Sensors. | |
4 - Use "{{sensors_names}}" for - Battery Low % Level & Low Battery Level - Sensor name only. | |
5 - Use "{{unavailable_sensors_names}}" for - Unavailable or Unknown Sensors - Sensor name only. | |
**Battery Sensors - Custom Group** | |
1 - Use "{{all_sensors_custom_group}}" for - Battery Low % Level + Low Battery Level + Unavailable + Unknown. | |
2 - Use "{{sensors_custom_group}}" for - Battery Low % Level & Low Battery Level. | |
3 - Use "{{unavailable_sensors_custom_group}}" for - Unavailable or Unknown Sensors. | |
4 - Use "{{sensors_names_custom_group}}" for - Battery Low % Level & Low Battery Level - Sensor name only. | |
5 - Use "{{unavailable_sensors_names_custom_group}}" for - Unavailable or Unknown Sensors - Sensor name only. | |
For more information on how to use these sensors in your actions [Click Here](https://community.home-assistant.io/t/653754/21) | |
default: [] | |
selector: | |
action: | |
global_conditions_settings: | |
name: "Global Conditions" | |
icon: mdi:earth | |
collapsed: true | |
input: | |
global_conditions: | |
name: Global Conditions | |
description: > | |
Enter any global conditions you would like to apply to the automation. | |
default: [] | |
selector: | |
condition: | |
mode: restart | |
max_exceeded: silent | |
variables: | |
include_button: !input include_button | |
button_entity: !input button_entity | |
include_time: !input include_time | |
time: !input time | |
weekday_options: !input weekday_options | |
battery_level: !input battery_level | |
exclude_sensors: !input exclude_sensors | |
custom_group: !input custom_group | |
custom_group_battery_level: !input custom_group_battery_level | |
include_easy_notify: !input include_easy_notify | |
include_persistent_notification: !input include_persistent_notification | |
sensor_selection: !input sensor_selection | |
notify_device: !input notify_device | |
notify_title: !input notify_title | |
notify_message: !input notify_message | |
notify_okay_message: !input notify_okay_message | |
notify_interruption_level: !input notify_interruption_level | |
notify_sound: !input notify_sound | |
notify_data: !input notify_data | |
notify_channel: !input notify_channel | |
notify_action_buttons: !input notify_action_buttons | |
to_do_list: !input to_do_list | |
to_do_task_title: !input to_do_task_title | |
action_button_to_do: !input action_button_to_do | |
action_button_cancel: !input action_button_cancel | |
action_button_confirmation_title: !input action_button_confirmation_title | |
action_button_confirmation_message: !input action_button_confirmation_message | |
cancel_action_button_confirmation_message: !input cancel_action_button_confirmation_message | |
include_custom_actions: !input include_custom_actions | |
global_conditions: !input global_conditions | |
# Notify device option data | |
device_message_data: >- | |
{% set message = namespace(data={}) %} | |
{% set push = namespace(data={}) %} | |
{% if notify_interruption_level in ['active', 'critical', 'time-sensitive', 'passive'] %} | |
{% set push.data = dict(push.data, **{ 'interruption-level': notify_interruption_level }) %} | |
{% endif %} | |
{% if notify_sound != [] %} | |
{% set push.data = dict(push.data, **{ 'sound': notify_sound }) %} | |
{% endif %} | |
{% if push.data %} | |
{% set message.data = dict(message.data, **{ 'push': push.data }) %} | |
{% endif %} | |
{% if 'high_priority' in notify_data %} | |
{% set message.data = dict(message.data, **{ 'ttl': 0, 'priority': 'high' }) %} | |
{% endif %} | |
{% if 'channel' in notify_data %} | |
{% set message.data = dict(message.data, **{ 'channel': notify_channel }) %} | |
{% endif %} | |
{% if 'sticky' in notify_data %} | |
{% set message.data = dict(message.data, **{ 'sticky': "true" }) %} | |
{% endif %} | |
{{ message.data }} | |
# Notify device option data with action buttons | |
device_message_data_action_button: >- | |
{% set message = namespace(data={}) %} | |
{% set push = namespace(data={}) %} | |
{% if notify_interruption_level in ['active', 'critical', 'time-sensitive', 'passive'] %} | |
{% set push.data = dict(push.data, **{ 'interruption-level': notify_interruption_level }) %} | |
{% endif %} | |
{% if notify_sound != [] %} | |
{% set push.data = dict(push.data, **{ 'sound': notify_sound }) %} | |
{% endif %} | |
{% if push.data %} | |
{% set message.data = dict(message.data, **{ 'push': push.data }) %} | |
{% endif %} | |
{% if 'high_priority' in notify_data %} | |
{% set message.data = dict(message.data, **{ 'ttl': 0, 'priority': 'high' }) %} | |
{% endif %} | |
{% if 'channel' in notify_data %} | |
{% set message.data = dict(message.data, **{ 'channel': notify_channel }) %} | |
{% endif %} | |
{% if 'sticky' in notify_data %} | |
{% set message.data = dict(message.data, **{ 'sticky': "true" }) %} | |
{% endif %} | |
{% set actions = [ | |
{'action': action_button_to_do, 'title': action_button_to_do}, | |
{'action': action_button_cancel, 'title': action_button_cancel} | |
] %} | |
{% set message.data = dict(message.data, **{ 'actions': actions }) %} | |
{{ message.data }} | |
# Notify device option data with confirmation links to to-do | |
device_confirmation_message_data: >- | |
{% set message = namespace(data={}) %} | |
{% set push = namespace(data={}) %} | |
{% if notify_interruption_level in ['active', 'critical', 'time-sensitive', 'passive'] %} | |
{% set push.data = dict(push.data, **{ 'interruption-level': notify_interruption_level }) %} | |
{% endif %} | |
{% if notify_sound != [] %} | |
{% set push.data = dict(push.data, **{ 'sound': notify_sound }) %} | |
{% endif %} | |
{% if push.data %} | |
{% set message.data = dict(message.data, **{ 'push': push.data }) %} | |
{% endif %} | |
{% if 'high_priority' in notify_data %} | |
{% set message.data = dict(message.data, **{ 'ttl': 0, 'priority': 'high' }) %} | |
{% endif %} | |
{% if 'channel' in notify_data %} | |
{% set message.data = dict(message.data, **{ 'channel': notify_channel }) %} | |
{% endif %} | |
{% if 'sticky' in notify_data %} | |
{% set message.data = dict(message.data, **{ 'sticky': "true" }) %} | |
{% endif %} | |
{% set message.data = dict(message.data, **{ 'url': "/todo?entity_id=" ~ to_do_list, 'clickAction': "/todo?entity_id=" ~ to_do_list }) %} | |
{{ message.data }} | |
# Sensors to report in text message - default | |
all_sensors: >- | |
{% set low_battery = namespace(sensors=[]) %} | |
{% for state in states.sensor | |
| rejectattr('attributes.device_class', 'undefined') | |
| selectattr('attributes.device_class', '==', 'battery') %} | |
{% if 0 <= state.state | int(-1) <= battery_level | int and state.entity_id not in exclude_sensors.entity_id %} | |
{% set low_battery.sensors = low_battery.sensors + [state.name ~ ' @ ' ~ state.state ~ '%'] %} | |
{% endif %} | |
{% endfor %} | |
{% for state in states.binary_sensor | |
| rejectattr('attributes.device_class', 'undefined') | |
| selectattr('attributes.device_class', '==', 'battery') | |
| selectattr('state', 'in', ['on', 'low']) %} | |
{% if state.entity_id not in exclude_sensors.entity_id %} | |
{% set low_battery.sensors = low_battery.sensors + [state.name ~ ' is low!'] %} | |
{% endif %} | |
{% endfor %} | |
{% for state in states.sensor | |
| rejectattr('attributes.device_class', 'undefined') | |
| selectattr('attributes.device_class', '==', 'battery') | |
| selectattr('state', 'in', ['unavailable', 'unknown']) %} | |
{% if state.entity_id not in exclude_sensors.entity_id %} | |
{% set low_battery.sensors = low_battery.sensors + [state.name ~ ' is ' ~ state.state ~ '!'] %} | |
{% endif %} | |
{% endfor %} | |
{% for state in states.binary_sensor | |
| rejectattr('attributes.device_class', 'undefined') | |
| selectattr('attributes.device_class', '==', 'battery') | |
| selectattr('state', 'in', ['unavailable', 'unknown']) %} | |
{% if state.entity_id not in exclude_sensors.entity_id %} | |
{% set low_battery.sensors = low_battery.sensors + [state.name ~ ' is ' ~ state.state ~ '!'] %} | |
{% endif %} | |
{% endfor %} | |
{{ low_battery.sensors | join(', ') }} | |
sensors: >- | |
{% set low_battery = namespace(sensors=[]) %} | |
{% for state in states.sensor | |
| rejectattr('attributes.device_class', 'undefined') | |
| selectattr('attributes.device_class', '==', 'battery') %} | |
{% if 0 <= state.state | int(-1) <= battery_level | int and state.entity_id not in exclude_sensors.entity_id %} | |
{% set low_battery.sensors = low_battery.sensors + [state.name ~ ' @ ' ~ state.state ~ '%'] %} | |
{% endif %} | |
{% endfor %} | |
{% for state in states.binary_sensor | |
| rejectattr('attributes.device_class', 'undefined') | |
| selectattr('attributes.device_class', '==', 'battery') | |
| selectattr('state', 'in', ['on', 'low']) %} | |
{% if state.entity_id not in exclude_sensors.entity_id %} | |
{% set low_battery.sensors = low_battery.sensors + [state.name ~ ' is low!'] %} | |
{% endif %} | |
{% endfor %} | |
{{ low_battery.sensors | join(', ') }} | |
unavailable_sensors: >- | |
{% set low_battery = namespace(sensors=[]) %} | |
{% for state in states.sensor | |
| rejectattr('attributes.device_class', 'undefined') | |
| selectattr('attributes.device_class', '==', 'battery') | |
| selectattr('state', 'in', ['unavailable', 'unknown']) %} | |
{% if state.entity_id not in exclude_sensors.entity_id %} | |
{% set low_battery.sensors = low_battery.sensors + [state.name ~ ' is ' ~ state.state ~ '!'] %} | |
{% endif %} | |
{% endfor %} | |
{% for state in states.binary_sensor | |
| rejectattr('attributes.device_class', 'undefined') | |
| selectattr('attributes.device_class', '==', 'battery') | |
| selectattr('state', 'in', ['unavailable', 'unknown']) %} | |
{% if state.entity_id not in exclude_sensors.entity_id %} | |
{% set low_battery.sensors = low_battery.sensors + [state.name ~ ' is ' ~ state.state ~ '!'] %} | |
{% endif %} | |
{% endfor %} | |
{{ low_battery.sensors | join(', ') }} | |
# Sensors to report in voice message | |
sensors_names: >- | |
{% set low_battery = namespace(sensors=[]) %} | |
{% for state in states.sensor | |
| rejectattr('attributes.device_class', 'undefined') | |
| selectattr('attributes.device_class', '==', 'battery') %} | |
{% if 0 <= state.state | int(-1) <= battery_level | int and state.entity_id not in exclude_sensors.entity_id %} | |
{% set low_battery.sensors = low_battery.sensors + [state.name] %} | |
{% endif %} | |
{% endfor %} | |
{% for state in states.binary_sensor | |
| rejectattr('attributes.device_class', 'undefined') | |
| selectattr('attributes.device_class', '==', 'battery') | |
| selectattr('state', 'in', ['on', 'low']) %} | |
{% if state.entity_id not in exclude_sensors.entity_id %} | |
{% set low_battery.sensors = low_battery.sensors + [state.name] %} | |
{% endif %} | |
{% endfor %} | |
{{low_battery.sensors | join(', ')}} | |
unavailable_sensors_names: >- | |
{% set low_battery = namespace(sensors=[]) %} | |
{% for state in states.sensor | |
| rejectattr('attributes.device_class', 'undefined') | |
| selectattr('attributes.device_class', '==', 'battery') | |
| selectattr('state', 'in', ['unavailable', 'unknown']) %} | |
{% if state.entity_id not in exclude_sensors.entity_id %} | |
{% set low_battery.sensors = low_battery.sensors + [state.name] %} | |
{% endif %} | |
{% endfor %} | |
{% for state in states.binary_sensor | |
| rejectattr('attributes.device_class', 'undefined') | |
| selectattr('attributes.device_class', '==', 'battery') | |
| selectattr('state', 'in', ['unavailable', 'unknown']) %} | |
{% if state.entity_id not in exclude_sensors.entity_id %} | |
{% set low_battery.sensors = low_battery.sensors + [state.name] %} | |
{% endif %} | |
{% endfor %} | |
{{low_battery.sensors | join(', ')}} | |
# Battery sensors for custom group | |
all_sensors_custom_group: >- | |
{% set low_battery = namespace(sensors=[]) %} | |
{% for state in states.sensor | |
| rejectattr('attributes.device_class', 'undefined') | |
| selectattr('attributes.device_class', '==', 'battery') %} | |
{% if 0 <= state.state | int(-1) <= custom_group_battery_level | int and state.entity_id in custom_group.entity_id %} | |
{% set low_battery.sensors = low_battery.sensors + [state.name ~ ' @ ' ~ state.state ~ '%'] %} | |
{% endif %} | |
{% endfor %} | |
{% for state in states.binary_sensor | |
| rejectattr('attributes.device_class', 'undefined') | |
| selectattr('attributes.device_class', '==', 'battery') | |
| selectattr('state', 'in', ['on', 'low']) %} | |
{% if state.entity_id in custom_group.entity_id %} | |
{% set low_battery.sensors = low_battery.sensors + [state.name ~ ' is low!'] %} | |
{% endif %} | |
{% endfor %} | |
{% for state in states.sensor | |
| rejectattr('attributes.device_class', 'undefined') | |
| selectattr('attributes.device_class', '==', 'battery') | |
| selectattr('state', 'in', ['unavailable', 'unknown']) %} | |
{% if state.entity_id in custom_group.entity_id %} | |
{% set low_battery.sensors = low_battery.sensors + [state.name ~ ' is ' ~ state.state ~ '!'] %} | |
{% endif %} | |
{% endfor %} | |
{% for state in states.binary_sensor | |
| rejectattr('attributes.device_class', 'undefined') | |
| selectattr('attributes.device_class', '==', 'battery') | |
| selectattr('state', 'in', ['unavailable', 'unknown']) %} | |
{% if state.entity_id in custom_group.entity_id %} | |
{% set low_battery.sensors = low_battery.sensors + [state.name ~ ' is ' ~ state.state ~ '!'] %} | |
{% endif %} | |
{% endfor %} | |
{{ low_battery.sensors | join(', ') }} | |
sensors_custom_group: >- | |
{% set low_battery = namespace(sensors=[]) %} | |
{% for state in states.sensor | |
| rejectattr('attributes.device_class', 'undefined') | |
| selectattr('attributes.device_class', '==', 'battery') %} | |
{% if 0 <= state.state | int(-1) <= custom_group_battery_level | int and state.entity_id in custom_group.entity_id %} | |
{% set low_battery.sensors = low_battery.sensors + [state.name ~ ' @ ' ~ state.state ~ '%'] %} | |
{% endif %} | |
{% endfor %} | |
{% for state in states.binary_sensor | |
| rejectattr('attributes.device_class', 'undefined') | |
| selectattr('attributes.device_class', '==', 'battery') | |
| selectattr('state', 'in', ['on', 'low']) %} | |
{% if state.entity_id in custom_group.entity_id %} | |
{% set low_battery.sensors = low_battery.sensors + [state.name ~ ' is low!'] %} | |
{% endif %} | |
{% endfor %} | |
{{ low_battery.sensors | join(', ') }} | |
unavailable_sensors_custom_group: >- | |
{% set low_battery = namespace(sensors=[]) %} | |
{% for state in states.sensor | |
| rejectattr('attributes.device_class', 'undefined') | |
| selectattr('attributes.device_class', '==', 'battery') | |
| selectattr('state', 'in', ['unavailable', 'unknown']) %} | |
{% if state.entity_id in custom_group.entity_id %} | |
{% set low_battery.sensors = low_battery.sensors + [state.name ~ ' is ' ~ state.state ~ '!'] %} | |
{% endif %} | |
{% endfor %} | |
{% for state in states.binary_sensor | |
| rejectattr('attributes.device_class', 'undefined') | |
| selectattr('attributes.device_class', '==', 'battery') | |
| selectattr('state', 'in', ['unavailable', 'unknown']) %} | |
{% if state.entity_id in custom_group.entity_id %} | |
{% set low_battery.sensors = low_battery.sensors + [state.name ~ ' is ' ~ state.state ~ '!'] %} | |
{% endif %} | |
{% endfor %} | |
{{ low_battery.sensors | join(', ') }} | |
# Sensors to report in voice message custom group | |
sensors_names_custom_group: >- | |
{% set low_battery = namespace(sensors=[]) %} | |
{% for state in states.sensor | |
| rejectattr('attributes.device_class', 'undefined') | |
| selectattr('attributes.device_class', '==', 'battery') %} | |
{% if 0 <= state.state | int(-1) <= custom_group_battery_level | int and state.entity_id in custom_group.entity_id %} | |
{% set low_battery.sensors = low_battery.sensors + [state.name] %} | |
{% endif %} | |
{% endfor %} | |
{% for state in states.binary_sensor | |
| rejectattr('attributes.device_class', 'undefined') | |
| selectattr('attributes.device_class', '==', 'battery') | |
| selectattr('state', 'in', ['on', 'low']) %} | |
{% if state.entity_id in custom_group.entity_id %} | |
{% set low_battery.sensors = low_battery.sensors + [state.name] %} | |
{% endif %} | |
{% endfor %} | |
{{ low_battery.sensors | join(', ') }} | |
unavailable_sensors_names_custom_group: >- | |
{% set low_battery = namespace(sensors=[]) %} | |
{% for state in states.sensor | |
| rejectattr('attributes.device_class', 'undefined') | |
| selectattr('attributes.device_class', '==', 'battery') | |
| selectattr('state', 'in', ['unavailable', 'unknown']) %} | |
{% if state.entity_id in custom_group.entity_id %} | |
{% set low_battery.sensors = low_battery.sensors + [state.name] %} | |
{% endif %} | |
{% endfor %} | |
{% for state in states.binary_sensor | |
| rejectattr('attributes.device_class', 'undefined') | |
| selectattr('attributes.device_class', '==', 'battery') | |
| selectattr('state', 'in', ['unavailable', 'unknown']) %} | |
{% if state.entity_id in custom_group.entity_id %} | |
{% set low_battery.sensors = low_battery.sensors + [state.name] %} | |
{% endif %} | |
{% endfor %} | |
{{ low_battery.sensors | join(', ') }} | |
# Sensors for the easy notify message | |
easy_notify_message: >- | |
{% set low_battery = namespace(sensors=[]) %} | |
{% if sensor_selection == 'enable_battery_sensors_custom_group' and notify_message == 'all_sensors' %} | |
{{all_sensors_custom_group|replace(', ', '\n')}} | |
{% elif sensor_selection == 'enable_battery_sensors_custom_group' and notify_message == 'sensors'%} | |
{{sensors_custom_group|replace(', ', '\n')}} | |
{% elif sensor_selection == 'enable_battery_sensors_custom_group' and notify_message == 'unavailable_sensors'%} | |
{{unavailable_sensors_custom_group|replace(', ', '\n')}} | |
{% elif sensor_selection == 'enable_all_sensors' and notify_message == 'all_sensors' %} | |
{{all_sensors|replace(', ', '\n')}} | |
{% elif sensor_selection == 'enable_all_sensors' and notify_message == 'sensors'%} | |
{{sensors|replace(', ', '\n')}} | |
{% elif sensor_selection == 'enable_all_sensors' and notify_message == 'unavailable_sensors'%} | |
{{unavailable_sensors|replace(', ', '\n')}} | |
{% elif sensor_selection == 'enable_all_and_custom_group_sensors' and notify_message == 'all_sensors' %} | |
{{all_sensors|replace(', ', '\n')}}{{'\n'}}{{all_sensors_custom_group|replace(', ', '\n')}} | |
{% elif sensor_selection == 'enable_all_and_custom_group_sensors' and notify_message == 'sensors'%} | |
{{sensors|replace(', ', '\n')}}{{'\n'}}{{sensors_custom_group|replace(', ', '\n')}} | |
{% elif sensor_selection == 'enable_all_and_custom_group_sensors' and notify_message == 'unavailable_sensors'%} | |
{{unavailable_sensors|replace(', ', '\n')}}{{'\n'}}{{unavailable_sensors_custom_group|replace(', ', '\n')}} | |
{% else %} | |
[] | |
{% endif %} | |
triggers: | |
- trigger: state | |
entity_id: !input button_entity | |
id: 't0' | |
- trigger: time | |
at: !input time | |
id: 't1' | |
# All Conditions | |
condition: | |
#Trigger conditions | |
- condition: or | |
conditions: | |
- condition: and # trigger by button helper | |
conditions: | |
- condition: trigger | |
id: 't0' | |
- "{{ include_button == 'enable_button_trigger' }}" | |
- condition: and # trigger by time | |
conditions: | |
- condition: trigger | |
id: 't1' | |
- "{{ include_time == 'time_enabled' }}" | |
# Check The Weekday Option | |
- condition: or | |
conditions: | |
- "{{ include_time == 'time_disabled' }}" | |
- condition: and | |
conditions: | |
- condition: time | |
weekday: !input weekday_options | |
- "{{ include_time == 'time_enabled' }}" | |
- condition: trigger | |
id: 't0' | |
# Global Conditions | |
- condition: and | |
conditions: !input global_conditions | |
action: | |
- choose: | |
- alias: "Perform the custom actions" | |
conditions: | |
- condition: template | |
value_template: "{{ include_custom_actions == 'enable_custom_actions' }}" | |
sequence: !input custom_actions | |
- choose: | |
- alias: "Use the easy notify options" | |
conditions: | |
- condition: template | |
value_template: "{{ (include_easy_notify == 'enable_easy_notify') or (include_easy_notify == 'enable_easy_okay_notify') }}" | |
- condition: template | |
value_template: "{{ notify_device | length > 0 }}" | |
sequence: | |
- alias: "Send a notification to each device" | |
repeat: | |
for_each: !input notify_device | |
sequence: | |
- choose: | |
- alias: "Sensors have been found" | |
conditions: | |
- "{{ easy_notify_message != '' }}" | |
sequence: | |
- choose: | |
- alias: "Easy notify with no action button" | |
conditions: | |
- "{{ notify_action_buttons == 'disabled_notify_action_buttons' }}" | |
sequence: | |
- action: "notify.mobile_app_{{ device_attr(repeat.item, 'name') | slugify }}" | |
data: | |
title: !input notify_title | |
message: "{{easy_notify_message}}" | |
data: "{{ device_message_data }}" | |
- alias: "Easy notify with action button" | |
conditions: | |
- "{{ notify_action_buttons != 'disabled_notify_action_buttons' }}" | |
sequence: | |
- action: "notify.mobile_app_{{ device_attr(repeat.item, 'name') | slugify }}" | |
data: | |
title: !input notify_title | |
message: "{{easy_notify_message}}" | |
data: "{{ device_message_data_action_button }}" | |
- alias: "No sensors have been found" | |
conditions: | |
- "{{ easy_notify_message == '' }}" | |
- "{{ include_easy_notify == 'enable_easy_okay_notify' }}" | |
sequence: | |
- action: "notify.mobile_app_{{ device_attr(repeat.item, 'name') | slugify }}" | |
data: | |
title: !input notify_title | |
message: !input notify_okay_message | |
data: "{{ device_message_data }}" | |
- choose: | |
- alias: "Use the easy notify persistent notification options" | |
conditions: | |
- condition: template | |
value_template: "{{ (include_persistent_notification == 'enable_persistent_notification') or (include_persistent_notification == 'enable_persistent_okay_notification') }}" | |
sequence: | |
- choose: | |
- alias: "Sensors have been found" | |
conditions: | |
- "{{ easy_notify_message != '' }}" | |
sequence: | |
- action: persistent_notification.create | |
data: | |
title: "🪫 {{notify_title}}" | |
message: "{{easy_notify_message}}" | |
- alias: "No sensors have been found" | |
conditions: | |
- "{{ easy_notify_message == '' }}" | |
- "{{ include_persistent_notification == 'enable_persistent_okay_notification' }}" | |
sequence: | |
- action: persistent_notification.create | |
data: | |
title: "🪫 {{notify_title}}" | |
message: !input notify_okay_message | |
- choose: | |
- alias: "Check if the To-Do action button is enabled" | |
conditions: | |
- condition: template | |
value_template: "{{ (include_easy_notify == 'enable_easy_notify') or (include_easy_notify == 'enable_easy_okay_notify') }}" | |
- condition: template | |
value_template: "{{(notify_action_buttons == 'enable_to_do_list_button') or (notify_action_buttons == 'enable_to_do_list_button_and_confirmation')}}" | |
- condition: template | |
value_template: "{{ notify_device | length > 0 }}" | |
sequence: | |
- alias: "Wait for a response from the action buttons" | |
wait_for_trigger: | |
- trigger: event | |
event_type: mobile_app_notification_action | |
event_data: | |
action: "{{ action_button_to_do }}" | |
- trigger: event | |
event_type: mobile_app_notification_action | |
event_data: | |
action: "{{ action_button_cancel }}" | |
- choose: | |
- alias: "Check if confirmation message is disabled" | |
conditions: | |
- condition: template | |
value_template: "{{ notify_action_buttons == 'enable_to_do_list_button' }}" | |
sequence: | |
- if: | |
- alias: "Confirmation from the action buttons" | |
condition: template | |
value_template: "{{ wait.trigger.idx is defined }}" | |
then: | |
- alias: "Perform the chosen actions" | |
choose: | |
- conditions: "{{ wait.trigger.event.data.action == action_button_to_do }}" | |
sequence: | |
- alias: "Add task to To-Do list" | |
action: todo.add_item | |
metadata: {} | |
data: | |
item: !input to_do_task_title | |
description: "{{easy_notify_message}}" | |
target: | |
entity_id: !input to_do_list | |
- conditions: "{{ wait.trigger.event.data.action == action_button_cancel }}" | |
sequence: | |
- stop: "Stop the automation" | |
- alias: "Check if confirmation message is enabled" | |
conditions: | |
- condition: template | |
value_template: "{{ notify_action_buttons == 'enable_to_do_list_button_and_confirmation' }}" | |
sequence: | |
- if: | |
- alias: "Confirmation from the action buttons" | |
condition: template | |
value_template: "{{ wait.trigger.idx is defined }}" | |
then: | |
- alias: "Perform the chosen actions" | |
choose: | |
- conditions: "{{ wait.trigger.event.data.action == action_button_to_do }}" | |
sequence: | |
- alias: "Add task to To-Do list" | |
action: todo.add_item | |
metadata: {} | |
data: | |
item: !input to_do_task_title | |
description: "{{easy_notify_message}}" | |
target: | |
entity_id: !input to_do_list | |
- alias: "Send a notification to each device" | |
repeat: | |
for_each: !input notify_device | |
sequence: | |
- action: "notify.mobile_app_{{ device_attr(repeat.item, 'name') | slugify }}" | |
data: | |
title: !input action_button_confirmation_title | |
message: !input action_button_confirmation_message | |
data: "{{ device_confirmation_message_data }}" | |
- conditions: "{{ wait.trigger.event.data.action == action_button_cancel }}" | |
sequence: | |
- alias: "Send a notification to each device" | |
repeat: | |
for_each: !input notify_device | |
sequence: | |
- action: "notify.mobile_app_{{ device_attr(repeat.item, 'name') | slugify }}" | |
data: | |
title: !input action_button_confirmation_title | |
message: !input cancel_action_button_confirmation_message | |
data: "{{ device_message_data }}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
the icon is just a "🪫", how to fix it? thanks!