[Solved] Restart / Reload an integration with a button or automation or shell

I’am looking for a work around because of:

Is is possible to reload / restart an integration like “Harmony Integration” from shell/tty or internal by HA with an automation or button or a http:// call to HA?

How?

No one can tell me how to use the reload option of an integration from outside (by cron e. g.) or by an automation from inside HA?

I don’t believe that… :wink:

Where are the HA cracks? :pray:

The reason for my question was a harmony hub which disconnects from HA (or vice versa) from time to time and is not able to reconnect itself. I could not figure out why. Only a HA reboot or reload of the intergration fixes this (and only when harmony hub is in XMPP mode! Otherwise: HA restart is the only solution)

To close this issue with a valid answer / help: here are my results after some investigation:

One needs:
1.)
A long Auth Token which can be created in the user settings in the Webinterface of HA. Scroll down to the end of the page (may be very long sometimes), create, copy and save the token (a very large string)

2.)
The Entry-ID of the Integration which should be reloaded. Keep in mind: some Integrations need a HA restart after a reload. So this will not work with any integration. Check in in the webinterface of the integration if a reload only does the job or HA asks for a server reboot / reload.

3.)
Go for the entry id. This can be found in

~/.storage/core.config_entries

This is a hidden file and you should read / print it. Do not write to it (you’ve been warned). Search for your integration and pick the “entry_id”. Keep in mind: this ID may change on remove and re-install of your integration.

e.g:

            {
                "entry_id": "cdf9a0aabf56211a7ab3ad70ac9f32af0",
                "version": 1,
                "domain": "harmony",
                "title": "harmony-hub",
                "data": {
                    "name": "harmony-hub",
                    "host": "192.168.x.x1"
                },

4.)
Create a cron job in the OS or a shell command based trigger in HA. I would like to suggest to wrap the command line in a unix script and call that script

Use the system call as follows (replace the entry id and the Long Auth Code)

curl -X POST "http://192.168.x.x:8123/api/config/config_entries/<integration_entry_id>/reload" --oauth2-bearer "<Long_Auth_code_from_HA>"

e.g.:

curl -X POST "http://192.168.x.x1:8123/api/config/config_entries/entry/cdf9a04a22d234c7ab3ad70ac9f32af0/reload" --oauth2-bearer "ejkasjfkdjfdifjkdjgidsgjiortr43430lkjklfsd90dflkjklfjsdkjf09lkjkwejrjweopfksdljfweyJpc3MiOiIwNGUyYjgwODJlNzQ0MThkODgyN2I2MzgwOGIyYjNkMiIsImlhd"

One can also create a rest call in HA. Should also do. I do all my automations and “cron” in node Red, therefore no details here. Sorry.

Check your logfile while testing this call.

7 Likes

So if I were to try and implement this using an automation trigger, what’s the best way to determine that an integration is not working?

I have an intermittent problem with the connector to Control4 failing and in the integrations screen, it has a red border around it. Choosing Reload from the UI fixes it, so ideally I want to detect and automate this using the Shell script approach you have outlined here.

What’s the best way to determine that the integration has failed? Only thing I can think of for the minute is to check the state of one of the Control4 lighting circuits to see if it’s changed to “unknown”, or is there a specific way to check the status of an integration?

Thanks for your guides on the restarting steps, much appreciated.