How to automatically reload integration on a schedule?

Is there a simple way to force an integration to reload on regular schedule, for example every night at 2 am?

1 Like

Use an automation something like this (assuming it is an integration setup in the UI).

description: "Reload xxx integration @ 2am"
mode: single
trigger:
  - platform: time
    at: "02:00:00"
condition: []
action:
  - service: homeassistant.reload_config_entry
    data:
      entry_id: ad7f562e4ef537e1bf858335aae4002e

The config entry id is found in config/.storage/core.config_entries for the one you want to reload.

13 Likes

You can also get entry_id using the config_entry_id filter.

4 Likes

Thank y’all!

is this write in to automations.yaml ?

i was edit to every 3 hours instead of time

the code below correct ?

  • description: “Reload Tuya integration @ 3hours”
    mode: single
    trigger:
    • platform: time_pattern
      hours: “/3”
      condition:
      action:
    • service: homeassistant.reload_config_entry
      data:
      entry_id: 635ee76a799ddf6fb8e8a6efe0852786

i was edit to every 3 hours instead of time

the code below correct ?

- description: "Reload Tuya integration @ 3hours"
  mode: single
  trigger:
   - platform: time_pattern
     hours: "/1"
  condition: []
  action:
   - service: homeassistant.reload_config_entry
     data:
       entry_id: 635ee76a799ddf6fb8e8a6efe0852786
1 Like

It also makes sense to reload the integration in case that entity or entities from that integration become unavailable:

alias: Restart TuyaLocal integration
description: TuyaLocal integration reload in case of error.
trigger:
  - platform: state
    entity_id:
      - switch.tuyalocal_toaster
    to: unavailable
    for:
      hours: 0
      minutes: 0
      seconds: 30
condition: [ ]
action:
  - service: homeassistant.reload_config_entry
    data:
      entry_id: GUID from config/.storage/core.config_entries
mode: single
2 Likes

If you format your code correctly people would get even more help from your post :slight_smile:

1 Like

Folks,

Was following along in this thread, but got really lost with locating the entry_id and hope one of you kind souls can help me.

No idea where this goes… anyone?

I cannot find the config/.storage directory anywhere?

All help greatly appreciated :yum:

The following service call, to reload an integration, requires that you provide it with the integration’s entry_id.

- service: homeassistant.reload_config_entry
  data: 
    entry_id: ad7f562e4ef537e1bf858335aae4002e

There are several ways to find an integration’s entry_id. One way is to use the config_entry_id filter. As per its documentation, it requires that you supply it with the entity_id of any entity that belongs to the integration.

- service: homeassistant.reload_config_entry
  data: 
    entry_id: "{{ config_entry_id('sensor.whatever') }}"

Have you found the configuration.yaml file? The .storage directory is a hidden sub-directory of the directory containing the configuration.yaml file.

4 Likes

Thanks for the help, managed to find it and identified the entry id.

Great, thanks. Sometimes TuyaLocal devices become unavailable, can skip automations and lose data before noticing.

Took me a minute to understand, as I was looking for an integration id to restart the integration.

Confirmed that If you just use an entry_id it will restart the associated integration.
I wanted to use this when my blinds integration went offline for all blinds.
So using just one blind entry will trigger the integration restart to fix all blinds in the integration.
Works well. Thank you

1 Like

Apologies for replying on an old thread but I’ve been searching for the last few hours for a way to reload (only) a HACS integration (wyzesense) that doesn’t create any of its own entities and it instead updates some binary_sensor entities. Any hints? Thanks