I’ve created a simple python script that runs every 60 seconds and sends several system data over MQTT. It uses the MQTT Discovery for Home Assistant so you don’t need to configure anything in Home Assistant if you have discovery enabled for MQTT
It currently logs the following data:
- CPU usage
- CPU temperature
- Disk usage
- Memory usage
- Power status of the RPI
- Last boot
- Clone this repo
- cd system_sensors
- pip3 install -r requirements.txt
- python3 system_sensors.py
- (optional) create service to autostart the script at boot:
- sudo nano /etc/systemd/system/system_sensor.service
- copy following script:
[Unit] Description=System Sensor service After=multi-user.target [Service] User=[user] Type=idle ExecStart=/usr/bin/python3 /home/pi/sensors/system_sensors.py [Install] WantedBy=multi-user.target
- edit the path to your script path
- sudo systemctl enable system_sensor.service
- sudo systemctl start system_sensor.service
The only config you need in Home Assistant is the following:
mqtt:
discovery: true
discovery_prefix: homeassistant
I have used following custom plugins for lovelace:
- vertical-stack-in-card
- mini-graph-card
- bar-card
Config:
- type: 'custom:vertical-stack-in-card'
title: Deconz System Monitor
cards:
- type: horizontal-stack
cards:
- type: custom:mini-graph-card
entities:
- sensor.deconzcpuusage
name: CPU
line_color: '#2980b9'
line_width: 2
hours_to_show: 24
- type: custom:mini-graph-card
entities:
- sensor.deconztemperature
name: Temp
line_color: '#2980b9'
line_width: 2
hours_to_show: 24
- type: custom:bar-card
entity: sensor.deconzdiskuse
title: HDD
title_position: inside
align: split
show_icon: true
color: '#00ba6a'
- type: custom:bar-card
entity: sensor.deconzmemoryuse
title: RAM
title_position: inside
align: split
show_icon: true
- type: entities
entities:
- sensor.deconzlastboot
- sensor.deconzpowerstatus
Example: