Hi,
I made automation that checks updateable Zigbee devices from zigbee2mqtt bridge and asks you if you want to update them.
groups.yaml Place here all your zigbee2mqtt devices that can do OTA update
zigbee_updates:
name: Zigbee device updates
entities:
- binary_sensor.0x000b57fffef2c3e6_update_available
- binary_sensor.0x842e14fffe416ac5_update_available
- binary_sensor.0x842e14fffefc7ffa_update_available
- binary_sensor.0x842e14fffe415c1e_update_available
- binary_sensor.0x842e14fffe415d7e_update_available
- binary_sensor.0x842e14fffe43aaf8_update_available
- binary_sensor.0x000d6ffffe54fd83_update_available
- binary_sensor.0x000b57fffeebd210_update_available
- binary_sensor.0x000b57fffed8366c_update_available
- binary_sensor.0x842e14fffe41729d_update_available
- binary_sensor.0x000d6ffffe09fda2_update_available
automations.yaml
- id: notify_if_zigbee_update
alias: Notification- Alert That Zigbee device has updates
initial_state: 'on'
trigger:
- hours: /4
platform: time_pattern
condition:
condition: and
conditions:
# don't send notifications in night time
- condition: template
value_template: "{{ 8 < now().hour < 21 }}"
- condition: template
value_template: >
{% set ns = namespace(found=false) -%}
{% for entity_id in states.group.zigbee_updates.attributes.entity_id -%}
{% set parts = entity_id.split('.') -%}
{% if is_state(entity_id, "on") -%}
{% set ns.found = true -%}
{% endif -%}
{% endfor -%}
{{ ns.found }}
action:
# change here your notification service
- service: notify.home_assistant_notifications
data:
message: >
{{ "\uD83D\uDCE6" }} Zigbee device(s):
{%- for entity_id in states.group.zigbee_updates.attributes.entity_id -%}
{%- set parts = entity_id.split('.') -%}
{% if is_state(entity_id, "on") -%}
{{ states[parts[0]][parts[1]].name | replace("_update_available","") }} {{ '\n' }}
{%- endif -%}
{%- endfor -%}
has pending update(s).
data:
actions:
- action: update_zigbeedevices
title: Update
destructive: true
- action: ''
title: Dismiss
- id: update_zigbeedevices
alias: OTA update Zigbee devices
trigger:
- event_data:
action: update_zigbeedevices
# change here your notification type
event_type: html5_notification.clicked
platform: event
action:
- repeat:
# repeat for every entity in the list
count: "{{ expand('group.zigbee_updates') | count }}"
sequence:
- choose:
conditions: "{{ expand('group.zigbee_updates')[repeat.index].state == 'on' }}"
sequence:
- service: mqtt.publish
data:
topic: zigbee2mqtt/bridge/ota_update/update
payload: "{{ expand('group.zigbee_updates')[repeat.index].entity_id.replace('binary_sensor.', '') | replace('_update_available','') }}"
- delay: 5