$SUPERVISOR_TOKEN
is like a system variable. No need to define a token! Just use that template verbatim. I don’t know if it can be used in the rest Authorisation option though. I suspect not.
finally! with that info I could use this thread Update notifications! Core, HACS, Supervisor and Addons and the sensor:
- platform: command_line
name: Supervisor updates
command: 'curl http://supervisor/supervisor/info -H "Authorization: Bearer $SUPERVISOR_TOKEN" | jq ''{"newest_version":.data.version_latest,"current_version":.data.version,"addons":[.data.addons[] | select(.version != .installed)]}'''
value_template: >
{{value_json.addons|length}}
json_attributes:
- newest_version
- current_version
- addons
to pull all info from supervisor I was looking for. Only thing is:
None od my add-ons seem to be there… I noticed something this morning already when installing the Portainer, and all it could find was the hassio_observer
where have they all gone?!?
The home assistant containers are hidden by default. Read the portainer addon docs, it tells you how to un-hide them. I’d tell you but it’s ages since I did it and I’ve forgotten.
ok I will, but is that the same reason they don’t show up in the sensor?
No, probably not. Just a sec. Let me check my addon sensor.
EDIT: I don’t see any addons listed either. I think that attribute only shows addons with updates available.
ok thanks.
as for the Portainer if you have time… I did find the hidden containers, but can only Remove them
and the Add-ons are listed as Images:
They are not the containers. They are the instructions to hide the containers.
Access to these containers can be gained by going into Portainer → Settings → Hidden containers. Then delete the listed hidden labels (io.hass.type labels). Only do this if you know what you’re doing!
Tom,
Why are you dividing by 4? That sensor tells you how much CPU is used by supervisor. Why does the number of cores matter?
Also I have similar for all addons etc… check my system monitor package in my repo.
Because the report returns the sum of all cores.
Ok but if supervisor is telling you CPU percentage then can that not be spread over 4 cores?
Yes it can, which is why you have to divide by 4 to get a real percentage. Consider this, if the process is using 100% of all 4 cores it is reported as 400%, which is kinda daft. Hence to get a real pet-cent (per 100) you divide by the number of cores. Thus it is now reported as 100% use of the total available cpu resources.
If the process was using 100% of one of four cores, this would now be reported as 25% instead of 100%.
Reporting 100% if not dividing by 4 may mislead you into thinking all resources are used unless you remember the total available is (the mathematically improper) 400%.
Ok. I would have assumed and expected that it was taking that into account. I will have to investigate this on my system.
It’s definitely using the sum of the cores on my system, I used to see usage in excess of 200%. Also see: https://discord.com/channels/330944238910963714/332167321311510530/766620091302412300
Also I may have a way to implement these sensors over https locally using the rest sensor (less overhead than the command line sensor). Testing today…
Ok so you can use an https local api endpoint if you set verify_ssl
to false
an use this endpoint shown below.
Core and Supervisor (set the template divisor to the number of threads your CPU supports):
- platform: rest
resource: https://homeassistant:8123/api/hassio/core/stats
name: Core CPU
unit_of_measurement: '%'
value_template: '{{ (value_json.data.cpu_percent|float/4)|round(2) }}'
scan_interval: 60
verify_ssl: false
headers:
Authorization: !secret ha_api_token
Content-Type: application/json
json_attributes_path: "$.data"
json_attributes:
- memory_percent
- platform: rest
resource: https://homeassistant:8123/api/hassio/supervisor/stats
name: Supervisor CPU
unit_of_measurement: '%'
value_template: '{{ (value_json.data.cpu_percent|float/4)|round(2) }}'
scan_interval: 60
verify_ssl: false
headers:
Authorization: !secret ha_api_token
Content-Type: application/json
json_attributes_path: "$.data"
json_attributes:
- memory_percent
- platform: template
sensors:
core_memory:
friendly_name: "Core RAM"
value_template: "{{ state_attr('sensor.core_cpu', 'memory_percent') }}"
unit_of_measurement: '%'
supervisor_memory:
friendly_name: "Supervisor RAM"
value_template: "{{ state_attr('sensor.supervisor_cpu', 'memory_percent') }}"
unit_of_measurement: '%'
Addon
- platform: rest
resource: https://homeassistant:8123/api/hassio/addons/core_duckdns/stats
name: DuckDNS CPU
unit_of_measurement: '%'
value_template: '{{ (value_json.data.cpu_percent|float/4)|round(2) }}'
scan_interval: 60
verify_ssl: false
headers:
Authorization: !secret ha_api_token
Content-Type: application/json
json_attributes_path: "$.data"
json_attributes:
- memory_percent
- platform: template
sensors:
duckdns_memory:
friendly_name: "DuckDNS RAM"
value_template: "{{ state_attr('sensor.duckdns_cpu', 'memory_percent') }}"
unit_of_measurement: '%'
Secret (Long Lived Access Token, set in your profile):
ha_api_token: "Bearer eyJ0eXA..."
would you know of a way to get this working over the local resource, (vs the now configured duckdns resource) in
- platform: rest
name: Hassio Rpi4 config
resource: !secret resource_hassio_rpi4_config
value_template: > #components|list|count}}
{{value_json.version}}
json_attributes:
- components
- unit_system
- config_dir
headers:
Content-Type: application/json
Authorization: !secret api_bearer_token
User-Agent: Home Assistant REST sensor
scan_interval: 3600
and resource:
https://redacted.duckdns.org:1234/api/config
?
tried a few endpoints but with no real luck so far…or should I simply use that
https://homeassistant:8123/api/config
cant be that simple??
update
no it can’t…
anyone got the Portainer add-on working?
this is the info
- description: Manage your Docker environment with ease
icon: true
installed: 1.2.2
logo: true
name: Portainer
repository: a0d7b954
slug: a0d7b954_portainer
state: stopped
version: 1.2.2
so I am using
- platform: command_line
name: Stats Portainer
command: >
curl -sSL -H "Authorization: Bearer $SUPERVISOR_TOKEN" http://supervisor/addons/a0d7b954_portainer/stats
unit_of_measurement: '%'
value_template: >
{{value_json.data.cpu_percent}}
scan_interval: 60
json_attributes:
- data
like on all other add-ons, but this one remains Unknown. Even after having started the add-on.
btw Ive tried to go ups 1 branch in the resource too and use
http://supervisor/addons/a0d7b954_portainer
and adjusted the value_template too, but still nothing happening.
it can be if
right! thanks, can confirm this works indeed:
- platform: rest
name: Hassio Rpi4 config local
resource: https://homeassistant:8123/api/config
value_template: > #components|list|count}}
{{value_json.version}}
verify_ssl: false
json_attributes:
- components
- unit_system
- config_dir
headers:
Content-Type: application/json
Authorization: !secret api_bearer_token
scan_interval: 3600
very nice, hope this makes it easier at startup.
Good idea. Wish there was a component that automatically shows together the CPU and RAM usage of all components (Supervisor, Core, Addons, …)
BTW how do you get the Network Interface throughput?
Nevermind, found that system monitor can create sensors for network interfaces
Tom
What are the units for network_tx and _rx in the cli stats command?
On a side note, I’m restoring a 11GB backup on a NAS to a new bigger SSD. I started with a fresh install (Generic X86-64) and selected Restore at the start. It’s been going for over 24 hours! Is there any way how far I can tell it’s got?