Last active
February 25, 2026 10:14
-
-
Save Ltek/0e340b6ace16e85fac7b2c6a8069f118 to your computer and use it in GitHub Desktop.
Home Assistant Blueprint : Battery Report Notifications & Actions by LTek
This file contains hidden or 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: "🔋 Battery Report with Notification Actions" | |
| description: | | |
| 🔋 Battery Report with Notification Actions | |
| Author: LTek | |
| 🚀 Version 2026.02.12.12c | |
| - Added: Independent To-Do List options (Entity IDs, Friendly Names, Both) | |
| - Fixed: Stray quotes appearing in notification fallback messages | |
| - Fixed: custom_group_combined empty-check when both sensor groups are empty | |
| - Recent Fix: To-Do list and No-Issues Confirmation messages | |
| ***Features*** | |
| 📢 Notifications with list of entities with Battery status of Low, Unavailable, Unknown | |
| - Persistent Web UI (bell icon) dashboard notifications | |
| - Mobile Device Notifications | |
| ⚡ Execution methods | |
| - Schedule Time and Day(s) | |
| - Manual trigger via button | |
| 🚫️ Entity exclusion options | |
| - Directly select specific entities | |
| - Pattern-based exclusions using text strings | |
| - Case-sensitive matching for precise control | |
| - Include or Exclude entities with Visability disabled in HA (hidden entities) | |
| - Some Template Entities may cause problems or errors due to how HA processes them. Exclude those entities if you have problems or disable Visability for them in HA's settings. | |
| 📈 Flexible display formats | |
| - Friendly names only | |
| - Entity IDs only | |
| - Combined format (Friendly Name + Entity ID) | |
| 🛠 To-Do List Options | |
| - Auto Create To-Do task list, populated with battert report | |
| - Mobile Notification option to create To-Do task | |
| 🐛 Debug Mode (Short-term troubleshooting only) | |
| 📖 Community Discussion and Details here https://community.home-assistant.io/t/battery-report-with-notification-actions-by-ltek/918180 | |
| ** VARIABLES available to Notifications ** | |
| 🔧 Direct Input Variables | |
| - notify_title — Notification title | |
| - notify_okay_message — "No issues" message | |
| - action_button_to_do — Action button text | |
| - action_button_cancel — Cancel button text | |
| - action_button_confirmation_title — Confirmation title | |
| - action_button_confirmation_message — Confirmation message | |
| - cancel_action_button_confirmation_message — Cancel confirmation message | |
| - to_do_task_title — To-Do list task title | |
| - to_do_message_format — To-Do list content setting (All Issues/Low Only/Unavailable Only) | |
| 🔋 Battery Status Variables | |
| - all_sensors — All battery issues (Low + Unavailable/Unknown) with percentages | |
| - sensors — Low battery sensors with percentages | |
| - unavailable_sensors — Unavailable or Unknown battery sensors | |
| - easy_notify_message — Final notification message based on configuration | |
| 🏷️ Simplified Name Lists (No Percentages) | |
| - sensors_names — Low battery sensor names only | |
| - unavailable_sensors_names — Unavailable sensor names only | |
| 📦 Custom Group Variables | |
| - all_sensors_custom_group — All battery issues in the custom group | |
| - sensors_custom_group — Low battery sensors in the custom group | |
| - unavailable_sensors_custom_group — Unavailable sensors in the custom group | |
| - sensors_names_custom_group — Low battery sensor names in the custom group | |
| - unavailable_sensors_names_custom_group — Unavailable sensor names in the custom group | |
| ⚙️ Configuration Variables | |
| - notify_tag — Notification action tag | |
| - display_options — Notification display format setting | |
| - to_do_display_options — To-Do list display format setting | |
| - notify_interruption_level — iOS interruption level | |
| - notify_sound — iOS notification sound | |
| - notify_channel — Android notification channel | |
| ✅ Boolean Check | |
| - has_battery_issues — true if any battery issues exist, otherwise false | |
| domain: automation | |
| source_url: https://gist.github.com/Ltek/0e340b6ace16e85fac7b2c6a8069f118 | |
| input: | |
| trigger_settings: | |
| name: ⚡ Trigger Settings | |
| description: Enable at least one... Schedule or Button | |
| collapsed: true | |
| input: | |
| include_button: | |
| name: Use Button Trigger? | |
| description: Use this if you want to trigger the report using an input_button entity | |
| default: disable_button_trigger | |
| selector: | |
| select: | |
| options: | |
| - label: Enabled | |
| value: enable_button_trigger | |
| - label: Disabled | |
| value: disable_button_trigger | |
| custom_value: false | |
| multiple: false | |
| sort: false | |
| button_entity: | |
| name: Button Trigger Entity | |
| description: Button that will trigger the automation | |
| default: [] | |
| selector: | |
| entity: | |
| domain: | |
| - input_button | |
| multiple: false | |
| reorder: false | |
| include_time: | |
| name: Use Scheduled Reoccuring Report? | |
| description: Automatically runs based on the Days and Time set here | |
| default: time_disabled | |
| selector: | |
| select: | |
| options: | |
| - label: Enabled | |
| value: time_enabled | |
| - label: Disabled | |
| value: time_disabled | |
| custom_value: false | |
| multiple: false | |
| sort: false | |
| time: | |
| name: Set Reoccuring Time | |
| description: When to run automatic checks | |
| default: 05:00:00 | |
| selector: | |
| time: {} | |
| weekday_options: | |
| name: Set Reoccuring Days | |
| description: Must select at least one day when enabled | |
| 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 | |
| custom_value: false | |
| sort: false | |
| battery_settings: | |
| name: "🔋 Battery Monitoring Settings" | |
| description: Customize exactly what the Report to include, or exclude. | |
| collapsed: true | |
| input: | |
| include_hidden_entities: | |
| name: Include Hidden Entities | |
| description: Include or exclude entities with Visibility disabled in Home Assistant | |
| default: exclude_hidden | |
| selector: | |
| select: | |
| options: | |
| - label: Exclude Hidden Entities | |
| value: exclude_hidden | |
| - label: Include Hidden Entities | |
| value: include_hidden | |
| custom_value: false | |
| multiple: false | |
| sort: false | |
| battery_level: | |
| name: Battery Low Value Threshold | |
| description: Any battery level value equal to or under this will be considered low | |
| default: 20 | |
| selector: | |
| number: | |
| min: 1.0 | |
| max: 100.0 | |
| step: 1.0 | |
| unit_of_measurement: '%' | |
| mode: slider | |
| exclude_sensors: | |
| name: ➖ Excluded Entities | |
| description: Select sepecific Entities you do not want in the report | |
| default: | |
| entity_id: [] | |
| selector: | |
| target: | |
| entity: | |
| - device_class: | |
| - battery | |
| exclude_strings: | |
| name: ➖ Text Pattern Exclusions | |
| description: 'Exclude entities containing specific text | |
| Enter only one string per line | |
| CaSe SenSative! | |
| Examples: sensor.phone _battery temperature' | |
| default: '' | |
| selector: | |
| text: | |
| multiline: true | |
| multiple: false | |
| custom_group: | |
| name: ➕ Custom Battery Group | |
| description: Create special monitoring group | |
| default: | |
| entity_id: [] | |
| selector: | |
| target: | |
| entity: | |
| - device_class: | |
| - battery | |
| custom_group_battery_level: | |
| name: Custom Group Low Threshold | |
| description: Required value to be considered low | |
| default: 20 | |
| selector: | |
| number: | |
| min: 1.0 | |
| max: 100.0 | |
| step: 1.0 | |
| unit_of_measurement: '%' | |
| mode: slider | |
| notification_settings: | |
| name: "📢 Notification Settings" | |
| description: Configure alert preferences | |
| collapsed: true | |
| input: | |
| include_easy_notify: | |
| name: Device Notifications | |
| default: disabled_easy_notify | |
| selector: | |
| select: | |
| options: | |
| - label: Disabled | |
| value: disabled_easy_notify | |
| - label: Enabled | |
| value: enable_easy_notify | |
| - label: Enabled with No Issues confirmation | |
| value: enable_easy_okay_notify | |
| custom_value: false | |
| multiple: false | |
| sort: false | |
| notify_device: | |
| name: Devices to Notify | |
| description: Select at least one if Device Notifications are enabled | |
| default: [] | |
| selector: | |
| device: | |
| integration: mobile_app | |
| multiple: true | |
| notify_title: | |
| name: Notification Title | |
| default: Battery Report | |
| selector: | |
| text: | |
| multiple: false | |
| multiline: false | |
| sensor_selection: | |
| name: ' Sensor Selection' | |
| description: Select which sensors to include in 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 | |
| value: enable_all_sensors | |
| - label: Use All Battery Sensors Minus Excluded + Custom Group | |
| value: enable_all_and_custom_group_sensors | |
| custom_value: false | |
| multiple: false | |
| sort: false | |
| notify_message: | |
| name: Battery Issues to include in the Report | |
| default: all_sensors | |
| selector: | |
| select: | |
| options: | |
| - label: All Issues | |
| value: all_sensors | |
| - label: Only Low Batteries | |
| value: sensors | |
| - label: Only Unavailable | |
| value: unavailable_sensors | |
| custom_value: false | |
| multiple: false | |
| sort: false | |
| notify_okay_message: | |
| name: Confirmation Message when there are No Issues | |
| default: No battery issues to report | |
| selector: | |
| text: | |
| multiple: false | |
| multiline: false | |
| notify_interruption_level: | |
| name: iOS Interruption Level | |
| description: only for iOS | |
| default: active | |
| selector: | |
| select: | |
| 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 | |
| custom_value: false | |
| multiple: false | |
| sort: false | |
| notify_sound: | |
| name: iOS Notification Sound | |
| description: only for iOS | |
| default: '' | |
| selector: | |
| text: | |
| multiple: false | |
| multiline: false | |
| notify_data: | |
| name: Android Options | |
| description: Android-specific notification options | |
| default: [] | |
| selector: | |
| select: | |
| multiple: true | |
| options: | |
| - label: High Priority | |
| value: high_priority | |
| - label: Sticky Notification | |
| value: sticky | |
| - label: Notification Channel | |
| value: channel | |
| custom_value: false | |
| sort: false | |
| notify_channel: | |
| name: Android Notification Channel | |
| description: only for Android | |
| default: '' | |
| selector: | |
| text: | |
| multiple: false | |
| multiline: false | |
| include_persistent_notification: | |
| name: Persistent Notification in the Home Assistant web UI (bell icon) | |
| default: disabled_persistent_notification | |
| selector: | |
| select: | |
| options: | |
| - label: Disabled | |
| value: disabled_persistent_notification | |
| - label: Enabled | |
| value: enable_persistent_notification | |
| - label: Enabled with No Issues confirmation | |
| value: enable_persistent_okay_notification | |
| custom_value: false | |
| multiple: false | |
| sort: false | |
| display_options: | |
| name: Report Info Display Options | |
| description: What info do you want to see in the report | |
| default: friendly_names | |
| selector: | |
| select: | |
| options: | |
| - label: Entity IDs | |
| value: entity_ids | |
| - label: Friendly Names | |
| value: friendly_names | |
| - label: Both | |
| value: both | |
| custom_value: false | |
| multiple: false | |
| sort: false | |
| action_buttons_settings: | |
| name: "🛠 To-Do Settings" | |
| description: Configure notification actions | |
| collapsed: true | |
| input: | |
| auto_add_to_do: | |
| name: Automatically Add Report to To-Do List | |
| description: Automatically create a To-Do item (no button press needed) | |
| default: disable_auto_add_to_do | |
| selector: | |
| select: | |
| options: | |
| - label: Disabled | |
| value: disable_auto_add_to_do | |
| - label: Enabled | |
| value: enable_auto_add_to_do | |
| custom_value: false | |
| multiple: false | |
| sort: false | |
| notify_tag: | |
| name: Notification Action Tag | |
| description: A unique tag to identify the action buttons for this notification. | |
| Notifications using the same Tag will overwrite prior notifications. Good for when you want to only see the latest report, not historicals. | |
| default: battery_report_action | |
| selector: | |
| text: | |
| multiple: false | |
| multiline: false | |
| notify_action_buttons: | |
| name: Mobile Device Notification To-Do Action Button | |
| description: You can decide to, or not to, add the report to the To-Do list. Best used when you do not have "Automatically Add Report to To-Do List" enabled. | |
| default: disabled_notify_action_buttons | |
| selector: | |
| select: | |
| options: | |
| - label: Disabled | |
| value: disabled_notify_action_buttons | |
| - label: Add To-Do Button | |
| value: enable_to_do_list_button | |
| - label: Add To-Do with Confirmation | |
| value: enable_to_do_list_button_and_confirmation | |
| custom_value: false | |
| multiple: false | |
| sort: false | |
| to_do_list: | |
| name: Add Report to this To-Do List | |
| default: [] | |
| selector: | |
| entity: | |
| domain: | |
| - todo | |
| multiple: false | |
| reorder: false | |
| to_do_task_title: | |
| name: To-Do Task Title | |
| default: Replace Batteries | |
| selector: | |
| text: | |
| multiple: false | |
| multiline: false | |
| to_do_message_format: | |
| name: To-Do List Message Format | |
| description: Which battery issues to add to the To-Do list | |
| default: all_sensors | |
| selector: | |
| select: | |
| options: | |
| - label: All Issues | |
| value: all_sensors | |
| - label: Only Low Batteries | |
| value: sensors | |
| - label: Only Unavailable/Unknown | |
| value: unavailable_sensors | |
| custom_value: false | |
| multiple: false | |
| sort: false | |
| to_do_display_options: | |
| name: To-Do List Display Format | |
| description: What info to show for each device in the To-Do list | |
| default: entity_ids | |
| selector: | |
| select: | |
| options: | |
| - label: Entity IDs | |
| value: entity_ids | |
| - label: Friendly Names | |
| value: friendly_names | |
| - label: Both | |
| value: both | |
| custom_value: false | |
| multiple: false | |
| sort: false | |
| action_button_to_do: | |
| name: Mobile Action Button Text | |
| default: Add to To-Do List | |
| selector: | |
| text: | |
| multiple: false | |
| multiline: false | |
| action_button_cancel: | |
| name: Cancel Button Text | |
| default: Cancel | |
| selector: | |
| text: | |
| multiple: false | |
| multiline: false | |
| action_button_confirmation_title: | |
| name: Confirmation Message Title | |
| default: Action Confirmation | |
| selector: | |
| text: | |
| multiple: false | |
| multiline: false | |
| action_button_confirmation_message: | |
| name: Confirmation Message | |
| default: Task added to To-Do list | |
| selector: | |
| text: | |
| multiple: false | |
| multiline: false | |
| cancel_action_button_confirmation_message: | |
| name: Cancel Confirmation Message | |
| default: Action cancelled | |
| selector: | |
| text: | |
| multiple: false | |
| multiline: false | |
| custom_actions_settings: | |
| name: ⚡ Custom Actions | |
| description: Additional actions to run | |
| collapsed: true | |
| input: | |
| include_custom_actions: | |
| name: Enable Custom Actions | |
| default: disabled_custom_actions | |
| selector: | |
| select: | |
| options: | |
| - label: Enabled | |
| value: enable_custom_actions | |
| - label: Disabled | |
| value: disable_custom_actions | |
| custom_value: false | |
| multiple: false | |
| sort: false | |
| custom_actions: | |
| name: Custom Actions | |
| default: [] | |
| selector: | |
| action: {} | |
| global_conditions_settings: | |
| name: "🌍 Global Conditions" | |
| description: Additional conditions for automation | |
| collapsed: true | |
| input: | |
| global_conditions: | |
| name: Conditions | |
| default: [] | |
| selector: | |
| condition: {} | |
| debug_settings: | |
| name: "🐛 Debug Settings" | |
| description: Configure debug options | |
| collapsed: true | |
| input: | |
| include_logbook_debug: | |
| name: Enable Logbook Debug | |
| description: Enable or disable logging debug information | |
| default: enable_logbook_debug | |
| selector: | |
| select: | |
| options: | |
| - label: Enabled | |
| value: enable_logbook_debug | |
| - label: Disabled | |
| value: disable_logbook_debug | |
| custom_value: false | |
| multiple: false | |
| sort: false | |
| variables: | |
| include_button: !input include_button | |
| include_time: !input include_time | |
| weekday_options: !input weekday_options | |
| include_hidden_entities: !input include_hidden_entities | |
| battery_level: !input battery_level | |
| exclude_sensors: !input exclude_sensors | |
| exclude_strings: !input exclude_strings | |
| custom_group: !input custom_group | |
| custom_group_battery_level: !input custom_group_battery_level | |
| display_options: !input display_options | |
| include_easy_notify: !input include_easy_notify | |
| notify_device: !input notify_device | |
| notify_title: !input notify_title | |
| sensor_selection: !input sensor_selection | |
| 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 | |
| include_persistent_notification: !input include_persistent_notification | |
| notify_action_buttons: !input notify_action_buttons | |
| auto_add_to_do: !input auto_add_to_do | |
| notify_tag: !input notify_tag | |
| to_do_list: !input to_do_list | |
| to_do_task_title: !input to_do_task_title | |
| to_do_message_format: !input to_do_message_format | |
| to_do_display_options: !input to_do_display_options | |
| 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 | |
| exclude_regex: "{% if exclude_strings is defined %}\n {% set patterns = exclude_strings.split('\\n') | map('trim') | reject('eq', '') | list %}\n {{ patterns | join('|') if patterns else 'a^' }}\n{% else %}\n a^\n{% endif %}" | |
| all_exclude_sensors: "{% if exclude_sensors is defined %}\n {% set labels = label_entities(exclude_sensors.label_id) if exclude_sensors.label_id is defined and exclude_sensors.label_id else [] %}\n {% set entities = exclude_sensors.entity_id if exclude_sensors.entity_id is defined and exclude_sensors.entity_id else [] %}\n {{ (labels + entities) | unique | list }}\n{% else %}\n []\n{% endif %}" | |
| custom_group_sensors: "{% if custom_group is defined and (custom_group.entity_id | default([]) | length > 0 or custom_group.label_id | default([]) | length > 0) %}\n {% set labels = label_entities(custom_group.label_id) if custom_group.label_id is defined and custom_group.label_id else [] %}\n {% set entities = custom_group.entity_id if custom_group.entity_id is defined and custom_group.entity_id else [] %}\n {{ (labels + entities) | reject('search', exclude_regex) | unique | list }}\n{% else %}\n []\n{% endif %}" | |
| all_sensors: "{% if battery_level is defined and display_options is defined %}\n {% set results = namespace(items=[], count=0) %}\n {% for s in states.sensor | selectattr('attributes.device_class', '==', 'battery') %}\n {% if include_hidden_entities == 'exclude_hidden' %}\n {% set s = s if not is_hidden_entity(s.entity_id) else none %}\n {% endif %}\n {% if s and s.entity_id not in all_exclude_sensors and not s.entity_id is search(exclude_regex) %}\n {% if s.state not in ['unavailable','unknown'] and s.state | int(0) <= battery_level %}\n {% set results.count = results.count + 1 %}\n {% if display_options == 'entity_ids' %}\n {% set results.items = results.items + ['• ' ~ s.entity_id ~ ' @ ' ~ s.state ~ '%'] %}\n {% elif display_options == 'friendly_names' %}\n {% set results.items = results.items + ['• ' ~ s.name ~ ' @ ' ~ s.state ~ '%'] %}\n {% else %}\n {% set results.items = results.items + ['• ' ~ s.name ~ ' (' ~ s.entity_id ~ ') @ ' ~ s.state ~ '%'] %}\n {% endif %}\n {% elif s.state in ['unavailable','unknown'] %}\n {% set results.count = results.count + 1 %}\n {% if display_options == 'entity_ids' %}\n {% set results.items = results.items + ['• ' ~ s.entity_id ~ (' (unknown)' if s.state == 'unknown' else '')] %}\n {% elif display_options == 'friendly_names' %}\n {% set results.items = results.items + ['• ' ~ s.name ~ (' (unknown)' if s.state == 'unknown' else '')] %}\n {% else %}\n {% set results.items = results.items + ['• ' ~ s.name ~ ' (' ~ s.entity_id ~ ')' ~ (' (unknown)' if s.state == 'unknown' else '')] %}\n {% endif %}\n {% endif %}\n {% endif %}\n {% endfor %}\n {% for s in states.binary_sensor | selectattr('attributes.device_class', '==', 'battery') %}\n {% if include_hidden_entities == 'exclude_hidden' %}\n {% set s = s if not is_hidden_entity(s.entity_id) else none %}\n {% endif %}\n {% if s and s.entity_id not in all_exclude_sensors and not s.entity_id is search(exclude_regex) %}\n {% if s.state in ['on','low'] %}\n {% set results.count = results.count + 1 %}\n {% if display_options == 'entity_ids' %}\n {% set results.items = results.items + ['• ' ~ s.entity_id ~ ' is low'] %}\n {% elif display_options == 'friendly_names' %}\n {% set results.items = results.items + ['• ' ~ s.name ~ ' is low'] %}\n {% else %}\n {% set results.items = results.items + ['• ' ~ s.name ~ ' (' ~ s.entity_id ~ ') is low'] %}\n {% endif %}\n {% elif s.state in ['unavailable','unknown'] %}\n {% set results.count = results.count + 1 %}\n {% if display_options == 'entity_ids' %}\n {% set results.items = results.items + ['• ' ~ s.entity_id ~ (' (unknown)' if s.state == 'unknown' else '')] %}\n {% elif display_options == 'friendly_names' %}\n {% set results.items = results.items + ['• ' ~ s.name ~ (' (unknown)' if s.state == 'unknown' else '')] %}\n {% else %}\n {% set results.items = results.items + ['• ' ~ s.name ~ ' (' ~ s.entity_id ~ ')' ~ (' (unknown)' if s.state == 'unknown' else '')] %}\n {% endif %}\n {% endif %}\n {% endif %}\n {% endfor %}\n {% if results.count > 0 %}\n {{ '\\n' ~ results.count ~ ' Devices\\n\\n' ~ results.items | join('\\n') }}\n {% else %}\n ''\n {% endif %}\n{% else %}\n ''\n{% endif %}" | |
| sensors: "{% if battery_level is defined and display_options is defined %}\n {% set results = namespace(items=[], count=0) %}\n {% for s in states.sensor | selectattr('attributes.device_class', '==', 'battery') %}\n {% if include_hidden_entities == 'exclude_hidden' %}\n {% set s = s if not is_hidden_entity(s.entity_id) else none %}\n {% endif %}\n {% if s and s.entity_id not in all_exclude_sensors and not s.entity_id is search(exclude_regex) %}\n {% if s.state not in ['unavailable','unknown'] and s.state | int(0) <= battery_level %}\n {% set results.count = results.count + 1 %}\n {% if display_options == 'entity_ids' %}\n {% set results.items = results.items + ['• ' ~ s.entity_id ~ ' @ ' ~ s.state ~ '%'] %}\n {% elif display_options == 'friendly_names' %}\n {% set results.items = results.items + ['• ' ~ s.name ~ ' @ ' ~ s.state ~ '%'] %}\n {% else %}\n {% set results.items = results.items + ['• ' ~ s.name ~ ' (' ~ s.entity_id ~ ') @ ' ~ s.state ~ '%'] %}\n {% endif %}\n {% endif %}\n {% endif %}\n {% endfor %}\n {% for s in states.binary_sensor | selectattr('attributes.device_class', '==', 'battery') %}\n {% if include_hidden_entities == 'exclude_hidden' %}\n {% set s = s if not is_hidden_entity(s.entity_id) else none %}\n {% endif %}\n {% if s and s.entity_id not in all_exclude_sensors and not s.entity_id is search(exclude_regex) %}\n {% if s.state in ['on','low'] %}\n {% set results.count = results.count + 1 %}\n {% if display_options == 'entity_ids' %}\n {% set results.items = results.items + ['• ' ~ s.entity_id ~ ' is low'] %}\n {% elif display_options == 'friendly_names' %}\n {% set results.items = results.items + ['• ' ~ s.name ~ ' is low'] %}\n {% else %}\n {% set results.items = results.items + ['• ' ~ s.name ~ ' (' ~ s.entity_id ~ ') is low'] %}\n {% endif %}\n {% endif %}\n {% endif %}\n {% endfor %}\n {% if results.count > 0 %}\n {{ '\\n' ~ results.count ~ ' Low Battery Devices\\n\\n' ~ results.items | join('\\n') }}\n {% else %}\n ''\n {% endif %}\n{% else %}\n ''\n{% endif %}" | |
| unavailable_sensors: "{% if display_options is defined %}\n {% set results = namespace(items=[], count=0) %}\n {% for s in states.sensor | selectattr('attributes.device_class', '==', 'battery') %}\n {% if include_hidden_entities == 'exclude_hidden' %}\n {% set s = s if not is_hidden_entity(s.entity_id) else none %}\n {% endif %}\n {% if s and s.entity_id not in all_exclude_sensors and not s.entity_id is search(exclude_regex) %}\n {% if s.state in ['unavailable','unknown'] %}\n {% set results.count = results.count + 1 %}\n {% if display_options == 'entity_ids' %}\n {% set results.items = results.items + ['• ' ~ s.entity_id ~ (' (unknown)' if s.state == 'unknown' else '')] %}\n {% elif display_options == 'friendly_names' %}\n {% set results.items = results.items + ['• ' ~ s.name ~ (' (unknown)' if s.state == 'unknown' else '')] %}\n {% else %}\n {% set results.items = results.items + ['• ' ~ s.name ~ ' (' ~ s.entity_id ~ ')' ~ (' (unknown)' if s.state == 'unknown' else '')] %}\n {% endif %}\n {% endif %}\n {% endif %}\n {% endfor %}\n {% for s in states.binary_sensor | selectattr('attributes.device_class', '==', 'battery') %}\n {% if include_hidden_entities == 'exclude_hidden' %}\n {% set s = s if not is_hidden_entity(s.entity_id) else none %}\n {% endif %}\n {% if s and s.entity_id not in all_exclude_sensors and not s.entity_id is search(exclude_regex) %}\n {% if s.state in ['unavailable','unknown'] %}\n {% set results.count = results.count + 1 %}\n {% if display_options == 'entity_ids' %}\n {% set results.items = results.items + ['• ' ~ s.entity_id ~ (' (unknown)' if s.state == 'unknown' else '')] %}\n {% elif display_options == 'friendly_names' %}\n {% set results.items = results.items + ['• ' ~ s.name ~ (' (unknown)' if s.state == 'unknown' else '')] %}\n {% else %}\n {% set results.items = results.items + ['• ' ~ s.name ~ ' (' ~ s.entity_id ~ ')' ~ (' (unknown)' if s.state == 'unknown' else '')] %}\n {% endif %}\n {% endif %}\n {% endif %}\n {% endfor %}\n {% if results.count > 0 %}\n {{ '\\n' ~ results.count ~ ' Unavailable Devices\\n\\n' ~ results.items | join('\\n') }}\n {% else %}\n ''\n {% endif %}\n{% else %}\n ''\n{% endif %}" | |
| all_sensors_custom_group: "{% if custom_group is defined and (custom_group.entity_id | default([]) | length > 0 or custom_group.label_id | default([]) | length > 0) and custom_group_battery_level is defined and display_options is defined %}\n {% set results = namespace(items=[], count=0) %}\n {% for s in states.sensor | selectattr('attributes.device_class', '==', 'battery') %}\n {% if include_hidden_entities == 'exclude_hidden' %}\n {% set s = s if not is_hidden_entity(s.entity_id) else none %}\n {% endif %}\n {% if s and s.entity_id in custom_group_sensors %}\n {% if s.state not in ['unavailable','unknown'] and s.state | int(0) <= custom_group_battery_level %}\n {% set results.count = results.count + 1 %}\n {% if display_options == 'entity_ids' %}\n {% set results.items = results.items + ['• ' ~ s.entity_id ~ ' @ ' ~ s.state ~ '%'] %}\n {% elif display_options == 'friendly_names' %}\n {% set results.items = results.items + ['• ' ~ s.name ~ ' @ ' ~ s.state ~ '%'] %}\n {% else %}\n {% set results.items = results.items + ['• ' ~ s.name ~ ' (' ~ s.entity_id ~ ') @ ' ~ s.state ~ '%'] %}\n {% endif %}\n {% elif s.state in ['unavailable','unknown'] %}\n {% set results.count = results.count + 1 %}\n {% if display_options == 'entity_ids' %}\n {% set results.items = results.items + ['• ' ~ s.entity_id ~ (' (unknown)' if s.state == 'unknown' else '')] %}\n {% elif display_options == 'friendly_names' %}\n {% set results.items = results.items + ['• ' ~ s.name ~ (' (unknown)' if s.state == 'unknown' else '')] %}\n {% else %}\n {% set results.items = results.items + ['• ' ~ s.name ~ ' (' ~ s.entity_id ~ ')' ~ (' (unknown)' if s.state == 'unknown' else '')] %}\n {% endif %}\n {% endif %}\n {% endif %}\n {% endfor %}\n {% for s in states.binary_sensor | selectattr('attributes.device_class', '==', 'battery') %}\n {% if include_hidden_entities == 'exclude_hidden' %}\n {% set s = s if not is_hidden_entity(s.entity_id) else none %}\n {% endif %}\n {% if s and s.entity_id in custom_group_sensors %}\n {% if s.state in ['on','low'] %}\n {% set results.count = results.count + 1 %}\n {% if display_options == 'entity_ids' %}\n {% set results.items = results.items + ['• ' ~ s.entity_id ~ ' is low'] %}\n {% elif display_options == 'friendly_names' %}\n {% set results.items = results.items + ['• ' ~ s.name ~ ' is low'] %}\n {% else %}\n {% set results.items = results.items + ['• ' ~ s.name ~ ' (' ~ s.entity_id ~ ') is low'] %}\n {% endif %}\n {% elif s.state in ['unavailable','unknown'] %}\n {% set results.count = results.count + 1 %}\n {% if display_options == 'entity_ids' %}\n {% set results.items = results.items + ['• ' ~ s.entity_id ~ (' (unknown)' if s.state == 'unknown' else '')] %}\n {% elif display_options == 'friendly_names' %}\n {% set results.items = results.items + ['• ' ~ s.name ~ (' (unknown)' if s.state == 'unknown' else '')] %}\n {% else %}\n {% set results.items = results.items + ['• ' ~ s.name ~ ' (' ~ s.entity_id ~ ')' ~ (' (unknown)' if s.state == 'unknown' else '')] %}\n {% endif %}\n {% endif %}\n {% endif %}\n {% endfor %}\n {% if results.count > 0 %}\n {{ '\\n' ~ results.count ~ ' Devices in Custom Group\\n\\n' ~ results.items | join('\\n') }}\n {% else %}\n ''\n {% endif %}\n{% else %}\n ''\n{% endif %}" | |
| sensors_custom_group: "{% if custom_group is defined and (custom_group.entity_id | default([]) | length > 0 or custom_group.label_id | default([]) | length > 0) and custom_group_battery_level is defined and display_options is defined %}\n {% set results = namespace(items=[], count=0) %}\n {% for s in states.sensor | selectattr('attributes.device_class', '==', 'battery') %}\n {% if include_hidden_entities == 'exclude_hidden' %}\n {% set s = s if not is_hidden_entity(s.entity_id) else none %}\n {% endif %}\n {% if s and s.entity_id in custom_group_sensors %}\n {% if s.state not in ['unavailable','unknown'] and s.state | int(0) <= custom_group_battery_level %}\n {% set results.count = results.count + 1 %}\n {% if display_options == 'entity_ids' %}\n {% set results.items = results.items + ['• ' ~ s.entity_id ~ ' @ ' ~ s.state ~ '%'] %}\n {% elif display_options == 'friendly_names' %}\n {% set results.items = results.items + ['• ' ~ s.name ~ ' @ ' ~ s.state ~ '%'] %}\n {% else %}\n {% set results.items = results.items + ['• ' ~ s.name ~ ' (' ~ s.entity_id ~ ') @ ' ~ s.state ~ '%'] %}\n {% endif %}\n {% endif %}\n {% endif %}\n {% endfor %}\n {% for s in states.binary_sensor | selectattr('attributes.device_class', '==', 'battery') %}\n {% if include_hidden_entities == 'exclude_hidden' %}\n {% set s = s if not is_hidden_entity(s.entity_id) else none %}\n {% endif %}\n {% if s and s.entity_id in custom_group_sensors %}\n {% if s.state in ['on','low'] %}\n {% set results.count = results.count + 1 %}\n {% if display_options == 'entity_ids' %}\n {% set results.items = results.items + ['• ' ~ s.entity_id ~ ' is low'] %}\n {% elif display_options == 'friendly_names' %}\n {% set results.items = results.items + ['• ' ~ s.name ~ ' is low'] %}\n {% else %}\n {% set results.items = results.items + ['• ' ~ s.name ~ ' (' ~ s.entity_id ~ ') is low'] %}\n {% endif %}\n {% endif %}\n {% endif %}\n {% endfor %}\n {% if results.count > 0 %}\n {{ '\\n' ~ results.count ~ ' Devices in Custom Group (Low Battery)\\n\\n' ~ results.items | join('\\n') }}\n {% else %}\n ''\n {% endif %}\n{% else %}\n ''\n{% endif %}" | |
| unavailable_sensors_custom_group: "{% if custom_group is defined and (custom_group.entity_id | default([]) | length > 0 or custom_group.label_id | default([]) | length > 0) and display_options is defined %}\n {% set results = namespace(items=[], count=0) %}\n {% for s in states.sensor | selectattr('attributes.device_class', '==', 'battery') %}\n {% if include_hidden_entities == 'exclude_hidden' %}\n {% set s = s if not is_hidden_entity(s.entity_id) else none %}\n {% endif %}\n {% if s and s.entity_id in custom_group_sensors %}\n {% if s.state in ['unavailable','unknown'] %}\n {% set results.count = results.count + 1 %}\n {% if display_options == 'entity_ids' %}\n {% set results.items = results.items + ['• ' ~ s.entity_id ~ (' (unknown)' if s.state == 'unknown' else '')] %}\n {% elif display_options == 'friendly_names' %}\n {% set results.items = results.items + ['• ' ~ s.name ~ (' (unknown)' if s.state == 'unknown' else '')] %}\n {% else %}\n {% set results.items = results.items + ['• ' ~ s.name ~ ' (' ~ s.entity_id ~ ')' ~ (' (unknown)' if s.state == 'unknown' else '')] %}\n {% endif %}\n {% endif %}\n {% endif %}\n {% endfor %}\n {% for s in states.binary_sensor | selectattr('attributes.device_class', '==', 'battery') %}\n {% if include_hidden_entities == 'exclude_hidden' %}\n {% set s = s if not is_hidden_entity(s.entity_id) else none %}\n {% endif %}\n {% if s and s.entity_id in custom_group_sensors %}\n {% if s.state in ['unavailable','unknown'] %}\n {% set results.count = results.count + 1 %}\n {% if display_options == 'entity_ids' %}\n {% set results.items = results.items + ['• ' ~ s.entity_id ~ (' (unknown)' if s.state == 'unknown' else '')] %}\n {% elif display_options == 'friendly_names' %}\n {% set results.items = results.items + ['• ' ~ s.name ~ (' (unknown)' if s.state == 'unknown' else '')] %}\n {% else %}\n {% set results.items = results.items + ['• ' ~ s.name ~ ' (' ~ s.entity_id ~ ')' ~ (' (unknown)' if s.state == 'unknown' else '')] %}\n {% endif %}\n {% endif %}\n {% endif %}\n {% endfor %}\n {% if results.count > 0 %}\n {{ '\\n' ~ results.count ~ ' Devices in Custom Group (Unavailable)\\n\\n' ~ results.items | join('\\n') }}\n {% else %}\n ''\n {% endif %}\n{% else %}\n ''\n{% endif %}" | |
| sensors_names: "{% if battery_level is defined and display_options is defined %}\n {% set results = namespace(items=[], count=0) %}\n {% for s in states.sensor | selectattr('attributes.device_class', '==', 'battery') %}\n {% if include_hidden_entities == 'exclude_hidden' %}\n {% set s = s if not is_hidden_entity(s.entity_id) else none %}\n {% endif %}\n {% if s and s.entity_id not in all_exclude_sensors and not s.entity_id is search(exclude_regex) %}\n {% if s.state not in ['unavailable','unknown'] and s.state | int(0) <= battery_level %}\n {% set results.count = results.count + 1 %}\n {% if display_options == 'entity_ids' %}\n {% set results.items = results.items + ['• ' ~ s.entity_id] %}\n {% elif display_options == 'friendly_names' %}\n {% set results.items = results.items + ['• ' ~ s.name] %}\n {% else %}\n {% set results.items = results.items + ['• ' ~ s.name ~ ' (' ~ s.entity_id ~ ')'] %}\n {% endif %}\n {% endif %}\n {% endif %}\n {% endfor %}\n {% for s in states.binary_sensor | selectattr('attributes.device_class', '==', 'battery') %}\n {% if include_hidden_entities == 'exclude_hidden' %}\n {% set s = s if not is_hidden_entity(s.entity_id) else none %}\n {% endif %}\n {% if s and s.entity_id not in all_exclude_sensors and not s.entity_id is search(exclude_regex) %}\n {% if s.state in ['on','low'] %}\n {% set results.count = results.count + 1 %}\n {% if display_options == 'entity_ids' %}\n {% set results.items = results.items + ['• ' ~ s.entity_id] %}\n {% elif display_options == 'friendly_names' %}\n {% set results.items = results.items + ['• ' ~ s.name] %}\n {% else %}\n {% set results.items = results.items + ['• ' ~ s.name ~ ' (' ~ s.entity_id ~ ')'] %}\n {% endif %}\n {% endif %}\n {% endif %}\n {% endfor %}\n {% if results.count > 0 %}\n {{ '\\n' ~ results.count ~ ' Devices (Low Battery)\\n\\n' ~ results.items | join('\\n') }}\n {% else %}\n ''\n {% endif %}\n{% else %}\n ''\n{% endif %}" | |
| unavailable_sensors_names: "{% if display_options is defined %}\n {% set results = namespace(items=[], count=0) %}\n {% for s in states.sensor | selectattr('attributes.device_class', '==', 'battery') %}\n {% if include_hidden_entities == 'exclude_hidden' %}\n {% set s = s if not is_hidden_entity(s.entity_id) else none %}\n {% endif %}\n {% if s and s.entity_id not in all_exclude_sensors and not s.entity_id is search(exclude_regex) %}\n {% if s.state in ['unavailable','unknown'] %}\n {% set results.count = results.count + 1 %}\n {% if display_options == 'entity_ids' %}\n {% set results.items = results.items + ['• ' ~ s.entity_id ~ (' (unknown)' if s.state == 'unknown' else '')] %}\n {% elif display_options == 'friendly_names' %}\n {% set results.items = results.items + ['• ' ~ s.name ~ (' (unknown)' if s.state == 'unknown' else '')] %}\n {% else %}\n {% set results.items = results.items + ['• ' ~ s.name ~ ' (' ~ s.entity_id ~ ')' ~ (' (unknown)' if s.state == 'unknown' else '')] %}\n {% endif %}\n {% endif %}\n {% endif %}\n {% endfor %}\n {% for s in states.binary_sensor | selectattr('attributes.device_class', '==', 'battery') %}\n {% if include_hidden_entities == 'exclude_hidden' %}\n {% set s = s if not is_hidden_entity(s.entity_id) else none %}\n {% endif %}\n {% if s and s.entity_id not in all_exclude_sensors and not s.entity_id is search(exclude_regex) %}\n {% if s.state in ['unavailable','unknown'] %}\n {% set results.count = results.count + 1 %}\n {% if display_options == 'entity_ids' %}\n {% set results.items = results.items + ['• ' ~ s.entity_id ~ (' (unknown)' if s.state == 'unknown' else '')] %}\n {% elif display_options == 'friendly_names' %}\n {% set results.items = results.items + ['• ' ~ s.name ~ (' (unknown)' if s.state == 'unknown' else '')] %}\n {% else %}\n {% set results.items = results.items + ['• ' ~ s.name ~ ' (' ~ s.entity_id ~ ')' ~ (' (unknown)' if s.state == 'unknown' else '')] %}\n {% endif %}\n {% endif %}\n {% endif %}\n {% endfor %}\n {% if results.count > 0 %}\n {{ '\\n' ~ results.count ~ ' Devices (Unavailable)\\n\\n' ~ results.items | join('\\n') }}\n {% else %}\n ''\n {% endif %}\n{% else %}\n ''\n{% endif %}" | |
| sensors_entity_ids_semicolon: "{% if battery_level is defined %}\n {% set results = namespace(items=[]) %}\n {% for s in states.sensor | selectattr('attributes.device_class', '==', 'battery') %}\n {% if include_hidden_entities == 'exclude_hidden' %}\n {% set s = s if not is_hidden_entity(s.entity_id) else none %}\n {% endif %}\n {% if s and s.entity_id not in all_exclude_sensors and not s.entity_id is search(exclude_regex) %}\n {% if s.state not in ['unavailable','unknown'] and s.state | int(0) <= battery_level %}\n {% set results.items = results.items + [s.entity_id] %}\n {% endif %}\n {% endif %}\n {% endfor %}\n {% for s in states.binary_sensor | selectattr('attributes.device_class', '==', 'battery') %}\n {% if include_hidden_entities == 'exclude_hidden' %}\n {% set s = s if not is_hidden_entity(s.entity_id) else none %}\n {% endif %}\n {% if s and s.entity_id not in all_exclude_sensors and not s.entity_id is search(exclude_regex) %}\n {% if s.state in ['on','low'] %}\n {% set results.items = results.items + [s.entity_id] %}\n {% endif %}\n {% endif %}\n {% endfor %}\n {{ results.items | join('; ') if results.items else '' }}\n{% else %}\n ''\n{% endif %}" | |
| unavailable_sensors_entity_ids_semicolon: "{% set results = namespace(items=[]) %}\n {% for s in states.sensor | selectattr('attributes.device_class', '==', 'battery') %}\n {% if include_hidden_entities == 'exclude_hidden' %}\n {% set s = s if not is_hidden_entity(s.entity_id) else none %}\n {% endif %}\n {% if s and s.entity_id not in all_exclude_sensors and not s.entity_id is search(exclude_regex) %}\n {% if s.state in ['unavailable','unknown'] %}\n {% set results.items = results.items + [s.entity_id] %}\n {% endif %}\n {% endif %}\n {% endfor %}\n {% for s in states.binary_sensor | selectattr('attributes.device_class', '==', 'battery') %}\n {% if include_hidden_entities == 'exclude_hidden' %}\n {% set s = s if not is_hidden_entity(s.entity_id) else none %}\n {% endif %}\n {% if s and s.entity_id not in all_exclude_sensors and not s.entity_id is search(exclude_regex) %}\n {% if s.state in ['unavailable','unknown'] %}\n {% set results.items = results.items + [s.entity_id] %}\n {% endif %}\n {% endif %}\n {% endfor %}\n {{ results.items | join('; ') if results.items else '' }}" | |
| sensors_names_custom_group: "{% if custom_group is defined and (custom_group.entity_id | default([]) | length > 0 or custom_group.label_id | default([]) | length > 0) and custom_group_battery_level is defined and display_options is defined %}\n {% set results = namespace(items=[], count=0) %}\n {% for s in states.sensor | selectattr('attributes.device_class', '==', 'battery') %}\n {% if include_hidden_entities == 'exclude_hidden' %}\n {% set s = s if not is_hidden_entity(s.entity_id) else none %}\n {% endif %}\n {% if s and s.entity_id in custom_group_sensors %}\n {% if s.state not in ['unavailable','unknown'] and s.state | int(0) <= custom_group_battery_level %}\n {% set results.count = results.count + 1 %}\n {% if display_options == 'entity_ids' %}\n {% set results.items = results.items + ['• ' ~ s.entity_id] %}\n {% elif display_options == 'friendly_names' %}\n {% set results.items = results.items + ['• ' ~ s.name] %}\n {% else %}\n {% set results.items = results.items + ['• ' ~ s.name ~ ' (' ~ s.entity_id ~ ')'] %}\n {% endif %}\n {% endif %}\n {% endif %}\n {% endfor %}\n {% for s in states.binary_sensor | selectattr('attributes.device_class', '==', 'battery') %}\n {% if include_hidden_entities == 'exclude_hidden' %}\n {% set s = s if not is_hidden_entity(s.entity_id) else none %}\n {% endif %}\n {% if s and s.entity_id in custom_group_sensors %}\n {% if s.state in ['on','low'] %}\n {% set results.count = results.count + 1 %}\n {% if display_options == 'entity_ids' %}\n {% set results.items = results.items + ['• ' ~ s.entity_id] %}\n {% elif display_options == 'friendly_names' %}\n {% set results.items = results.items + ['• ' ~ s.name] %}\n {% else %}\n {% set results.items = results.items + ['• ' ~ s.name ~ ' (' ~ s.entity_id ~ ')'] %}\n {% endif %}\n {% endif %}\n {% endif %}\n {% endfor %}\n {% if results.count > 0 %}\n {{ '\\n' ~ results.count ~ ' Devices in Custom Group (Low Battery)\\n\\n' ~ results.items | join('\\n') }}\n {% else %}\n ''\n {% endif %}\n{% else %}\n ''\n{% endif %}" | |
| unavailable_sensors_names_custom_group: "{% if custom_group is defined and (custom_group.entity_id | default([]) | length > 0 or custom_group.label_id | default([]) | length > 0) and display_options is defined %}\n {% set results = namespace(items=[], count=0) %}\n {% for s in states.sensor | selectattr('attributes.device_class', '==', 'battery') %}\n {% if include_hidden_entities == 'exclude_hidden' %}\n {% set s = s if not is_hidden_entity(s.entity_id) else none %}\n {% endif %}\n {% if s and s.entity_id in custom_group_sensors %}\n {% if s.state in ['unavailable','unknown'] %}\n {% set results.count = results.count + 1 %}\n {% if display_options == 'entity_ids' %}\n {% set results.items = results.items + ['• ' ~ s.entity_id ~ (' (unknown)' if s.state == 'unknown' else '')] %}\n {% elif display_options == 'friendly_names' %}\n {% set results.items = results.items + ['• ' ~ s.name ~ (' (unknown)' if s.state == 'unknown' else '')] %}\n {% else %}\n {% set results.items = results.items + ['• ' ~ s.name ~ ' (' ~ s.entity_id ~ ')' ~ (' (unknown)' if s.state == 'unknown' else '')] %}\n {% endif %}\n {% endif %}\n {% endif %}\n {% endfor %}\n {% for s in states.binary_sensor | selectattr('attributes.device_class', '==', 'battery') %}\n {% if include_hidden_entities == 'exclude_hidden' %}\n {% set s = s if not is_hidden_entity(s.entity_id) else none %}\n {% endif %}\n {% if s and s.entity_id in custom_group_sensors %}\n {% if s.state in ['unavailable','unknown'] %}\n {% set results.count = results.count + 1 %}\n {% if display_options == 'entity_ids' %}\n {% set results.items = results.items + ['• ' ~ s.entity_id ~ (' (unknown)' if s.state == 'unknown' else '')] %}\n {% elif display_options == 'friendly_names' %}\n {% set results.items = results.items + ['• ' ~ s.name ~ (' (unknown)' if s.state == 'unknown' else '')] %}\n {% else %}\n {% set results.items = results.items + ['• ' ~ s.name ~ ' (' ~ s.entity_id ~ ')' ~ (' (unknown)' if s.state == 'unknown' else '')] %}\n {% endif %}\n {% endif %}\n {% endif %}\n {% endfor %}\n {% if results.count > 0 %}\n {{ '\\n' ~ results.count ~ ' Devices in Custom Group (Unavailable)\\n\\n' ~ results.items | join('\\n') }}\n {% else %}\n ''\n {% endif %}\n{% else %}\n ''\n{% endif %}" | |
| sensors_entity_ids_semicolon_custom_group: "{% if custom_group is defined and (custom_group.entity_id | default([]) | length > 0 or custom_group.label_id | default([]) | length > 0) and custom_group_battery_level is defined %}\n {% set results = namespace(items=[]) %}\n {% for s in states.sensor | selectattr('attributes.device_class', '==', 'battery') %}\n {% if include_hidden_entities == 'exclude_hidden' %}\n {% set s = s if not is_hidden_entity(s.entity_id) else none %}\n {% endif %}\n {% if s and s.entity_id in custom_group_sensors %}\n {% if s.state not in ['unavailable','unknown'] and s.state | int(0) <= custom_group_battery_level %}\n {% set results.items = results.items + [s.entity_id] %}\n {% endif %}\n {% endif %}\n {% endfor %}\n {% for s in states.binary_sensor | selectattr('attributes.device_class', '==', 'battery') %}\n {% if include_hidden_entities == 'exclude_hidden' %}\n {% set s = s if not is_hidden_entity(s.entity_id) else none %}\n {% endif %}\n {% if s and s.entity_id in custom_group_sensors %}\n {% if s.state in ['on','low'] %}\n {% set results.items = results.items + [s.entity_id] %}\n {% endif %}\n {% endif %}\n {% endfor %}\n {{ results.items | join('; ') if results.items else '' }}\n{% else %}\n ''\n{% endif %}" | |
| unavailable_sensors_entity_ids_semicolon_custom_group: "{% if custom_group is defined and (custom_group.entity_id | default([]) | length > 0 or custom_group.label_id | default([]) | length > 0) %}\n {% set results = namespace(items=[]) %}\n {% for s in states.sensor | selectattr('attributes.device_class', '==', 'battery') %}\n {% if include_hidden_entities == 'exclude_hidden' %}\n {% set s = s if not is_hidden_entity(s.entity_id) else none %}\n {% endif %}\n {% if s and s.entity_id in custom_group_sensors %}\n {% if s.state in ['unavailable','unknown'] %}\n {% set results.items = results.items + [s.entity_id] %}\n {% endif %}\n {% endif %}\n {% endfor %}\n {% for s in states.binary_sensor | selectattr('attributes.device_class', '==', 'battery') %}\n {% if include_hidden_entities == 'exclude_hidden' %}\n {% set s = s if not is_hidden_entity(s.entity_id) else none %}\n {% endif %}\n {% if s and s.entity_id in custom_group_sensors %}\n {% if s.state in ['unavailable','unknown'] %}\n {% set results.items = results.items + [s.entity_id] %}\n {% endif %}\n {% endif %}\n {% endfor %}\n {{ results.items | join('; ') if results.items else '' }}\n{% else %}\n ''\n{% endif %}" | |
| # Updated To-Do variables with independent message format, display options, and whole number percentages | |
| to_do_low_items: > | |
| {% set results = namespace(items=[]) %} | |
| {% if sensor_selection in ['enable_all_sensors', 'enable_all_and_custom_group_sensors'] %} | |
| {% if to_do_message_format in ['all_sensors', 'sensors'] %} | |
| {% for s in states.sensor | selectattr('attributes.device_class', '==', 'battery') %} | |
| {% if include_hidden_entities == 'exclude_hidden' %} | |
| {% set s = s if not is_hidden_entity(s.entity_id) else none %} | |
| {% endif %} | |
| {% if s and s.entity_id not in all_exclude_sensors and not s.entity_id is search(exclude_regex) %} | |
| {% if s.state not in ['unavailable','unknown'] and s.state | int(0) <= battery_level %} | |
| {% if to_do_display_options == 'entity_ids' %} | |
| {% set results.items = results.items + [s.entity_id ~ ' ' ~ (s.state | float | round(0)) ~ '%'] %} | |
| {% elif to_do_display_options == 'friendly_names' %} | |
| {% set results.items = results.items + [s.name ~ ' ' ~ (s.state | float | round(0)) ~ '%'] %} | |
| {% else %} | |
| {% set results.items = results.items + [s.name ~ ' (' ~ s.entity_id ~ ') ' ~ (s.state | float | round(0)) ~ '%'] %} | |
| {% endif %} | |
| {% endif %} | |
| {% endif %} | |
| {% endfor %} | |
| {% for s in states.binary_sensor | selectattr('attributes.device_class', '==', 'battery') %} | |
| {% if include_hidden_entities == 'exclude_hidden' %} | |
| {% set s = s if not is_hidden_entity(s.entity_id) else none %} | |
| {% endif %} | |
| {% if s and s.entity_id not in all_exclude_sensors and not s.entity_id is search(exclude_regex) %} | |
| {% if s.state in ['on','low'] %} | |
| {% if to_do_display_options == 'entity_ids' %} | |
| {% set results.items = results.items + [s.entity_id ~ ' low'] %} | |
| {% elif to_do_display_options == 'friendly_names' %} | |
| {% set results.items = results.items + [s.name ~ ' low'] %} | |
| {% else %} | |
| {% set results.items = results.items + [s.name ~ ' (' ~ s.entity_id ~ ') low'] %} | |
| {% endif %} | |
| {% endif %} | |
| {% endif %} | |
| {% endfor %} | |
| {% endif %} | |
| {% endif %} | |
| {{ results.items | join('\n') if results.items else '' }} | |
| to_do_unavailable_items: > | |
| {% set results = namespace(items=[]) %} | |
| {% if sensor_selection in ['enable_all_sensors', 'enable_all_and_custom_group_sensors'] %} | |
| {% if to_do_message_format in ['all_sensors', 'unavailable_sensors'] %} | |
| {% for s in states.sensor | selectattr('attributes.device_class', '==', 'battery') %} | |
| {% if include_hidden_entities == 'exclude_hidden' %} | |
| {% set s = s if not is_hidden_entity(s.entity_id) else none %} | |
| {% endif %} | |
| {% if s and s.entity_id not in all_exclude_sensors and not s.entity_id is search(exclude_regex) %} | |
| {% if s.state in ['unavailable','unknown'] %} | |
| {% if to_do_display_options == 'entity_ids' %} | |
| {% set results.items = results.items + [s.entity_id ~ ' ?'] %} | |
| {% elif to_do_display_options == 'friendly_names' %} | |
| {% set results.items = results.items + [s.name ~ ' ?'] %} | |
| {% else %} | |
| {% set results.items = results.items + [s.name ~ ' (' ~ s.entity_id ~ ') ?'] %} | |
| {% endif %} | |
| {% endif %} | |
| {% endif %} | |
| {% endfor %} | |
| {% for s in states.binary_sensor | selectattr('attributes.device_class', '==', 'battery') %} | |
| {% if include_hidden_entities == 'exclude_hidden' %} | |
| {% set s = s if not is_hidden_entity(s.entity_id) else none %} | |
| {% endif %} | |
| {% if s and s.entity_id not in all_exclude_sensors and not s.entity_id is search(exclude_regex) %} | |
| {% if s.state in ['unavailable','unknown'] %} | |
| {% if to_do_display_options == 'entity_ids' %} | |
| {% set results.items = results.items + [s.entity_id ~ ' ?'] %} | |
| {% elif to_do_display_options == 'friendly_names' %} | |
| {% set results.items = results.items + [s.name ~ ' ?'] %} | |
| {% else %} | |
| {% set results.items = results.items + [s.name ~ ' (' ~ s.entity_id ~ ') ?'] %} | |
| {% endif %} | |
| {% endif %} | |
| {% endif %} | |
| {% endfor %} | |
| {% endif %} | |
| {% endif %} | |
| {{ results.items | join('\n') if results.items else '' }} | |
| to_do_low_items_custom_group: > | |
| {% set results = namespace(items=[]) %} | |
| {% if custom_group is defined and (custom_group.entity_id | default([]) | length > 0 or custom_group.label_id | default([]) | length > 0) %} | |
| {% if sensor_selection in ['enable_battery_sensors_custom_group', 'enable_all_and_custom_group_sensors'] %} | |
| {% if to_do_message_format in ['all_sensors', 'sensors'] %} | |
| {% for s in states.sensor | selectattr('attributes.device_class', '==', 'battery') %} | |
| {% if include_hidden_entities == 'exclude_hidden' %} | |
| {% set s = s if not is_hidden_entity(s.entity_id) else none %} | |
| {% endif %} | |
| {% if s and s.entity_id in custom_group_sensors %} | |
| {% if s.state not in ['unavailable','unknown'] and s.state | int(0) <= custom_group_battery_level %} | |
| {% if to_do_display_options == 'entity_ids' %} | |
| {% set results.items = results.items + [s.entity_id ~ ' ' ~ (s.state | float | round(0)) ~ '%'] %} | |
| {% elif to_do_display_options == 'friendly_names' %} | |
| {% set results.items = results.items + [s.name ~ ' ' ~ (s.state | float | round(0)) ~ '%'] %} | |
| {% else %} | |
| {% set results.items = results.items + [s.name ~ ' (' ~ s.entity_id ~ ') ' ~ (s.state | float | round(0)) ~ '%'] %} | |
| {% endif %} | |
| {% endif %} | |
| {% endif %} | |
| {% endfor %} | |
| {% for s in states.binary_sensor | selectattr('attributes.device_class', '==', 'battery') %} | |
| {% if include_hidden_entities == 'exclude_hidden' %} | |
| {% set s = s if not is_hidden_entity(s.entity_id) else none %} | |
| {% endif %} | |
| {% if s and s.entity_id in custom_group_sensors %} | |
| {% if s.state in ['on','low'] %} | |
| {% if to_do_display_options == 'entity_ids' %} | |
| {% set results.items = results.items + [s.entity_id ~ ' low'] %} | |
| {% elif to_do_display_options == 'friendly_names' %} | |
| {% set results.items = results.items + [s.name ~ ' low'] %} | |
| {% else %} | |
| {% set results.items = results.items + [s.name ~ ' (' ~ s.entity_id ~ ') low'] %} | |
| {% endif %} | |
| {% endif %} | |
| {% endif %} | |
| {% endfor %} | |
| {% endif %} | |
| {% endif %} | |
| {% endif %} | |
| {{ results.items | join('\n') if results.items else '' }} | |
| to_do_unavailable_items_custom_group: > | |
| {% set results = namespace(items=[]) %} | |
| {% if custom_group is defined and (custom_group.entity_id | default([]) | length > 0 or custom_group.label_id | default([]) | length > 0) %} | |
| {% if sensor_selection in ['enable_battery_sensors_custom_group', 'enable_all_and_custom_group_sensors'] %} | |
| {% if to_do_message_format in ['all_sensors', 'unavailable_sensors'] %} | |
| {% for s in states.sensor | selectattr('attributes.device_class', '==', 'battery') %} | |
| {% if include_hidden_entities == 'exclude_hidden' %} | |
| {% set s = s if not is_hidden_entity(s.entity_id) else none %} | |
| {% endif %} | |
| {% if s and s.entity_id in custom_group_sensors %} | |
| {% if s.state in ['unavailable','unknown'] %} | |
| {% if to_do_display_options == 'entity_ids' %} | |
| {% set results.items = results.items + [s.entity_id ~ ' ?'] %} | |
| {% elif to_do_display_options == 'friendly_names' %} | |
| {% set results.items = results.items + [s.name ~ ' ?'] %} | |
| {% else %} | |
| {% set results.items = results.items + [s.name ~ ' (' ~ s.entity_id ~ ') ?'] %} | |
| {% endif %} | |
| {% endif %} | |
| {% endif %} | |
| {% endfor %} | |
| {% for s in states.binary_sensor | selectattr('attributes.device_class', '==', 'battery') %} | |
| {% if include_hidden_entities == 'exclude_hidden' %} | |
| {% set s = s if not is_hidden_entity(s.entity_id) else none %} | |
| {% endif %} | |
| {% if s and s.entity_id in custom_group_sensors %} | |
| {% if s.state in ['unavailable','unknown'] %} | |
| {% if to_do_display_options == 'entity_ids' %} | |
| {% set results.items = results.items + [s.entity_id ~ ' ?'] %} | |
| {% elif to_do_display_options == 'friendly_names' %} | |
| {% set results.items = results.items + [s.name ~ ' ?'] %} | |
| {% else %} | |
| {% set results.items = results.items + [s.name ~ ' (' ~ s.entity_id ~ ') ?'] %} | |
| {% endif %} | |
| {% endif %} | |
| {% endif %} | |
| {% endfor %} | |
| {% endif %} | |
| {% endif %} | |
| {% endif %} | |
| {{ results.items | join('\n') if results.items else '' }} | |
| # Updated To-Do description that combines all items based on independent message format | |
| to_do_description: > | |
| {% set all_items = [] %} | |
| {% if sensor_selection == 'enable_battery_sensors_custom_group' %} | |
| {% if to_do_low_items_custom_group %} | |
| {% set all_items = all_items + to_do_low_items_custom_group.split('\n') %} | |
| {% endif %} | |
| {% if to_do_unavailable_items_custom_group %} | |
| {% set all_items = all_items + to_do_unavailable_items_custom_group.split('\n') %} | |
| {% endif %} | |
| {% elif sensor_selection == 'enable_all_sensors' %} | |
| {% if to_do_low_items %} | |
| {% set all_items = all_items + to_do_low_items.split('\n') %} | |
| {% endif %} | |
| {% if to_do_unavailable_items %} | |
| {% set all_items = all_items + to_do_unavailable_items.split('\n') %} | |
| {% endif %} | |
| {% elif sensor_selection == 'enable_all_and_custom_group_sensors' %} | |
| {% if to_do_low_items %} | |
| {% set all_items = all_items + to_do_low_items.split('\n') %} | |
| {% endif %} | |
| {% if to_do_unavailable_items %} | |
| {% set all_items = all_items + to_do_unavailable_items.split('\n') %} | |
| {% endif %} | |
| {% if to_do_low_items_custom_group %} | |
| {% set all_items = all_items + to_do_low_items_custom_group.split('\n') %} | |
| {% endif %} | |
| {% if to_do_unavailable_items_custom_group %} | |
| {% set all_items = all_items + to_do_unavailable_items_custom_group.split('\n') %} | |
| {% endif %} | |
| {% endif %} | |
| {{ all_items | unique | sort | join('\n') }} | |
| device_message_data: "{% set message = namespace(data={}) %} {% set push = namespace(data={}) %} {% if notify_interruption_level in ['active', 'critical', 'time-sensitive', 'passive'] %}\n {% set push.data = dict(push.data, **{ 'interruption-level': notify_interruption_level }) %}\n{% endif %} {% if notify_sound != '' %}\n {% set push.data = dict(push.data, **{ 'sound': notify_sound }) %}\n{% endif %} {% if push.data %}\n {% set message.data = dict(message.data, **{ 'push': push.data }) %}\n{% endif %} {% if 'high_priority' in notify_data %}\n {% set message.data = dict(message.data, **{ 'ttl': 0, 'priority': 'high' }) %}\n{% endif %} {% if 'channel' in notify_data %}\n {% set message.data = dict(message.data, **{ 'channel': notify_channel }) %}\n{% endif %} {% if 'sticky' in notify_data %}\n {% set message.data = dict(message.data, **{ 'sticky': \"true\" }) %}\n{% endif %} {% set message.data = dict(message.data, **{ 'tag': notify_tag }) %} {{ message.data }}" | |
| device_message_data_action_button: "{% set message = namespace(data={}) %} {% set push = namespace(data={}) %} {% if notify_interruption_level in ['active', 'critical', 'time-sensitive', 'passive'] %}\n {% set push.data = dict(push.data, **{ 'interruption-level': notify_interruption_level }) %}\n{% endif %} {% if notify_sound != '' %}\n {% set push.data = dict(push.data, **{ 'sound': notify_sound }) %}\n{% endif %} {% if push.data %}\n {% set message.data = dict(message.data, **{ 'push': push.data }) %}\n{% endif %} {% if 'high_priority' in notify_data %}\n {% set message.data = dict(message.data, **{ 'ttl': 0, 'priority': 'high' }) %}\n{% endif %} {% if 'channel' in notify_data %}\n {% set message.data = dict(message.data, **{ 'channel': notify_channel }) %}\n{% endif %} {% if 'sticky' in notify_data %}\n {% set message.data = dict(message.data, **{ 'sticky': \"true\" }) %}\n{% endif %} {% set actions = [\n {'action': action_button_to_do, 'title': action_button_to_do},\n {'action': action_button_cancel, 'title': action_button_cancel}\n] %} {% set message.data = dict(message.data, **{ 'actions': actions, 'tag': notify_tag }) %} {{ message.data }}" | |
| device_confirmation_message_data: "{% set message = namespace(data={}) %} {% set push = namespace(data={}) %} {% if notify_interruption_level in ['active', 'critical', 'time-sensitive', 'passive'] %}\n {% set push.data = dict(push.data, **{ 'interruption-level': notify_interruption_level }) %}\n{% endif %} {% if notify_sound != '' %}\n {% set push.data = dict(push.data, **{ 'sound': notify_sound }) %}\n{% endif %} {% if push.data %}\n {% set message.data = dict(message.data, **{ 'push': push.data }) %}\n{% endif %} {% if 'high_priority' in notify_data %}\n {% set message.data = dict(message.data, **{ 'ttl': 0, 'priority': 'high' }) %}\n{% endif %} {% if 'channel' in notify_data %}\n {% set message.data = dict(message.data, **{ 'channel': notify_channel }) %}\n{% endif %} {% if 'sticky' in notify_data %}\n {% set message.data = dict(message.data, **{ 'sticky': \"true\" }) %}\n{% endif %} {% set message.data = dict(message.data, **{ 'tag': notify_tag }) %} {{ message.data }}" | |
| # FIX 1: Removed stray single-quotes from bare fallback strings outside {{ }} blocks. | |
| # FIX 2: custom_group_combined empty-check now uses sensors_custom_group and | |
| # unavailable_sensors_custom_group directly (which are '' when empty) rather | |
| # than concatenating them first — avoiding the false non-empty '\n' result. | |
| easy_notify_message: > | |
| {% if sensor_selection == 'enable_battery_sensors_custom_group' and notify_message == 'all_sensors' %} | |
| {% if custom_group is defined and (custom_group.entity_id | default([]) | length > 0 or custom_group.label_id | default([]) | length > 0) %} | |
| {% if sensors_custom_group != '' or unavailable_sensors_custom_group != '' %} | |
| {{ (sensors_custom_group ~ '\n' ~ unavailable_sensors_custom_group) | replace('\n\n\n\n', '\n\n') | trim }} | |
| {% else %} | |
| No battery issues found in custom group | |
| {% endif %} | |
| {% else %} | |
| No custom group configured | |
| {% endif %} | |
| {% elif sensor_selection == 'enable_battery_sensors_custom_group' and notify_message == 'sensors' %} | |
| {% if custom_group is defined and (custom_group.entity_id | default([]) | length > 0 or custom_group.label_id | default([]) | length > 0) %} | |
| {{ sensors_custom_group if sensors_custom_group != '' else 'No low batteries in custom group' }} | |
| {% else %} | |
| No custom group configured | |
| {% endif %} | |
| {% elif sensor_selection == 'enable_battery_sensors_custom_group' and notify_message == 'unavailable_sensors' %} | |
| {% if custom_group is defined and (custom_group.entity_id | default([]) | length > 0 or custom_group.label_id | default([]) | length > 0) %} | |
| {{ unavailable_sensors_custom_group if unavailable_sensors_custom_group != '' else 'No unavailable sensors in custom group' }} | |
| {% else %} | |
| No custom group configured | |
| {% endif %} | |
| {% elif sensor_selection == 'enable_all_sensors' and notify_message == 'all_sensors' %} | |
| {% if sensors != '' or unavailable_sensors != '' %} | |
| {{ (sensors ~ '\n\n' ~ unavailable_sensors) | replace('\n\n\n\n', '\n\n') | trim }} | |
| {% else %} | |
| No battery issues found | |
| {% endif %} | |
| {% elif sensor_selection == 'enable_all_sensors' and notify_message == 'sensors' %} | |
| {{ sensors if sensors != '' else 'No low batteries found' }} | |
| {% elif sensor_selection == 'enable_all_sensors' and notify_message == 'unavailable_sensors' %} | |
| {{ unavailable_sensors if unavailable_sensors != '' else 'No unavailable sensors found' }} | |
| {% elif sensor_selection == 'enable_all_and_custom_group_sensors' and notify_message == 'all_sensors' %} | |
| {% set custom_group_combined = '' %} | |
| {% if custom_group is defined and (custom_group.entity_id | default([]) | length > 0 or custom_group.label_id | default([]) | length > 0) %} | |
| {% if sensors_custom_group != '' or unavailable_sensors_custom_group != '' %} | |
| {% set custom_group_combined = (sensors_custom_group ~ '\n\n' ~ unavailable_sensors_custom_group) | replace('\n\n\n\n', '\n\n') | trim %} | |
| {% endif %} | |
| {% endif %} | |
| {% if sensors != '' or unavailable_sensors != '' or custom_group_combined != '' %} | |
| {% set base = (sensors ~ '\n\n' ~ unavailable_sensors) | replace('\n\n\n\n', '\n\n') | trim %} | |
| {{ (base ~ ('\n\n' ~ custom_group_combined if custom_group_combined != '' else '')) | trim }} | |
| {% else %} | |
| No battery issues found | |
| {% endif %} | |
| {% elif sensor_selection == 'enable_all_and_custom_group_sensors' and notify_message == 'sensors' %} | |
| {% set custom_group_part = '' %} | |
| {% if custom_group is defined and (custom_group.entity_id | default([]) | length > 0 or custom_group.label_id | default([]) | length > 0) %} | |
| {% if sensors_custom_group != '' %} | |
| {% set custom_group_part = sensors_custom_group %} | |
| {% endif %} | |
| {% endif %} | |
| {% if sensors != '' or custom_group_part != '' %} | |
| {{ (sensors ~ ('\n\n' ~ custom_group_part if custom_group_part != '' else '')) | trim }} | |
| {% else %} | |
| No low batteries found | |
| {% endif %} | |
| {% elif sensor_selection == 'enable_all_and_custom_group_sensors' and notify_message == 'unavailable_sensors' %} | |
| {% set custom_group_part = '' %} | |
| {% if custom_group is defined and (custom_group.entity_id | default([]) | length > 0 or custom_group.label_id | default([]) | length > 0) %} | |
| {% if unavailable_sensors_custom_group != '' %} | |
| {% set custom_group_part = unavailable_sensors_custom_group %} | |
| {% endif %} | |
| {% endif %} | |
| {% if unavailable_sensors != '' or custom_group_part != '' %} | |
| {{ (unavailable_sensors ~ ('\n\n' ~ custom_group_part if custom_group_part != '' else '')) | trim }} | |
| {% else %} | |
| No unavailable sensors found | |
| {% endif %} | |
| {% else %} | |
| No battery sensors configured | |
| {% endif %} | |
| has_battery_issues: > | |
| {% set has_issues = false %} | |
| {% if sensor_selection == 'enable_battery_sensors_custom_group' %} | |
| {% if custom_group is defined and (custom_group.entity_id | default([]) | length > 0 or custom_group.label_id | default([]) | length > 0) %} | |
| {% if notify_message == 'all_sensors' %} | |
| {% set has_issues = sensors_custom_group != '' or unavailable_sensors_custom_group != '' %} | |
| {% elif notify_message == 'sensors' %} | |
| {% set has_issues = sensors_custom_group != '' %} | |
| {% elif notify_message == 'unavailable_sensors' %} | |
| {% set has_issues = unavailable_sensors_custom_group != '' %} | |
| {% endif %} | |
| {% endif %} | |
| {% elif sensor_selection == 'enable_all_sensors' %} | |
| {% if notify_message == 'all_sensors' %} | |
| {% set has_issues = sensors != '' or unavailable_sensors != '' %} | |
| {% elif notify_message == 'sensors' %} | |
| {% set has_issues = sensors != '' %} | |
| {% elif notify_message == 'unavailable_sensors' %} | |
| {% set has_issues = unavailable_sensors != '' %} | |
| {% endif %} | |
| {% elif sensor_selection == 'enable_all_and_custom_group_sensors' %} | |
| {% set base_issues = false %} | |
| {% if notify_message == 'all_sensors' %} | |
| {% set base_issues = sensors != '' or unavailable_sensors != '' %} | |
| {% elif notify_message == 'sensors' %} | |
| {% set base_issues = sensors != '' %} | |
| {% elif notify_message == 'unavailable_sensors' %} | |
| {% set base_issues = unavailable_sensors != '' %} | |
| {% endif %} | |
| {% set custom_issues = false %} | |
| {% if custom_group is defined and (custom_group.entity_id | default([]) | length > 0 or custom_group.label_id | default([]) | length > 0) %} | |
| {% if notify_message == 'all_sensors' %} | |
| {% set custom_issues = sensors_custom_group != '' or unavailable_sensors_custom_group != '' %} | |
| {% elif notify_message == 'sensors' %} | |
| {% set custom_issues = sensors_custom_group != '' %} | |
| {% elif notify_message == 'unavailable_sensors' %} | |
| {% set custom_issues = unavailable_sensors_custom_group != '' %} | |
| {% endif %} | |
| {% endif %} | |
| {% set has_issues = base_issues or custom_issues %} | |
| {% endif %} | |
| {{ has_issues }} | |
| trigger: | |
| - platform: state | |
| entity_id: !input button_entity | |
| id: button_trigger | |
| - platform: time | |
| at: !input time | |
| id: time_trigger | |
| condition: | |
| - condition: or | |
| conditions: | |
| - condition: and | |
| conditions: | |
| - condition: trigger | |
| id: button_trigger | |
| - condition: template | |
| value_template: '{{ include_button == ''enable_button_trigger'' }}' | |
| - condition: and | |
| conditions: | |
| - condition: trigger | |
| id: time_trigger | |
| - condition: template | |
| value_template: '{{ include_time == ''time_enabled'' }}' | |
| - condition: template | |
| value_template: '{{ now().strftime(''%a'').lower() in weekday_options }}' | |
| - condition: and | |
| conditions: !input global_conditions | |
| action: | |
| - service: logbook.log | |
| data: | |
| name: Battery Report Debug | |
| message: 'Initial: include_easy_notify: {{ include_easy_notify | default(''undefined'') }}, include_persistent_notification: {{ include_persistent_notification | default(''undefined'') }}, notify_device: {{ notify_device | default(''undefined'') }}, custom_group_sensors: {{ custom_group_sensors | default(''undefined'') }}, all_sensors_count: {{ all_sensors.split(''\n'')[1] | default(''0'', true) }}, sensors_count: {{ sensors.split(''\n'')[1] | default(''0'', true) }}, unavailable_sensors_count: {{ unavailable_sensors.split(''\n'')[1] | default(''0'', true) }}, sensors_custom_group_count: {{ sensors_custom_group.split(''\n'')[1] | default(''0'', true) }}, unavailable_sensors_custom_group_count: {{ unavailable_sensors_custom_group.split(''\n'')[1] | default(''0'', true) }}, easy_notify_message: {{ easy_notify_message | default(''undefined'') }}, to_do_list: {{ to_do_list | default(''undefined'') }}, to_do_list_state: {{ states(to_do_list) if to_do_list is string else (states(to_do_list[0]) if to_do_list | length > 0 else ''not_found'') }}, has_battery_issues: {{ has_battery_issues | default(''undefined'') }}' | |
| - 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: '{{ notify_device | default([]) }}' | |
| sequence: | |
| - choose: | |
| - alias: Sensors have been found | |
| conditions: | |
| - condition: template | |
| value_template: '{{ has_battery_issues }}' | |
| sequence: | |
| - choose: | |
| - alias: Easy notify with no action button | |
| conditions: | |
| - condition: template | |
| value_template: '{{ notify_action_buttons == ''disabled_notify_action_buttons'' or auto_add_to_do == ''enable_auto_add_to_do'' }}' | |
| sequence: | |
| - service: notify.mobile_app_{{ device_attr(repeat.item, 'name') | slugify }} | |
| data: | |
| title: !input notify_title | |
| message: '{{ easy_notify_message }}' | |
| data: '{{ device_message_data }}' | |
| - service: logbook.log | |
| data: | |
| name: Battery Report Debug | |
| message: 'Sent notification without action buttons to device: {{ device_attr(repeat.item, ''name'') | slugify }}, service: notify.mobile_app_{{ device_attr(repeat.item, ''name'') | slugify }}, tag: {{ notify_tag }}, message: {{ easy_notify_message }}' | |
| - alias: Easy notify with action button | |
| conditions: | |
| - condition: template | |
| value_template: '{{ notify_action_buttons != ''disabled_notify_action_buttons'' and auto_add_to_do != ''enable_auto_add_to_do'' }}' | |
| sequence: | |
| - service: notify.mobile_app_{{ device_attr(repeat.item, 'name') | slugify }} | |
| data: | |
| title: !input notify_title | |
| message: '{{ easy_notify_message }}' | |
| data: '{{ device_message_data_action_button }}' | |
| - service: logbook.log | |
| data: | |
| name: Battery Report Debug | |
| message: 'Sent notification with action buttons to device: {{ device_attr(repeat.item, ''name'') | slugify }}, service: notify.mobile_app_{{ device_attr(repeat.item, ''name'') | slugify }}, tag: {{ notify_tag }}, actions: {{ device_message_data_action_button }}' | |
| - alias: No sensors have been found | |
| conditions: | |
| - condition: template | |
| value_template: '{{ not has_battery_issues }}' | |
| - condition: template | |
| value_template: '{{ include_easy_notify == ''enable_easy_okay_notify'' }}' | |
| sequence: | |
| - service: notify.mobile_app_{{ device_attr(repeat.item, 'name') | slugify }} | |
| data: | |
| title: !input notify_title | |
| message: !input notify_okay_message | |
| data: '{{ device_message_data }}' | |
| - service: logbook.log | |
| data: | |
| name: Battery Report Debug | |
| message: 'Sent no-issues notification to device: {{ device_attr(repeat.item, ''name'') | slugify }}, service: notify.mobile_app_{{ device_attr(repeat.item, ''name'') | slugify }}, tag: {{ notify_tag }}, message: {{ notify_okay_message }}' | |
| - 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: | |
| - condition: template | |
| value_template: '{{ has_battery_issues }}' | |
| sequence: | |
| - service: persistent_notification.create | |
| data: | |
| title: "🔋 {{ notify_title }}" | |
| message: '{{ easy_notify_message }}' | |
| notification_id: battery_report | |
| - service: logbook.log | |
| data: | |
| name: Battery Report Debug | |
| message: 'Created persistent notification, id: battery_report, message: {{ easy_notify_message }}' | |
| - alias: No sensors have been found | |
| conditions: | |
| - condition: template | |
| value_template: '{{ not has_battery_issues }}' | |
| - condition: template | |
| value_template: '{{ include_persistent_notification == ''enable_persistent_okay_notification'' }}' | |
| sequence: | |
| - service: persistent_notification.create | |
| data: | |
| title: "🔋 {{ notify_title }}" | |
| message: !input notify_okay_message | |
| notification_id: battery_report_ok | |
| - service: logbook.log | |
| data: | |
| name: Battery Report Debug | |
| message: 'Created persistent no-issues notification, id: battery_report_ok, message: {{ notify_okay_message }}' | |
| - choose: | |
| - alias: Automatically add to To-Do list | |
| conditions: | |
| - condition: template | |
| value_template: '{{ auto_add_to_do == ''enable_auto_add_to_do'' }}' | |
| - condition: template | |
| value_template: '{{ has_battery_issues }}' | |
| - condition: template | |
| value_template: '{{ to_do_list is string or (to_do_list | length > 0 and to_do_list != []) }}' | |
| - condition: template | |
| value_template: > | |
| {% set entity = to_do_list if to_do_list is string else to_do_list[0] %} | |
| {{ is_state(entity, 'unknown') == false and is_state(entity, 'unavailable') == false }} | |
| sequence: | |
| - service: todo.add_item | |
| target: | |
| entity_id: '{{ to_do_list if to_do_list is string else to_do_list[0] }}' | |
| data: | |
| item: '{{ to_do_task_title }}' | |
| description: '{{ to_do_description }}' | |
| continue_on_error: true | |
| - service: logbook.log | |
| data: | |
| name: Battery Report Debug | |
| message: 'Attempted to automatically add To-Do item to {{ to_do_list if to_do_list is string else to_do_list[0] }}: title={{ to_do_task_title }}, description={{ to_do_description }}, entity_state={{ states(to_do_list if to_do_list is string else to_do_list[0]) }}' | |
| - if: | |
| - condition: template | |
| value_template: '{{ notify_action_buttons == ''enable_to_do_list_button_and_confirmation'' }}' | |
| then: | |
| - repeat: | |
| for_each: '{{ notify_device | default([]) }}' | |
| sequence: | |
| - service: 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 }}' | |
| continue_on_error: true | |
| - service: logbook.log | |
| data: | |
| name: Battery Report Debug | |
| message: 'Sent auto-add confirmation notification to device: {{ device_attr(repeat.item, ''name'') | slugify }}, service: notify.mobile_app_{{ device_attr(repeat.item, ''name'') | slugify }}, tag: {{ notify_tag }}, message: {{ action_button_confirmation_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: '{{ auto_add_to_do != ''enable_auto_add_to_do'' }}' | |
| - condition: template | |
| value_template: '{{ notify_device | length > 0 }}' | |
| - condition: template | |
| value_template: '{{ to_do_list is string or (to_do_list | length > 0 and to_do_list != []) }}' | |
| - condition: template | |
| value_template: > | |
| {% set entity = to_do_list if to_do_list is string else to_do_list[0] %} | |
| {{ is_state(entity, 'unknown') == false and is_state(entity, 'unavailable') == false }} | |
| sequence: | |
| - alias: Wait for a response from the action buttons | |
| wait_for_trigger: | |
| - platform: event | |
| event_type: mobile_app_notification_action | |
| event_data: | |
| action: '{{ action_button_to_do }}' | |
| - platform: event | |
| event_type: mobile_app_notification_action | |
| event_data: | |
| action: '{{ action_button_cancel }}' | |
| timeout: 00:15:00 | |
| continue_on_timeout: true | |
| - service: logbook.log | |
| data: | |
| name: Battery Report Debug | |
| message: 'Wait for trigger result: {{ wait.trigger | default(''no trigger received'', true) }}, action: {{ wait.trigger.event.data.action if wait.trigger else ''none'' }}, tag: {{ notify_tag if wait.trigger else ''none'' }}, event_data: {{ wait.trigger.event.data if wait.trigger else ''none'' }}' | |
| - choose: | |
| - alias: Check if confirmation message is disabled | |
| conditions: | |
| - condition: template | |
| value_template: '{{ notify_action_buttons == ''enable_to_do_list_button'' }}' | |
| sequence: | |
| - if: | |
| - condition: template | |
| value_template: '{{ wait.trigger is not none and wait.trigger.event.data.action == action_button_to_do }}' | |
| then: | |
| - service: todo.add_item | |
| target: | |
| entity_id: '{{ to_do_list if to_do_list is string else to_do_list[0] }}' | |
| data: | |
| item: '{{ to_do_task_title }}' | |
| description: '{{ to_do_description }}' | |
| continue_on_error: true | |
| - service: logbook.log | |
| data: | |
| name: Battery Report Debug | |
| message: 'Attempted to add To-Do item to {{ to_do_list if to_do_list is string else to_do_list[0] }}: title={{ to_do_task_title }}, description={{ to_do_description }}, entity_state={{ states(to_do_list if to_do_list is string else to_do_list[0]) }}' | |
| - service: logbook.log | |
| data: | |
| name: Battery Report Debug | |
| message: 'To-Do item addition attempted, result: {{ ''success'' if wait.trigger is not none else ''failed or no trigger'' }}' | |
| - if: | |
| - condition: template | |
| value_template: '{{ wait.trigger is not none and wait.trigger.event.data.action == action_button_cancel }}' | |
| then: | |
| - service: logbook.log | |
| data: | |
| name: Battery Report Debug | |
| message: 'Action cancelled for tag: {{ notify_tag }}' | |
| - 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: | |
| - condition: template | |
| value_template: '{{ wait.trigger is not none and wait.trigger.event.data.action == action_button_to_do }}' | |
| then: | |
| - service: todo.add_item | |
| target: | |
| entity_id: '{{ to_do_list if to_do_list is string else to_do_list[0] }}' | |
| data: | |
| item: '{{ to_do_task_title }}' | |
| description: '{{ to_do_description }}' | |
| continue_on_error: true | |
| - service: logbook.log | |
| data: | |
| name: Battery Report Debug | |
| message: 'Attempted to add To-Do item to {{ to_do_list if to_do_list is string else to_do_list[0] }}: title={{ to_do_task_title }}, description={{ to_do_description }}, entity_state={{ states(to_do_list if to_do_list is string else to_do_list[0]) }}' | |
| - service: logbook.log | |
| data: | |
| name: Battery Report Debug | |
| message: 'To-Do item addition attempted, result: {{ ''success'' if wait.trigger is not none else ''failed or no trigger'' }}' | |
| - repeat: | |
| for_each: '{{ notify_device | default([]) }}' | |
| sequence: | |
| - service: 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 }}' | |
| continue_on_error: true | |
| - service: logbook.log | |
| data: | |
| name: Battery Report Debug | |
| message: 'Sent confirmation notification to device: {{ device_attr(repeat.item, ''name'') | slugify }}, service: notify.mobile_app_{{ device_attr(repeat.item, ''name'') | slugify }}, tag: {{ notify_tag }}, message: {{ action_button_confirmation_message }}' | |
| - if: | |
| - condition: template | |
| value_template: '{{ wait.trigger is not none and wait.trigger.event.data.action == action_button_cancel }}' | |
| then: | |
| - repeat: | |
| for_each: '{{ notify_device | default([]) }}' | |
| sequence: | |
| - service: 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 }}' | |
| continue_on_error: true | |
| - service: logbook.log | |
| data: | |
| name: Battery Report Debug | |
| message: 'Sent cancel confirmation notification to device: {{ device_attr(repeat.item, ''name'') | slugify }}, service: notify.mobile_app_{{ device_attr(repeat.item, ''name'') | slugify }}, tag: {{ notify_tag }}, message: {{ cancel_action_button_confirmation_message }}' | |
| - choose: | |
| - alias: Perform the custom actions | |
| conditions: | |
| - condition: template | |
| value_template: '{{ include_custom_actions == ''enable_custom_actions'' }}' | |
| sequence: !input custom_actions | |
| mode: single |
Comments are disabled for this gist.