How to display a system status in Home Assistant
It is handy to have system information easily accessible. Manual checking (via SSH) can become annoying quickly. However, thanks to Home Assistant’s built-in integration Command line Sensor, it is easy to set up in-app system monitoring in a matter of minutes.
At first you have to prepare a data source. On GNU/Linux, you can use e.g. lm-sensors package to get information about temperatures, fan speeds, etc. To install the package on Ubuntu, run:
Now you need to scan the system for available sensors.
To use recommended options, press
Enter on every question except the last one (see below). The default value will be used (always in CAPITAL letters). This is 100% safe, however, it could happen that some sensors will not be available. For every sensor there will be a description and potential risks, so decide for yourself to install or not.
Answer the last question
Now reboot and check whether the installation was successful:
Depending on the hardware the output will look like this:
We will use JSON output format to get the data easily:
Now it is easy to push these values to the HA.
Home Assistant configuration
Warning: it is dangerous to run
sensors multiple times at once, it can crash the system. To read multiple values, we will save the
sensors output to a file and read from the file instead.
configuration.yml and add these lines:
This is just a dummy sensor to save actual values to a file. Now you can add one on more actual ‘sensors’ below the block we just added.
To get a value from JSON, you need to use
value_json and access the keys with
["bracket notation"] if the key contains spaces. In the example I read a temperature of the chipset, which looks like this in the source JSON:
After you add all of the needed sensors, check the configuration in HA in settings and restart the HA.
Adding sensors to Lovelace
After restarting the HA, all sensors should be available (if not, wait for a time specified in the config:
command_timeout). The sensors are just like any other entities, so pick e.g. Sensor Card and add your sensors. Now it is easy to see nice graphs right in the HA app without logging to SSH and checking the values manually!