Skip to content

Instantly share code, notes, and snippets.

@dwardu89
Last active December 28, 2022 22:01
Show Gist options
  • Save dwardu89/504165e75778824510252202f3e7f870 to your computer and use it in GitHub Desktop.
Save dwardu89/504165e75778824510252202f3e7f870 to your computer and use it in GitHub Desktop.
Home assistant blueprint to get entities with updates
blueprint:
name: Update detection & notification for all update sensors
description: Regularly test all sensors with 'update' device-class for having an update set to 'on'.
domain: automation
input:
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.0
max: 7.0
mode: slider
step: 1.0
exclude:
name: Excluded Updates
description: Updates to exclude from detection. Only use entities, devices do not work.
default: {entity_id: []}
selector:
target:
entity:
domain: update
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/dwardu89/504165e75778824510252202f3e7f870
variables:
day: !input 'day'
exclude: !input 'exclude'
sensors: >-
{% set result = namespace(sensors=[]) %}
{% for update in states.update %}
{% if 'on' in update.state and not update.entity_id in exclude.entity_id %}
{% set result.sensors = result.sensors + [update.name.capitalize()|replace(" update", "")] %}
{% endif %}
{% endfor %}
{{result.sensors|join(', ')}}
trigger:
- platform: time
at: !input 'time'
condition:
- '{{ sensors != '''' and (day | int == 0 or day | int == now().isoweekday()) }}'
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