Can I write an automation to reload/restart an integration?

I use OctoPrint and, as I turn off the 3D printer when it is not in use, a lot of entities get stuck “unavailable”.
I found this topic when I was searching to write an automation to reload the integration.
While I did not find one to reload the integration, the solution to OctoPrint for me was using service HOMEASSISTANT.RELOAD_CONFIG_ENTRY, Home Assistant Core Integration - Home Assistant (home-assistant.io)
One entity of Octoprint responds even with power cycling the printer, the status of the printer, so I used that as a trigger and reloaded the entire entity using the homeassistant.reload_config_entry option.
It works for a per device and reloads all entities of that device.
I certainly would not want to muck around doing this for ZigBee though given I have over 40 ZigBee devices.

A reload Integration service would definitely be helpful.

1 Like

Thanks for this.

I noticed that it helped to reload the Unifi integration after any update to Unifi Network.

Now I don’t have to remember as it will trigger an automation when my routers device track makes itself unavailable.

1 Like

I haven’t had the issue with Unifi yet, but will keep an eye on it. I may do the same thing as a precaution :slight_smile:

Following the Early Access channel means frequent updates. Digging my own grave ? :thinking:

1 Like

Never use Early Access in a prod environment, or an environment where a partner may be involved.
Anyway, that is a bit off topic and I don’t want to hijack another thread lol

Great tip.
I also turn off my printer when it is not in use ( Ender 3 ) and everytime I launch HA and my printer is OFFLINE I get error that HA could not make connection with Octoprint!

I`m using MQTT plugin within Octoprint so I think I do not need the Octoprint integration. Just deleted it.

I`m haging issues with ESPHOME and ZIGBEE they turn unavailable multiple times per day and I wonder if it is not due to the Octoprint integration. Will see, just deleted the bloody Octoprint integration.

Always worth a try. You can always add the integration back if you need to :slight_smile:

Same Problem with Meross Mss310 (Energy Monitoring). I think it’s because of calling too much for information. I experienced same thing when I wanted to make a script flash the lights (switch), it just made the Plugin stop working, probably because of overload.

Don’t know how to fix the request problem right now (limitation of request probably) so I thought of the easy way… Reload the Plugin :smiley:

I will play with the rate and burst limits a bit and see if that helps.
I will report, maybe that helps others too.

I ended up switching to Meross LAN, which entierly solved it.

Some of my integrations also need reloading from time to time (Wiser, IKEA) and I’m really interested in a solution to this. Am thinking a button to reload a specific integration and an automation to “press” that button.

+1 for integration reload

1 Like

+1, I have the issue where zwave stuff stops working on upgrading the integration.

I need to restart MQTT and then Zwave and want to do that on server restart, since for some reason a restart is not enough :slight_smile:

EDIT:
Just noticed it now exists, Call service “Restart Add-ON”.

I believe integrations are different from addon’s. Restart Add-on has been available for a while.

I don’t think there is a service to restart Integrations.

I frequently need to restart the Home Connect integration. I’m using the Reload Config Entry service twice a day now, and I’ve not needed to restart the integration itself since implementing this. You might be able to use Reload Config Entry in a similar way - it’s worth a try.

1 Like

I had troubles with my tuya integration. Somehow the temperatures shown only were correct in the first moments after a restart or reloading the config. After that the temps were way off so scripts to set the temp on my floor heating were firing at the wrong temps. Since I couldnt get a fix on the temps and it wasn’t a fixed offset that needed to be applied I now use a reload script like mention above by @arrows and it looks like this:

alias: Reload Tuya integration every few minutes
description: ''
trigger:
  - platform: time_pattern
    minutes: '1'
condition: []
action:
  - service: homeassistant.reload_config_entry
    data: {}
    target:
      entity_id:
        - climate.ty88632848c82xxxxxx
        - climate.ty4220004198f4xxxxxx
mode: single
6 Likes

There does appear to be one, but it restarts all of them. Call Service → Home Assistant Core Integration: Restart

Looks like I’m not the only one affected by Tuya stalling. :smiley: Same issue brought me here, thanks a lot for the tip. Mine is with doors sensors stopping to report statuses though.

1 Like

I’m afraid I have that problem as well. It seems to be a seperate problem from the Tuya issue, since my door sensors (aqara) connect to a Conbee II dongle, and I use a couple of IKEA range extenders to increase the range. Works most of the time, but one of the least used doors sometimes just goes unavailable. So annoying.

Same here, im looking into way to restart the Tuya service as my device status stops updating after about 8 hours

Check out my workaround here, does the job perfectly for me: