WTH is there no "reload integration" service?

Some devices in some integrations become unavailable sometimes, and a simple reload integration resolves the issue.

It would be great if we had a service call for reload integration so we can create an automation that does that automatically.

That already exists!

It is the homeassistant.reload_config_entry service.

Open your Home Assistant instance and show your service developer tools with a specific service selected.

15 Likes

It doesn’t always work. Tuya2 integration fails to reload after it has been running for a few hours.

That is not the reload service at fault I would say.

Please note: It is not normal to have to reload an integration. Those should be considered regular bugs.

1 Like

I know… It’s a shitty integration created by a even shittier company.
Never again Tuya, never again…

My reasoning was, is there something that can be done to the reload that makes even Tuya2 reload properly?

Right, but the WTH question was: “WTH is there no “reload integration” service?”
And the answer to that is: It already exists.

3 Likes

Agree! There is.

Can’t believe I missed that service, thanks @frenck!

1 Like

Maybe not the most instructive name as I had to search the forum for the same thing and found this. For me that just ment something completely different…

1 Like

This is a very well hidden feature. The website just gives a veneer of documentation.

How do I reload the nextcloud integration? It takes longer to start than even HA so after a complete server restart it’s lagging behind and HA complains about being unable to reach it.

Found this thread and was temporarily happy.
Using

service: homeassistant.reload_config_entry
data:
  entry_id: nextcloud

of course produces an error - I don’t know the integration’s ID (and obviously it’s not the configuration.yaml name).

.
So I read the above mockumentation

Service data attribute Description
entity_id List of entity ids used to reference a config entry.

and came to the conclusion to just enter ANY of the integration’s entity_ids to get it done.
But… nada.

WTH?!?

4 Likes

You can get the entry_id in the core.config.entities file located in the .storage folder. There may be a easier way, but you can definitely get it there.

image

3 Likes

Thank you for your hint.
I already looked there; .storage/core.config_entries contains just the integrations managed through the UI; nextcloud is YAML.
Found nothing in .storage/core.device_registry, nothing in .storage/core.entity_registry.

Very well hidden @frenck. :face_with_raised_eyebrow:

4 Likes

I followed the link which @Frenck added here in the post and it works as a charm. Just follow the link. I made a automation and a script with it and it perfectly works !

You made an automation reloading a YAML-only integration with the link Frenck provided?
Would you mind sharing it here?

2 Likes

I will share my script to reload. As said earlier I followed the link of Frenck. Selected the device (you can find the device name in your Devices. I made a automation for reload on time and a script which I use for a button card. Here is the script.yaml:

alias: Reload Huawei B535-232
sequence:
  - service: homeassistant.reload_config_entry
    target:
      device_id: 5d8254e71f159783b8c2b56990e037f7
    data: {}
mode: single
icon: mdi:autorenew
1 Like

Hmm, you’re reloading a UI-configured device-bound integration.
My need is the reload of a YAML-configured device-less integration without a device_id (from .storage)…

2 Likes

Well you beat me here

Have you gotten anywhere with this issue? I need to reload the “Onkyo” Integration, which is also a YAML-configured integration. Calling

service: homeassistant.reload_config_entry
target: {}
data: 
  entity_id: media_player.receiver

returns a “unknown error”, perhaps either because this doesn’t work for YAML-integrations or because the Onkyo integration does not create unique IDs for the media_player entities and has no option to do so.

And yeah, there is already a open github issue for the Onkyo integration because it requires the Onkyo receiver to be powered and connected while Home Assistant reboots, if its not, entities for Zone2 and Zone3 are getting deleted. This is rather frustrating and there seems to be no solution.

Any suggestions on how to automate this to occur for a specific device/config entry after a restart of Home Assistant?
I have an automation to restart the HA host weekly and have an integration that tends to need a reload to properly display the data in my dashboard.
I’d like to reload that integration after the restart, and once everything is up and running again.

That being said…

automation:
  - id: hass_reload_device_integration
    trigger:
      - platform: homeassistant
        id: startup
        event: start
    action:
      - service: homeassistant.reload_config_entry
        target:
          entity_id: cover.garage_door 

Obviously use an entity id from the integration you want to reload.

1 Like