I have a few Ubiquiti devices that I would like to receive notifications for if any or all devices have updates. Currently, all 3 devices have updates available, so I’m using this opportunity to build an automation to test sending notifications via notify.notify.
Right now, I’m not receiving anything. I’m also realizing that if/then is not the way to go because if either #1 or #2 is true it will break the automation. How do I check all 3 devices and send individual notifications for each?
automation:
- alias: "Check for Unifi device updates"
trigger:
platform: template
value_template: >
{{ is_state('update.udm_pro', 'on') or
is_state('update.ubiquiti_uap6mp_1', 'on') or
is_state('update.ubiquiti_uap6mp_2', 'on') }}
action:
- service: input_boolean.turn_on
entity_id: input_boolean.unifi_updates_available
- service: notify.notify
data_template:
title: "Unifi Update Available"
message: >
{% if is_state("update.udm_pro", 'on') %}
The {{ state_attr(update.udm_pro, 'friendly_name') }} has an update from {{ state_attr(update.udm_pro, 'current_version') }} to {{ state_attr(update.udm_pro, 'latest_version') }}
{% elif is_state("update.ubiquiti_uap6mp_1", 'on') %}
The {{ state_attr(update.ubiquiti_uap6mp_1, 'friendly_name') }} has an update from {{ state_attr(update.ubiquiti_uap6mp_1, 'current_version') }} to {{ state_attr(update.ubiquiti_uap6mp_1, 'latest_version') }}
{% elif is_state("update.ubiquiti_uap6mp_2", 'on') %}
The {{ state_attr(update.ubiquiti_uap6mp_2, 'friendly_name') }} has an update from {{ state_attr(update.ubiquiti_uap6mp_2, 'current_version') }} to {{ state_attr(update.ubiquiti_uap6mp_2, 'latest_version') }}
{% else %}
Error message
{% endif %}
I removed the input_booleans as they were duplicative/irrelevant, and changed it from a package to an automation. I also adjusted the message format to three if-endifs, but it’s still not triggering.
When I paste it into the template editor, it says UndefinedError: 'update' is undefined. Do I need to reconfigure the data_template?
- id: '1675848895522'
alias: "Check for Unifi device updates"
trigger:
platform: template
value_template: >
{{ is_state('update.udm_pro', 'on') or
is_state('update.ubiquiti_uap6mp_1', 'on') or
is_state('update.ubiquiti_uap6mp_2', 'on') }}
action:
- service: notify.notify
data_template:
title: "Unifi Update Available"
message: >
{% if is_state("update.udm_pro", 'on') %}
The {{ state_attr(update.udm_pro, 'friendly_name') }} has an update from {{ state_attr(update.udm_pro, 'current_version') }} to {{ state_attr(update.udm_pro, 'latest_version') }}
{% endif %}
{% if is_state("update.ubiquiti_uap6mp_1", 'on') %}
The {{ state_attr(update.ubiquiti_uap6mp_1, 'friendly_name') }} has an update from {{ state_attr(update.ubiquiti_uap6mp_1, 'current_version') }} to {{ state_attr(update.ubiquiti_uap6mp_1, 'latest_version') }}
{% endif %}
{% if is_state("update.ubiquiti_uap6mp_2", 'on') %}
The {{ state_attr(update.ubiquiti_uap6mp_2, 'friendly_name') }} has an update from {{ state_attr(update.ubiquiti_uap6mp_2, 'current_version') }} to {{ state_attr(update.ubiquiti_uap6mp_2, 'latest_version') }}
{% endif %}