Sensor for Version (Supervisor, DNS, Audio)

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’))

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.

Ok, then I don’t know either :frowning:

Bumping…

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

Thanks for that… I will try that tomorrow when my PC is on. Looks odd though…

See this topic:

1 Like

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