#Automation to detect updates has race condition somewhere?

1 messages · Page 1 of 1 (latest)

polar lintel
#

So I have this automation that reports to my phone when some updates are available:

alias: Notify user about device updates
description: >-
  Send a notification when devices have updates available, ensuring prompt
  action to keep all systems current.
triggers:
  - trigger: template
    value_template: |-
      {{ states.update
        | selectattr('state', 'eq', 'on') 
        | map(attribute='entity_id')
        | list
        | count > 0 }}
conditions: []
actions:
  - action: notify.my_phone
    metadata: {}
    data:
      title: New update available
      message: >
        Updates: {{ states.update | selectattr('state', 'eq', 'on') |
        map(attribute='attributes.title') | list | join(', ') }}.
mode: single

It works fine, but I've got twice in the past few days message Updates: None. Which to me it means that at the trigger time, states.update was evaluated, but the variable somewhat wasn't used in the action.

Is there a race condition somewhere?

When I look in the updates page, indeed there is an update available.

Also activity looks to be normal. No glitch there

torpid tinsel
#

Look at the trace for the automation. It should have the trigger variable defined, which will contain the to_state of the update entity that caused the trigger to fire. Does that entity have a title attribute?

polar lintel
#

It does have the title attribute, but it is NULL.

  to_state:
    entity_id: update.alarmo_card_update
    state: 'on'
    attributes:
      auto_update: false
      display_precision: 0
      installed_version: v1.6.4
      in_progress: false
      latest_version: v1.6.5
      release_summary: null
      release_url: https://github.com/nielsfaber/alarmo-card/releases/v1.6.5
      skipped_version: null
      title: null
      update_percentage: null
      friendly_name: Alarmo Card update
      supported_features: 23

This to me still doesn't explain why the state was set to on as you can see above, which is the trigger source, but then in the automation variable, it was not set as on since the template didn't filter it.

#

Maybe the states.update wasn't refreshed before actions were called.

full thorn
#

I know that it would only hide the problem, but you could consider adding a 1s delay (or even shorter) before sending the message
would be interesting if that would work

for testing you could additionally add the wait and another message just to check if you get two different ones

polar lintel
#

It is not easy to reproduce this but I agree with 1s delay it will likely wor

#

k

#

I will try to send message, add delay, and send it again after, if there will be difference

#

My new actions, but now we wait

actions:
  - action: notify.my_mobile
    metadata: {}
    data:
      title: New update available
      message: >
        Updates: {{ states.update | selectattr('state', 'eq', 'on') |
        map(attribute='attributes.title') | list | join(', ') }}.
  - delay:
      seconds: 1
  - action: notify.my_mobile
    metadata: {}
    data:
      title: New update available
      message: >
        Updates: {{ states.update | selectattr('state', 'eq', 'on') |
        map(attribute='attributes.title') | list | join(', ') }}.
torpid tinsel
polar lintel
#

ok I see, so it is rather entity issue or the fact that I check the wrong attribute. Next one might be friendly_name maybe