I made an automation with the help of ai (i don’t know jinja). I would like the automation get triggered when eighter there’s an update in HACS or in the core intergations or add-ons. Now the automation works, but only is one of the triggers is true. When there’s an update in both triggers, the automation doesn’t trigger at all. Can somebody please help me out? I already tried to split the automation into two automations, where one gets triggered by the core and one gets triggered by HACS, but that didn’t help eighter, because i got the same result. If one was true and triggered, the other one didn’t get triggered at all (i only split the triggers and left the rest of the automations as they where in one). So i think there’s something wrong with the jinja i use in the notification section. Here is the code from the automation:
alias: "Notify: Updates Beschikbaar voor HACS"
description: Stuur notificatie naar Danny wanneer er updates beschikbaar zijn voor HACS.
triggers:
- entity_id: sensor.hacs
from: "0"
to: "!0"
trigger: state
- value_template: >
{{ states.update | selectattr('state', 'equalto', 'on') | list | length > 0 }}
trigger: template
actions:
- action: notify.mobile_app_danny
metadata: {}
data:
title: Update(s) beschikbaar
message: " {% set updates = namespace(list=[]) %} {% for entity in states.update %} {% if entity.state == 'on' %} {% set update_name = state_attr(entity.entity_id, 'friendly_name') or entity.entity_id %} {% set updates.list = updates.list + [update_name ~ ' update beschikbaar'] %} {% endif %} {% endfor %} {% set hacs_state = states('sensor.hacs') %} {% if hacs_state not in ['unknown', 'unavailable', 'None', ''] %} {% set hacs_updates = hacs_state | int %} {% if hacs_updates > 0 %} {% set updates.list = updates.list + ['HACS updates beschikbaar (' ~ hacs_updates ~ ' pending updates)'] %} {% endif %} {% endif %} {% if updates.list | length > 0 %} Update(s) beschikbaar: {% for update in updates.list %} - {{ update }} {% endfor %} {% else %} Geen updates beschikbaar. {% endif %}"
data:
ttl: 0
priority: high
channel: Notify
mode: single
I hope somebody can help me out. Thanks in advance!
I am tired of debugging ChatGPT because it’s errors can be literally anywhere, so I did not dig deep. But the one below is pretty obvious. This line is nonsense: remove it entirely.
Hacs creates update sensors by the way, so that first trigger does not add anything much to begin with. Also, sensor.hacs has not existed anymore for a while now, so even if the trigger is now syntactically right, it still won’t do a thing. So that is three reasons ChatGPT produces nice looking nonsense in one trigger alone. Remove the first trigger completely.
Sorry, I can no longer stand to be polite where it comes to AI generated automations. It is not directed at you, I understand you need help to learn. That I do not mind, I love to help. Just ask here straight away, without ChatGPT.
Note that, once any update is found, it won’t trigger again until all updates are installed and then a new one is found. That is in the nature how triggers work, the first trigger won’t change that. The thing in the trigger needs to change from false to true for it to fire.
If you want to avoid that, you’d need to make a sensor with an update count, and trigger on that increasing. Those triggers are slightly more advanced than your regular ones.
i’m not sure i understand the question, it’s a little unclear. but if i take a guess what you’re saying is that you want to get a notification everytime an update for one of the update entities turn on. this template only checks for > 0. so that means it only fires when it goes from 0 something > 0. it doesn’t fire when it goes from 1 to 2.
if i understand your question right, i’m not sure there’s a super simple answer, but i think the way might be to create a input_number or to keep the old count. then trigger whenever the current count > that stored number… and update it each time it changes (including when the count decreases).
This is pretty much nonsense.
I can’t even figure out what you want to do.
Chat-bots reply in words / language and parrot what it finds.
It has no context to the actual computer language HA uses. It does what it does best (which it’s trained to do for writing text), and it makes shit up.
My suggestion would be to write down in words what you actually want to do, your goal for these actions. Then with that in hand, look at what other people trying to do a similar thing are doing using search. Tips on Searching for Answers & Duplicate Topics in the Forum.
Take a shot at writing what you can.
Then come back here with your goal and what you have tried and someone will be able to help you.