Is there any way I can get the installed supervisor, dns and audio versions as a sensor? I can get the available version but don’t see a simple way to find out what version is installed other than by using ssh and I would like it as a sensor so I can get an automation to tell me when there is a new version.
Normally these just update automagically but on a dev instance I have it didn’t this week. I was running version 1 dns instead of version 3 and didn’t know… but this broke everything until I realised I needed to update it. So I’d like a sensor that returns the installed version.
Seems I should be able to use something like this?
echo ha su info | docker exec addon_a0d7b954_ssh /bin/bash
but that returns a blank…
If I
docker exec -it addon_a0d7b954_ssh /bin/bash
and then execute
ha su info
I get all the info I need…
But how do I make that a shell command?
EDIT:
This seems to work:
docker exec -it addon_a0d7b954_ssh ha su info
curl -X GET \
-H "Authorization: Bearer token" \
-H "Content-Type: application/json" \
http://10.90.11.100:8123/supervisor/info
returns 404
same if I use /api/supervisor/info
Tried
- platform: rest
resource: http://IP_ADDRESS:8123/api/supervisor/info
headers:
Authorization: !secret my_sensor_secret_token
[ 12:15 PM ]
SyncWorker_8) [homeassistant.components.rest.sensor] Error fetching data: http://10.90.11.100:8123/api/supervisor/info failed with HTTPConnectionPool(host=‘10.90.11.100’, port=8123): Max retries exceeded with url: /api/supervisor/info (Caused by NewConnectionError(’<urllib3.connection.HTTPConnection object at 0x7f04e9802b10>: Failed to establish a new connection: [Errno 111] Connection refused’))
francisp
(Francis)
April 4, 2020, 3:09am
5
That is a normal error when restarting Home Assistant. I guess it happens because the sensor is ready before the rest platform is set up. I have a similar sensor to see if letsdnsocloud is running, always get this error when restarting. Next time the sensors polls (after 10 minutes), it works.
No it’s not normal… it is an ERROR not a warning and it doesn’t work at all. Connection refused… you can wait forever and it won’t connect.
I have something wrong with the command.
francisp
(Francis)
April 4, 2020, 3:46am
7
Ok, then I don’t know either
francisp
(Francis)
April 5, 2020, 6:27am
9
For supervisor (just stole it from another thread)
# Sensor to track available updates for supervisor & addons
- platform: command_line
name: Supervisor updates
command: 'curl http://supervisor/supervisor/info -H "Authorization: Bearer $(printenv 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
1 Like
Thanks for that… I will try that tomorrow when my PC is on. Looks odd though…
Ok. Thanks! I ended up settling on this (also wanted dns and audio containers. I had a DNS that was out of date for unknown reasons last week and it caused a lot of grief)
- platform: command_line
name: Supervisor updates
command: 'curl http://supervisor/supervisor/info -H "Authorization: Bearer $(printenv 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
- platform: command_line
name: DNS updates
command: 'curl http://supervisor/dns/info -H "Authorization: Bearer $(printenv SUPERVISOR_TOKEN)" | jq ''{"version":.data.version,"version_latest":.data.version_latest }'''
value_template: "{{ value_json.version }}"
json_attributes:
- version
- version_latest
- platform: command_line
name: Audio updates
command: 'curl http://supervisor/audio/info -H "Authorization: Bearer $(printenv SUPERVISOR_TOKEN)" | jq ''{"version":.data.version,"version_latest":.data.version_latest }'''
value_template: "{{ value_json.version }}"
json_attributes:
- version
- version_latest
1 Like
bschatzow
(Bill Schatzow)
April 20, 2023, 9:26am
13
Do these still work for you? Since 2023.4 x I now get no information showing on my markdown card.
Thanks.
From these sensors I have a Markdown card that would display all the versions install on HA.
- type: markdown
title: Are Updates Available?
card_mod:
style: |
:host {
--card-mod-icon-color: #42a5f5;
font-size: 1.1em;
}
content: |
<ha-icon icon="mdi:home-assistant"></ha-icon> Add-ons needing update: {{ states('sensor.supervisor_updates') | default }}
> {% for addon in state_attr('sensor.supervisor_updates', 'addons') %}
> {{ addon.name }} {{ addon.version }} -> {{ addon.version_latest }}
> {% endfor %}
<ha-icon icon="hacs:hacs"></ha-icon> HACS updates available: {{ states('sensor.hacs') | default }}
> {% for repo in state_attr('sensor.hacs', 'repositories') %}
> {{ repo.display_name }} {{ repo["installed_version"] }} -> {{ repo["available_version"] }}
> {% endfor %}
| | Current | | Latest |
|--- |:---: |:---: |:---: |
| **Supervisor** | {{ state_attr('sensor.supervisor_updates', 'current_version') }} | | {{ state_attr('sensor.supervisor_updates', 'newest_version') }} |
| **HassOS** | {{ states('sensor.home_assistant_operating_system_version') }} | | {{ states('sensor.home_assistant_operating_system_newest_version') }} |
| **CORE** | {{ states.sensor.updater_core.attributes.current_version }} | | {{ states.sensor.updater_core.attributes.newest_version }} |
| **Audio** | {{ states.sensor.updater_audio.attributes.current_version }} | | {{ states.sensor.updater_audio.attributes.newest_version }} |
| **CLI** | {{ states.sensor.updater_cli.attributes.current_version }} | | {{ states.sensor.updater_cli.attributes.newest_version }} |
| **DNS** | {{ states.sensor.updater_dns.attributes.current_version }} | | {{ states.sensor.updater_dns.attributes.newest_version }} |
| **Multicast** | {{ states.sensor.updater_multicast.attributes.current_version }} | | {{ states.sensor.updater_multicast.attributes.newest_version }} |
| **Observer** | {{ states.sensor.updater_observer.attributes.current_version }} | | {{ states.sensor.updater_observer.attributes.newest_version }} |
All that shows now is the title of the card.
The sensors are working fine but I’ve never used a markdown card to display them in the frontend… just a normal entity in a fold entity row