Any way to show currently installed version with sensor?

I’ve added the following sensor to my config but it doesn’t work:

- platform: command_line
  name: "HASS version"
  command: "hass --version"

The result of this sensor in the UI is “unknown”, and the log shows the following error:

16-08-15 19:15:00 homeassistant.components.sensor.command_line: Command failed: hass --version
16-08-15 19:16:30 homeassistant.components.sensor.command_line: Command failed: hass --version
16-08-15 19:18:00 homeassistant.components.sensor.command_line: Command failed: hass --version
16-08-15 19:19:30 homeassistant.components.sensor.command_line: Command failed: hass --version
16-08-15 19:21:00 homeassistant.components.sensor.command_line: Command failed: hass --version

I’m assuming the command is not working because it’s run as the user hass, but not within the virtual_env (my HASS instance is installed with the AiO installer on a Raspberry Pi 3).

I know you can simply view the currently installed version by going to the ‘About’ page under the hamburger menu on the left, but I was just wondering if there’s an alternative to my attempt above.

How about /path/to/your/venv/bin/hass --version?

1 Like

Wow, I didn’t realise it could be that simple! Thanks! :smile:

I have a similar sensor to show the installed Python version and, although that one worked, I updated that one with the full path as well, to make sure I’m showing the version of the right instance.

If you made this to keep an eye of possible updates, you can also make a rule:

hass_update_notify.yaml

alias: 016 - HASS update available
trigger:
  - platform: state
    entity_id: updater.updater      
action:
- service: notify.telegram
  data:
    title: System message - 
    message: A new version of Home Assistant is available! See release notes at: https://home-assistant.io/blog/categories/release-notes/

Works perfectly fine here!

1 Like

I didn’t, but that’s a good and useful suggestion nonetheless. I may just end up using it :slight_smile:

I did however notice that updater.updater is no longer listed as an entity on the new States page, but {{ states.updater.updater }} works on the Templates page (returns ‘None’ at the moment).

I use this to keep a watch on the current release version:

platform: command_line
   command: python3 -c "import requests;
   print(requests.get('https://pypi.python.org/pypi/homeassistant/json').json()['info']['version'])"
   name: Current HA Version

I’m aware this is an old thread, but how about:

- platform: command_line
  name: "HASS version"
  command: "cat .HA_VERSION"
1 Like