Skip to content

Instantly share code, notes, and snippets.

@TheQue42
Last active July 6, 2022 12:13
Show Gist options
  • Save TheQue42/b959d6ed3412b8d947fa3d03e4e6babb to your computer and use it in GitHub Desktop.
Save TheQue42/b959d6ed3412b8d947fa3d03e4e6babb to your computer and use it in GitHub Desktop.
Report/Detect devices with high battery temperature
blueprint:
name: BP-Battery Temp Checker
description: Regularly test any entity with the "battery" string, for high temp!
domain: automation
input:
repetition:
name: How often to run
description: Test is run at this intervall, in minutes. You MUST use the slash notation; 0-59 minutes.
default: '/30'
selector:
text:
multiline: false
max_temp:
name: Max Temp
description: Temperature at which alarm is generated
default: '40'
selector:
number:
min: 20
max: 80
exclude:
name: Excluded Sensors
description: >
There are some weird sensors out there, we might want to ignore.
Only entities are supported, devices must be expanded
default: []
selector:
target:
entity:
device_class: temperature
exclude_regexp:
name: Excluded Sensors, RegExp
description: >
There are some weird sensors out there, we might want to ignore.
default: 'DontMatchAnySensorsAtAll'
selector:
text:
multiline: false
actions:
name: Actions
description: 'Notifications or similar to be run. {{sensors}} is replaced with the names[] of devices indicating high temp'
selector:
action: {}
variables:
exclude: !input 'exclude'
exclude_regexp: !input 'exclude_regexp'
max_value: !input 'max_temp'
sensors: >-
{%- set result = namespace(sensors=[]) -%}
{%- for s in states.sensor | selectattr('attributes.device_class', '==', 'temperature') -%}
{%- if (s.entity_id is search("battery") and (not s.entity_id in exclude and not s.entity_id is search(exclude_regexp))) and s.state|float > max_value|float -%}
{%- set result.sensors = result.sensors + [s.entity_id] -%}
{% endif -%}
{%- endfor -%}
{{result.sensors}}
trigger:
- platform: time_pattern
minutes: !input 'repetition'
condition:
- '{{ sensors|length != 0 }}'
action:
- choose: []
default: !input 'actions'
mode: single
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment