home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.

Home Page:https://www.home-assistant.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Checking for Updates before atomation are loaded causes new update entities to not trigger automations when state changes during core startup

Lumute opened this issue · comments

The problem

I have a few automations with triggers based on the new Update Entities, one of them being this popular blueprint (link) and the rest manually created. They work well most of the times but I have noticed a couple of times that I have pending updates yet those automation were not triggered and after a little bit of troubleshooting I realized that this is happening when there is a new update available but before the automated update check happens I restart Core for some other unrelated reason (HACS integration update, etc.).

The issue seems to be that supervisor checks for updates (and changes the state of the new update entities) during startup, before automations are loaded.

I would suspect triggering automations (and thus notifications) are a very important use case for the new update entities.

I think adding a delay (or check) so supervisor does not check for updates until Core has finished loading everything (mainly automations) would fix this and make the use of the update entities much more reliable.

What version of Home Assistant Core has the issue?

2022.5.5

What was the last working version of Home Assistant Core?

No response

What type of installation are you running?

Home Assistant Supervised

Integration causing the issue

Supervisor

Link to integration documentation on our website

https://www.home-assistant.io/integrations/hassio/

Diagnostics information

No response

Example YAML snippet

alias: 'System: Update Add-On Clone''s repo when the Original repo updates'
description: ''
trigger:
  - platform: state
    entity_id:
      - update.z_wave_js_to_mqtt_update
    to: 'on'
condition: []
action:
  - service: shell_command.update_local_addon_clones
    data: {}
mode: single

Anything in the logs that might be useful for us?

No response

Additional information

It is easy to reproduce this:

1- Wait until you have an update
2- Create an automation based on the update entity with an update pending
3- Use the Developer Tools to manually change the state of that update entity to "off" and restart cor before supervisor automated update check happens.
4- Notice that the update is detected during startup yet the automation didn't trigger.

Hey there @home-assistant/supervisor, mind taking a look at this issue as it has been labeled with an integration (hassio) you are listed as a code owner for? Thanks!
(message by CodeOwnersMention)