Automation to create notification when HACS addons get new updates?

Hi!

Anyone knows how to make this automation, in order to get a persisten notification about new updates of the HACS addons?

Thank you in advance!

Hi,

I don’t have an automation for that but I have a conditional mushroom chip where I look for states(’‘sensor.hacs’’) not equal to zero and I use a markdown card to list all the addons being updated with the code below

            {%- for rep in state_attr('sensor.hacs', 'repositories') -%} **{{
            rep.display_name }}**{{ '\n' }}Current version: {{
            rep.installed_version }}{{ '\n' }}Latest version: {{
            rep.available_version }}

regards,
Abel

2 Likes

Hi!

It is more than enough. Thanks!
I forgot about the fact that HACS have a sensor for this.

This is what I have done for the automation I wanted

alias: Notify - New HACS Updates (Persistent Notification)
description: ""
trigger:
  - platform: state
    entity_id:
      - sensor.hacs
condition:
  - condition: template
    value_template: "{{ states(\"sensor.hacs\") | int != 0 }}"
action:
  - service: persistent_notification.create
    data:
      message: >
        New HACS Updates:{{ "\n\n" }} {%- for rep in state_attr('sensor.hacs',
        'repositories') -%} - {{rep.display_name }}
            {{ "    " }}Current: {{rep.installed_version }}
            {{ "    " }}Latest: {{rep.available_version }}
        {%- endfor -%}
mode: single

Now, @aoliveir , I have a question, what is the purpose of using %- -% ? I have seen this in the past, but I don’t know the purpose.

Thanks in advance.

1 Like

Hello,

It is used for whitespace control see Template Designer Documentation — Jinja Documentation (3.1.x)

Regards,

Abel

1 Like