Trigger automation when Hassio addon starts/ stops

Hi,

Is there a way to trigger an automation when a Hassio addon stops or starts?

I was looking for a way to check the status of installed/ running Hassio addons but couldn’t find any info or examples.

Cheers.

1 Like

Found an answer on the Discord channel.

You can use the Homeassistant Rest API to check the status of a running addon.

Example:

http://hassio:8123/api/hassio/addons/addon_slug_name/info

Then you can simply extract the state attribute value from the result.

Hope this helps someone.

1 Like

@Kanishkaz were you able to get this into a sensor on the front end? If so can you share your config?

I ended up moving NodeRed into a separate docker container outside of Hassio, so I’m not using the sensor anymore.

But, this is what I had in my config at the time:

- platform: command_line
  name: Node-Red Status
  command: !secret node_sensor
  value_template: '{{ value_json.data.state }}'

Unfortunately, I don’t have a copy of the secret. But I believe it’s just the following url with my credentials.

http://hassio:8123/api/hassio/addons/addon_slug_name/info

You should be able to get the slug name by running the command “hassio su info” in ssh.

Hope that helps.

Hey there, does this method still work? I can’t get it to work… :frowning:

edit: nevermind, got it to work. If anyone reading this in the future is still interested, i can clean up my config files an share them :slight_smile:

Hi,
Could you share your config ?
I don’t get it to work.
THX :wink:

Hi,

Unfortunately I don’t use this automation anymore, so I don’t have it in my config.

But I think you can find the slug name by using the following command in the terminal:

ha addons

You can still use the REST API call I have included in my previous example. You just need to make sure you also pass in an Authorization header with a token.

Here’s another example I found from a different user.

Thanks,
I’ll try this

For anyone stumbling across this like me:
Nowadays there is a binary sensor which can tell you if an addon is running. You just have to enable it.
Go to Settings > Devices > Addon in question > Sensors > Running > Advanced Options > Enable.

Using the not_running trigger you can trigger on an addon stopping.

Feature was added here:

2 Likes

I’m new to Home Assistant and came across this thread when trying to find a trigger for an addon stopping. I didn’t the find feature to enable the binary sensor for that purpose. There is only a watchdog feature but no sensor that comes with it.

I also didn’t find this:

Has this feature been taken out of Home Assistant again or am I just not seeing where I can enable it? Under “entities” there is only a sensor for an addon update.

Hey, instructions above a bit unclear

Go to Settings > Devices & services > Devices > filter devices by supervisor, enter “addon device” from supervisor > enable running sensor

4 Likes

Thanks a lot! I was struggling to find this feature.

1 Like

Just seen this. Thanks for taking the time to document this.

Sadly this no longer works, at least for ESPHome.

The esphome_running entity remains in the running state even when stopping the addon, never mind when restarting it :frowning: