Add service integration.reload

How did you get the reloading part to work?

Mine is for a different integration…

UPDATE 02/16/23: There is an updated simpler way doing this that I posted here: Add service integration.reload - #160 by skynet01

OLD WAY:

but it does work if I manually trigger it

Set up automation like this:

- id: auto_reload_emporia
  alias: "Keep Emporia running" 
  mode: single
  description: 'Check if Emporia is down'
  trigger:
  - platform: state
    entity_id: sensor.power_av_closet_6 # use any entity that is an emporia device / channel 
    to: unavailable
    for: 00:05:00
  - platform: template #check if any sensor gets stuck on the same number for 10 min
    value_template: "{{ as_timestamp( utcnow() ) | int > as_timestamp( states.sensor.power_pelican_123.last_changed ) | int + 10*60 }}"
  condition: []
  action:
  - service: rest_command.reload_emporia
    data: {}

Then in your main config file

rest_command:
  reload_emporia:
    url: http://[IP]:8123/api/config/config_entries/entry/[entry_id]/reload 
    method: POST
    headers:
      authorization: 'Bearer [Long-Lived Access Token]'
      content-type: 'application/json'
  1. [IP] = home assistant ip
  2. [entry_id] = go to config/.storage/core.config_entries search for emporia_vue you will see entry_id as the first record
  3. [Long Lived Access Token:] = Token can be created in the HA menu under your instance name. Yes there is a space between Bearer and the actual token
5 Likes

the whole idea behind this thread was the reload function, so you should not need/use the rest_command at all, and instead be using homeassistant.reload_config_entry service

2 Likes

Just need to verify, what’s the proper way of placing the long live access token?

rest_command:
  reload_aqara:
    url: http://192.168.1.40:8123/api/config/config_entries/entry/62dbc0b5edd9b3026b9078d199cb335c/reload 
    method: POST
    headers:
      authorization: eyJ0eXAiOiJblablalongaccesscode
      content-type: application/json

So it should it be like this?

rest_command:
  reload_aqara:
    url: http://192.168.1.40:8123/api/config/config_entries/entry/62dbc0b5edd9b3026b9078d199cb335c/reload 
    method: POST
    headers:
      authorization: 'Bearer eyJ0eXAiOiJblablalongaccesscode'
      content-type: application/json

hi @Mariusthvdb for the lovelace ui code, how do you key in for the rest of integration logo in your list other than ‘Luftdaten’ & ‘Philips’?

It should be like the second example with the word Bearer and a space before the token

homeassistant.reload_config_entry does not allow you to reload integrations that’s why rest_command is needed.

it allows you to reload config entries. which are integrations you setup via the UI config.

1 Like

Welp… you were right, thanks for telling me about this. I guess you just reference an entity to this service and it will automatically reload the automation that’s connected to it. Pretty sweet!

only thing you’ve got to remember is that when an integration has more entries, you have to reload those individually

Schermafbeelding 2021-09-06 om 09.43.53

just like you would have to do in the UI (click the entry, click 3 dots, and then click reload )

I’d LOVE to have this.
Some integrations would just stop working at some point and manually reloading is almost the solution to everyone of em.But having a nice automation to do this for me would be a much nicer touch.

Thank you guys.

This is already supported use " homeassistant.reload_config_entry" command, give it an entity that’s connected to an integration and integration will be reloaded

I’ve tried this, my case is the Eufy Security integration through HACS. I’ve tried Rest API and even a shell command to run curl. Neither would reload the integration

And Ann me to the list of wanting an integration.reload function

Do you have a reload option available on the integrations page? Not all integrations support reloading, if you don’t see a reload option for that integration on the main page then Rest Api or homeassistant.reload_config_entry will not work.

1 Like

No it has the option to reload. And doing so fixes the issue. Just can’t find a way to automate it

I am looking for this as a use case for restarting/reloading and integration (not an addon), in homeassistant. Can you tell me where and how I can get the “ID” of an integration? Thanks

Right, that’s exactly what the service I linked does. When you add an integration in Home Asssistant it creates a config entry. That’s how it keeps track of what integrations you have added to your particular instance and what values you entered for any settings of that integration. This distinction is also how you are able to add some integrations multiple times (multiple config entries for one particular integration)

Since that post about 6 months ago the service appears to have changed since then. It no longer accepts a config entry ID, instead it accepts the ID of an entity, device or area created for a config entry (i.e. integration). It then uses that to find the corresponding config entry and reloads it.

So you no longer need Node RED for this. Just go to the integration you want to reload with an automation and find an entity connected to it, then use homeassistant.reload_config_entry and pass it to it. You can also get device and area IDs in templates now if you prefer.

though this topic is long closed… I dont understand why you would say that. As someone using:

  reload_tradfri_integration:
    alias: Reload Tradfri integration
    mode: restart
    sequence:
      service: homeassistant.reload_config_entry
      data:
        entry_id: 37702redacted51

multiple times a day (hope the next dev will see a bump in the tradfri library and this wont be needed any longer…) I can say it still works just fine with the entry_id

it only accepts an entry_id:

The thing is I DO want to use node-red :-)…

So this should reload the integration of which the entity is part?

1 Like

Ah gotcha. Yea that’s my understanding. I haven’t used it in a while, I forget what I was doing when I posted that. But based on what others have said above and the doc of that service that should do trick.