When I click “Reload Integration” it works as expected. Is there a way to get notified when the integration fails or to retry the load after some seconds?
I was checking in the developer menu but I can not find anything about it.
If it occasionally fails to load on startup, you can create an automation that is triggered on startup, waits 1 minute, then checks if one of the integration’s entities has a valid value (is not unavailable).
If it is unavailable, the automation reloads the integration.
I didn’t suggest finding an integration’s state. I suggested you check the state of one of the entities that are produced by the integration.
Go to Settings → Devices & Services → Integrations.
Click on the Xplora Watch integration and it will list the number of devices and entities it produces. You want to use one of those entities, specifically an entity whose state is unavailable, or doesn’t exist, when the Xplora Watch integration fails to load.
You can check the state of a config entry (i.e. an integration) with the config_entry_attr(config_entry_id, 'state') function. I can’t find a list of expected return values, but when your integration fails like this it will probably return something like ConfigEntryState.SETUP_ERROR. Should be easily verifiable in Developer Tools > Template.
Yes, using an automation to detect when it’s necessary to reload it (using either of the techniques suggested by me and Mayhem_SWE) and then proceed to reload the integration (using the action described in Mayhem_SWE’s post).
I want to check that the value is different but I do not find how to do it, comparing it to loaded or 'ConfigEntryState.Loaded always return false there.
Yeah this is a bit weird. config_entry_attr(config_entry_id, 'state') is string results in false, so it must be some other type of object that gets stringified to ConfigEntryState.LOADED etc. at the time the template is rendered.
What kind of object? I really have no idea how to figure that out to be honest. Kind of annoying that there is no type filter similar to how it would work in native Python.
What I did figure out though, is that if you force stringification earlier it with a string filter, then the comparison does work: