Advertisement

A simple Python script allowing you to monitor all the Raspberry Pis you might have running in your smart home has been shared by GitHub user Sennevds. This can be useful if you have multiple Raspberry Pis doing different things, for example, if you have one as an ad-blocker and another one as a Zigbee hub.

Advertisement

Using this simple script you will be able to monitor vital system information, such as CPU usage and temperature. For all the nerds who like stats, you will of course also be able to display the system information using bars and graphs in the Home Assistant dashboard.

How the Raspberry Pi monitoring script works

The script, which is written in Python, runs every 60 seconds and sends system information data to an MQTT broker. If your Home Assistant has access to the same MQTT broker it will automatically pull that data using MQTT auto-discovery. You can then display the system information from the Raspberry Pi in your Home Assistant dashboard and, of course, use it in automations and scripts.

Advertisement

The script gathers data on the CPU (usage and temperate), memory (usage) storage (usage, swap usage and external drive usage), networking (Wi-Fi signal strength), and the Raspberry Pi itself (power status, last boot, last message received timestamp, and amount of upgrades pending).

CanaKit Raspberry Pi 4 8GB Basic Starter Kit with Fan (8GB RAM)
CanaKit Raspberry Pi 4 4GB Basic Starter Kit with Fan (4GB RAM)
CanaKit Raspberry Pi 4 Basic Kit (8GB RAM)
CanaKit Raspberry Pi 4 4GB Basic Kit with PiSwitch (4GB RAM)
Product
CanaKit Raspberry Pi 4 Basic Starter Kit
CanaKit Raspberry Pi 4 Basic Starter Kit
CanaKit Raspberry Pi 4 Basic Kit
CanaKit Raspberry Pi 4 Basic Kit
Model
Raspberry Pi 4 Model B (8 GB)
Raspberry Pi 4 Model B (4 GB)
Raspberry Pi 4 Model B (8 GB)
Raspberry Pi 4 Model B (8 GB)
PSU
Power supply with noise filter
Power supply with noise filter
Power supply with noise filter
Power supply with noise filter
Accessories
Clear case, fan, and set of heat sinks
Clear case, fan, and set of heat sinks
Set of 3 aluminium heat sinks
Set of 3 aluminium heat sinks
Price
$124.99
$104.99
Price not available
Price not available
-
-
CanaKit Raspberry Pi 4 8GB Basic Starter Kit with Fan (8GB RAM)
Product
CanaKit Raspberry Pi 4 Basic Starter Kit
Model
Raspberry Pi 4 Model B (8 GB)
PSU
Power supply with noise filter
Accessories
Clear case, fan, and set of heat sinks
Price
$124.99
CanaKit Raspberry Pi 4 4GB Basic Starter Kit with Fan (4GB RAM)
Product
CanaKit Raspberry Pi 4 Basic Starter Kit
Model
Raspberry Pi 4 Model B (4 GB)
PSU
Power supply with noise filter
Accessories
Clear case, fan, and set of heat sinks
Price
$104.99
CanaKit Raspberry Pi 4 Basic Kit (8GB RAM)
Product
CanaKit Raspberry Pi 4 Basic Kit
Model
Raspberry Pi 4 Model B (8 GB)
PSU
Power supply with noise filter
Accessories
Set of 3 aluminium heat sinks
Price
Price not available
-
CanaKit Raspberry Pi 4 4GB Basic Kit with PiSwitch (4GB RAM)
Product
CanaKit Raspberry Pi 4 Basic Kit
Model
Raspberry Pi 4 Model B (8 GB)
PSU
Power supply with noise filter
Accessories
Set of 3 aluminium heat sinks
Price
Price not available
-

For the script to work you will have to edit a file, which is written in YAML. There are a few required parameters such as information on the MQTT broker, a client ID and name, and the timezone you are in. Other parameters are optional, such as the update interval and whether the Wi-Fi signal strength should be measured or not.

How to use the system information data

Thanks to the MQTT auto-discover you won’t have to make any adjustments in Home Assistant, other than adding the following lines to your configuration.yaml:

Advertisement
mqtt:
  discovery: true
  discovery_prefix: homeassistant

Having the system information of your Raspberry Pis available in Home Assistant can be very useful. For starters, you won’t have to log in to the Raspberry Pis every time you want to check on how they are doing. You can also have a notification sent to your smartphone every time the CPU of a Raspberry Pi exceeds a limit you have set or if the storage is nearing its full capacity.

Displaying Raspberry Pi system information in Home Assistant
Displaying Raspberry Pi system information in Home Assistant (source: GitHub)

The creator of this script has also shared their own personal Lovelace configuration. They use a combination of the vertical-stack-in-card, the mini-graph-card, and the bar-card. I do have to admit, having the system information of Raspberry Pis displayed in Home Assistant does look nice.

Advertisement
Liam Alexander Colman, the author and maintainer of Home Assistant Guides.

About Liam Alexander Colman

Liam Alexander Colman has been using Home Assistant for various projects for quite some time. What started of with a Raspberry Pi quickly became three Raspberry Pis and eventually a full-blown server. I now use Unraid as my operating system and Home Assistant happily runs in a Docker container. My personal setup includes many Zigbee devices as well as integrations with existing products such as my Android TV box. Read on to find out more on how I got started with Home Assistant.

Leave a comment

Advertisement