Forked from sbyx/low-battery-level-detection-notification-for-all-battery-sensors.yaml
Last active
January 18, 2024 15:24
-
-
Save Ryther/f9bd384feb439dff42076b20440a2498 to your computer and use it in GitHub Desktop.
Revisions
-
Ryther revised this gist
Jan 18, 2024 . 1 changed file with 4 additions and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -86,7 +86,10 @@ variables: {% if not state.entity_id in exclude.entity_id %} {% set result.sensors = result.sensors + [state.name] %} {% endif %} {% endfor %} {% if result.sensors %} - {{result.sensors|join('\n- ')}} {% endif %} trigger: - platform: time at: !input time -
Ryther revised this gist
Jan 18, 2024 . 1 changed file with 51 additions and 29 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,31 +1,45 @@ blueprint: name: Low battery level detection & notification for all battery sensors description: Regularly test all sensors with 'battery' device-class for crossing a certain battery level threshold and if so execute an action. domain: automation input: threshold_min: name: Minimum battery threshold to evaluate description: Battery sensors below threshold will not be included default: 0 selector: number: min: 0.0 max: 95.0 unit_of_measurement: "%" mode: slider step: 5.0 threshold_max: name: Maximum battery threshold to evaluate description: Battery sensors below threshold are assumed to be low-battery (as well as binary battery sensors with value 'on'). default: 20 selector: number: min: 5.0 max: 100.0 unit_of_measurement: "%" mode: slider step: 5.0 time: name: Time to test on description: Test is run at configured time default: "10:00:00" selector: time: {} day: name: Weekday to test on description: "Test is run at configured time either everyday (0) or on a given weekday (1: Monday ... 7: Sunday)" default: 0 selector: number: @@ -35,42 +49,50 @@ blueprint: step: 1.0 exclude: name: Excluded Sensors description: Battery sensors (e.g. smartphone) to exclude from detection. Only entities are supported, devices must be expanded! default: entity_id: [] selector: target: entity: - device_class: - battery actions: name: Actions description: Notifications or similar to be run. {{sensors}} is replaced with the names of sensors being low on battery. selector: action: {} source_url: https://gist.github.com/Ryther/f9bd384feb439dff42076b20440a2498 variables: day: !input day threshold_min: !input threshold_min threshold_max: !input threshold_max exclude: !input exclude sensors: >- {% set result = namespace(sensors=[]) %} {% for state in states.sensor | selectattr('attributes.device_class', '==', 'battery') %} {% if 0 <= state.state | int(-1) < threshold_max | int and not state.entity_id in exclude.entity_id %} {% if 0 <= state.state | int(-1) > threshold_min | int %} {% set result.sensors = result.sensors + [state.name ~ ' (' ~ state.state ~ ' %)'] %} {% endif %} {% endif %} {% endfor %} {% for state in states.binary_sensor | selectattr('attributes.device_class', '==', 'battery') | selectattr('state', '==', 'on') %} {% if not state.entity_id in exclude.entity_id %} {% set result.sensors = result.sensors + [state.name] %} {% endif %} {% endfor %}- {{result.sensors|join('\n- ')}} trigger: - platform: time at: !input time condition: - "{{ sensors != '' and (day | int == 0 or day | int == now().isoweekday()) }}" action: - choose: [] default: !input actions mode: single -
sbyx revised this gist
Jan 13, 2021 . 1 changed file with 1 addition and 2 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -69,8 +69,7 @@ trigger: - platform: time at: !input 'time' condition: - '{{ sensors != '''' and (day | int == 0 or day | int == now().isoweekday()) }}' action: - choose: [] default: !input 'actions' -
sbyx revised this gist
Dec 26, 2020 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -53,7 +53,7 @@ variables: threshold: !input 'threshold' exclude: !input 'exclude' sensors: >- {% set result = namespace(sensors=[]) %} {% for state in states.sensor | selectattr('attributes.device_class', '==', 'battery') %} {% if 0 <= state.state | int(-1) < threshold | int and not state.entity_id in exclude.entity_id %} {% set result.sensors = result.sensors + [state.name ~ ' (' ~ state.state ~ ' %)'] %} -
sbyx revised this gist
Dec 26, 2020 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -55,7 +55,7 @@ variables: sensors: >- {% set result = namespace(sensors=[], sensors_values=[]) %} {% for state in states.sensor | selectattr('attributes.device_class', '==', 'battery') %} {% if 0 <= state.state | int(-1) < threshold | int and not state.entity_id in exclude.entity_id %} {% set result.sensors = result.sensors + [state.name ~ ' (' ~ state.state ~ ' %)'] %} {% endif %} {% endfor %} -
sbyx revised this gist
Dec 26, 2020 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -56,7 +56,7 @@ variables: {% set result = namespace(sensors=[], sensors_values=[]) %} {% for state in states.sensor | selectattr('attributes.device_class', '==', 'battery') %} {% if 0 < state.state | int < threshold | int and not state.entity_id in exclude.entity_id %} {% set result.sensors = result.sensors + [state.name ~ ' (' ~ state.state ~ ' %)'] %} {% endif %} {% endfor %} {% for state in states.binary_sensor | selectattr('attributes.device_class', '==', 'battery') | selectattr('state', '==', 'on') %} -
sbyx revised this gist
Dec 26, 2020 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -53,10 +53,10 @@ variables: threshold: !input 'threshold' exclude: !input 'exclude' sensors: >- {% set result = namespace(sensors=[], sensors_values=[]) %} {% for state in states.sensor | selectattr('attributes.device_class', '==', 'battery') %} {% if 0 < state.state | int < threshold | int and not state.entity_id in exclude.entity_id %} {% set result.sensors = result.sensors + [state.name ~ ' (' ~ state.state ~ '%)'] %} {% endif %} {% endfor %} {% for state in states.binary_sensor | selectattr('attributes.device_class', '==', 'battery') | selectattr('state', '==', 'on') %} -
sbyx revised this gist
Dec 26, 2020 . 1 changed file with 11 additions and 74 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -33,97 +33,34 @@ blueprint: max: 7.0 mode: slider step: 1.0 exclude: name: Excluded Sensors description: Battery sensors (e.g. smartphone) to exclude from detection. Only entities are supported, devices must be expanded! default: {entity_id: []} selector: target: entity: device_class: battery actions: name: Actions description: Notifications or similar to be run. {{sensors}} is replaced with the names of sensors being low on battery. selector: action: {} source_url: https://gist.github.com/sbyx/1f6f434f0903b872b84c4302637d0890 variables: day: !input 'day' threshold: !input 'threshold' exclude: !input 'exclude' sensors: >- {% set result = namespace(sensors=[]) %} {% for state in states.sensor | selectattr('attributes.device_class', '==', 'battery') %} {% if 0 < state.state | int < threshold | int and not state.entity_id in exclude.entity_id %} {% set result.sensors = result.sensors + [state.name] %} {% endif %} {% endfor %} {% for state in states.binary_sensor | selectattr('attributes.device_class', '==', 'battery') | selectattr('state', '==', 'on') %} {% if not state.entity_id in exclude.entity_id %} {% set result.sensors = result.sensors + [state.name] %} {% endif %} {% endfor %} -
sbyx revised this gist
Dec 23, 2020 . 1 changed file with 1 addition and 2 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -133,8 +133,7 @@ trigger: at: !input 'time' condition: - condition: template value_template: '{{ sensors != '''' and (day | int == 0 or day | int == now().isoweekday()) }}' action: - choose: [] default: !input 'actions' -
sbyx revised this gist
Dec 23, 2020 . 1 changed file with 99 additions and 19 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,19 +1,21 @@ blueprint: name: Low battery level detection & notification for all battery sensors description: Regularly test all sensors with 'battery' device-class for crossing a certain battery level threshold and if so execute an action. domain: automation input: threshold: name: Battery warning level threshold description: Battery sensors below threshold are assumed to be low-battery (as well as binary battery sensors with value 'on'). default: 20 selector: number: min: 5.0 max: 100.0 unit_of_measurement: '%' mode: slider step: 5.0 time: name: Time to test on description: Test is run at configured time @@ -22,40 +24,118 @@ blueprint: time: {} day: name: Weekday to test on description: 'Test is run at configured time either everyday (0) or on a given weekday (1: Monday ... 7: Sunday)' default: 0 selector: number: min: 0.0 max: 7.0 mode: slider step: 1.0 actions: name: Actions description: Notifications or similar to be run. {{sensors}} is replaced with the names of sensors being low on battery. selector: action: {} exclude0: name: Exclude Sensor default: none selector: entity: device_class: battery exclude1: name: Exclude Sensor default: none selector: entity: device_class: battery exclude2: name: Exclude Sensor default: none selector: entity: device_class: battery exclude3: name: Exclude Sensor default: none selector: entity: device_class: battery exclude4: name: Exclude Sensor default: none selector: entity: device_class: battery exclude5: name: Exclude Sensor default: none selector: entity: device_class: battery exclude6: name: Exclude Sensor default: none selector: entity: device_class: battery exclude7: name: Exclude Sensor default: none selector: entity: device_class: battery exclude8: name: Exclude Sensor default: none selector: entity: device_class: battery exclude9: name: Exclude Sensor default: none selector: entity: device_class: battery source_url: https://gist.github.com/sbyx/1f6f434f0903b872b84c4302637d0890 variables: day: !input 'day' threshold: !input 'threshold' exclude0: !input exclude0 exclude1: !input exclude1 exclude2: !input exclude2 exclude3: !input exclude3 exclude4: !input exclude4 exclude5: !input exclude5 exclude6: !input exclude6 exclude7: !input exclude7 exclude8: !input exclude8 exclude9: !input exclude9 sensors: >- {% set result = namespace(sensors=[]) %} {% set exclude = [exclude0, exclude1, exclude2, exclude3, exclude4, exclude5, exclude6, exclude7, exclude8, exclude9] %} {% for state in states.sensor | selectattr('attributes.device_class', '==', 'battery') %} {% if 0 < state.state | int < threshold | int and not state.entity_id in exclude %} {% set result.sensors = result.sensors + [state.name] %} {% endif %} {% endfor %} {% for state in states.binary_sensor | selectattr('attributes.device_class', '==', 'battery') | selectattr('state', '==', 'on') %} {% if not state.entity_id in exclude %} {% set result.sensors = result.sensors + [state.name] %} {% endif %} {% endfor %} {{result.sensors|join(', ')}} trigger: - platform: time at: !input 'time' condition: - condition: template value_template: '{{ sensors != '''' and (day | int == 0 or day | int == now().isoweekday()) }}' action: - choose: [] default: !input 'actions' mode: single -
sbyx created this gist
Dec 22, 2020 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,61 @@ blueprint: name: Low battery level detection & notification for all battery sensors description: Regularly test all sensors with 'battery' device-class for crossing a certain battery level threshold and if so execute an action. domain: automation input: threshold: name: Battery warning level threshold description: Battery sensors below threshold are assumed to be low-battery (as well as binary battery sensors with value 'on'). default: 20 selector: number: min: 5.0 max: 100.0 unit_of_measurement: '%' mode: slider step: 5 time: name: Time to test on description: Test is run at configured time default: '10:00:00' selector: time: {} day: name: Weekday to test on description: 'Test is run at configured time either everyday (0) or on a given weekday (1: Monday ... 7: Sunday)' default: 0 selector: number: min: 0 max: 7 mode: slider step: 1 actions: name: Actions description: "Notifications or similar to be run. {{sensors}} is replaced with the names of sensors being low on battery." selector: action: {} variables: day: !input day threshold: !input threshold sensors: >- {% set result = namespace(sensors=[]) %} {% for state in states.sensor | selectattr('attributes.device_class', '==', 'battery') %} {% if 0 < state.state | int < threshold | int %} {% set result.sensors = result.sensors + [state.name] %} {% endif %} {% endfor %} {% for state in states.binary_sensor | selectattr('attributes.device_class', '==', 'battery') | selectattr('state', '==', 'on') %} {% set result.sensors = result.sensors + [state.name] %} {% endfor %} {{result.sensors|join(', ')}} trigger: - platform: time at: !input time condition: - condition: template value_template: '{{ sensors != '''' and (day | int == 0 or day | int == now().isoweekday()) }}' action: - choose: [] default: !input actions mode: single