I’m trying to read an attribute from a local json file to retrieve the version installed of a component.
This is the content of version.json and it’s located on: /home/homeassistant/.homeassistant/www/custom_ui/version.json
Why not use Custom Updater with the Tracker Card? It reads directly from the .json on github and will also read what version you have installed, and even give you an option to update the component/card from your Lovelace UI.
Fair enough. I use it for all the custom cards that work with it, I have a lot, so it’s easier to use that and have them all in that nice neat card. I also have a few custom sensors for things like pi-hole, zigbee2mqtt, and HA itself.
Not sure if this is of any interest, but this is what I use to track Zigbee2mqtt. I have the same for pi-hole. Haven’t got around to using this to track HA yet.
The command line sensor gets the currently installed version, the rest sensor gets the latest version from GitHub, and the template sensor combines the two and tells me the current version, but if a new version is available, it tells me “Update Available”.
It wont work. It doesn’t use the required json file needed for the tracker card. Also, remember that Zigbee2mqtt is separate from Home Assistant. Home Assistant can connect to Zigbee2mqtt via MQTT, so no amount of anything will get this to work with the tracker card.
OK. last question ( I hope): can i track HA version with this component? Actually I don’t find anything about it. Actually i’m still using old method like:
- platform: rest
resource: https://s3.amazonaws.com/hassio-version/stable.json
name: Hassio Version
value_template: "{{ value_json.homeassistant.default }}"
scan_interval: 3600
- platform: version
name: Installed Version
There are 2 methods. One is to read the file in your config directory. The file is .HA_VERSION, or there is a command line. By the looks of it you are using HASS.io which is a little different to what I use. I have Home Assistant in a virtual environment on running under Raspbian.
This is what I use to get the version.
- platform: command_line
name: Installed Version
command: /srv/homeassistant/bin/hass --version
More information can be found on the Version Sensor. At the bottom there are some alternative methods. I think the last 2 might work for you but have a play with them and see what works with HASS.io.