Badges for addon service status

I removed the proxy settings inside my configuration.yaml and changed the long life token with new one. But the issue remain (status unknow)

Yes, I can see the front end (login page) if I connect to https://xyz.duckdns.org:8123 or https://xyz.duckdns.org from LAN and out of LAN.

With https://xyz.duckdns.org I get thiserror:

Error fetching data: <PreparedRequest [GET]> from https://xyz.duckdns.org/hassio/addon/core_samba/info failed with HTTPSConnectionPool(host='xyz.duckdns.org', port=443): Max retries exceeded with url: /hassio/addon/core_samba/info (Caused by NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0x6eda30d0>: Failed to establish a new connection: [Errno -3] Try again'))

With https://xyz.duckdns.org:8123 I get one:

Error fetching data: <PreparedRequest [GET]> from https://xyz.duckdns.org:8123/hassio/addon/core_samba/info failed with HTTPSConnectionPool(host='xyz.duckdns.org', port=8123): Max retries exceeded with url: /hassio/addon/core_samba/info (Caused by NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0x71802f50>: Failed to establish a new connection: [Errno 111] Connection refused'))

Hi silvrr, I made some research and seems that other people have my same issue.
What is your Home Assistant release?
Actuallly I’m on 0.92.2

Edit: just a little request. Please, could you share your background images? I really like your frontend theme.

92.0 currently. The method has been working for quite a few releases though.

https://github.com/SilvrrGIT/HomeAssistant/blob/master/www/background2.jpg

Thanks a lot for the background image.
About addons badge: actually works on your setup?

Hi threre, Trying to work with your Addon’s Sensor… But can’t really understand what should I put inside the “Authorization:”…?

You need to create a long lived token (LLT).

The authorization is Bearer + LLT

If my long lived token was 1234456789 then

Authorization: "Bearer 123456789"

would be the correct authorization section.

To pull a LLT, go to your user screen and scroll all the way to the bottom.

Still missing one thing…

In the Profile page, when I can create a LLT, I press on “create” and get a Box to enter something… I enter “Bearer njfjMNGJdfj 4r4…” , and when I press OK, I get a new ‘code’ , much longer…

Which one I need to use ? The one I wrote with the “Bearer” or the long one I got in result?

The long one you get in result.

It’s worth noting if you use the command line sensor you can just use the existing token within HA and just use the supervisor address making the package/config much more portable.

sensor:
  - platform: command_line
    name: lms
    command: 'curl -H "Authorization: $SUPERVISOR_TOKEN" http://supervisor/addons/local_lms/info'
    value_template: '{{ value_json.data.state }}'
    scan_interval: 5
1 Like

Hi, I put this in my configuration.yaml but I keep getting this error

Template variable error: 'value_json' is undefined when rendering '{{ value_json.data.state }}

Can anyone help me?

Post the full code using code blocks

  - platform: rest
    resource: http://10.0.0.25:8123/hassio/addon/bc9cb2be_cloudflare-argo/info
    name: cloudlflareargo
    value_template: '{{ value_json.data.state }}'
    scan_interval: 60
    headers:
      Authorization: !secret cloudflare_llt
      Content-Type: application/json

What does the json look like if you open that url in a browser?

Looks like this

if you go to that URL it’s returning that? That’s not json which the rest sensor is expecting hence the error

I think you need to change the rest URL to use the API:

http://10.0.0.25:8123/api/hassio/addons/bc9cb2be_cloudflare-argo/stats

[Variations of this work for me on several add-ons]

I get this error instead.

Template variable warning: 'dict object' has no attribute 'state' when rendering '{{ value_json.data.state }}'

Looks like there will be binary sensor on the next update. Thanks everyone!

Yeah, sorry, should still be going to the info path. Try this:

http://10.0.0.25:8123/api/hassio/addons/bc9cb2be_cloudflare-argo/info

It should return started if it’s running.

By the way, you can always try these commands from the Home Assistant command line using curl to see what JSON object is being returned to the sensor. So in this case you could try:

curl -X GET -H "Content-Type: application/json" http://10.0.0.25:8123/api/hassio/addons/bc9cb2be_cloudflare-argo/info -H "Authorization: <YOUR HA ACCESS TOKEN HERE>"

Then you can check the result to see that the JSON key you are looking for is actually present

For anyone stumbling across this like me:
Just like @phakorn mentioned, there is now a binary sensor for this that 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.

3 Likes