The RPi Reporter Daemon is a simple Linux python script which queries the Raspberry Pi on which it is running for various configuration and status values which it then reports via via MQTT to your Home Assistant installation.
This page describes what is being advertised to Home Assistant.
On this Page:
- Status Endpoints - shows the sensors offered by the Daemon
- Control Endpoints - shows the buttons offered by the Daemon (when they are configured)
Additional pages:
- Overall Daemon Instructions - This project top level README
- Controlling your RPi from Home Assistant - (Optional) Set up to allow remote control from HA
- The Associated Lovelace RPi Monitor Card - This is our companion Custom Lovelace Card that makes displaying this RPi Monitor data very easy.
- ChangeLog - We've been repairing or adding features to this script as users report issues or wishes. This is our list of changes.
The Daemon already reports each RPi device as:
Name | Description |
---|---|
Manufacturer |
Raspberry Pi (Trading) Ltd. |
Model |
RPi 4 Model B v1.1 |
Name |
(fqdn) pimon1.home |
sofware ver |
OS Name, Version (e.g., Buster v4.19.75v7l+) |
There are a number of settings in our config.ini
that affect the details of the advertisements to Home Assistant. They are all found in the [MQTT]
section of the config.ini
. The following are used for this purpose:
Name | Default | Description |
---|---|---|
hostname |
configured hostname | The host name of the RPi |
base_topic |
{no default} | Set this as desired for your installation |
sensor_name |
default "{SENSOR_NAME}" | If you prefer to use some other form set it here |
For the purpose of this document we'll use the following to indicate where these appear in the advertisements.
- placeholders used herein:
{HOSTNAME}
,{BASE_TOPIC}
, and{SENSOR_NAME}
.
NOTE: author's setup: I have a farm of 20+ RPi's spread all over my house. They all have identical config.ini's. I ONLY set "base_topic", i do not set the other two. For the other two the default values work great.
The Daemon also reports five topics for each RPi device:
Name | Device Class | Units | Description |
---|---|---|---|
~/monitor |
'timestamp' | n/a | Is a timestamp which shows when the RPi last sent information, carries a template payload conveying all monitored values (attach the lovelace custom card to this sensor!) |
~/temperature |
'temperature' | degrees C | Shows the latest system temperature |
~/disk_used |
none | percent (%) | Shows the percent of root file system used |
~/cpu_load |
none | percent (%) | Shows CPU load % over the last 5 minutes |
~/mem_used |
none | percent (%) | Shows the percent of RAM used |
The ~/monitor
advertisement:
{
"name": "Rpi Monitor {HOSTNAME}",
"uniq_id": "RPi-e45f01Monf81801_monitor",
"dev_cla": "timestamp",
"stat_t": "~/monitor",
"val_tpl": "{{ value_json.info.timestamp }}",
"~": "{BASE_TOPIC}/sensor/{SENSOR_NAME}",
"avty_t": "~/status",
"pl_avail": "online",
"pl_not_avail": "offline",
"ic": "mdi:raspberry-pi",
"json_attr_t": "~/monitor",
"json_attr_tpl": "{{ value_json.info | tojson }}",
"dev": {
"identifiers": ["RPi-e45f01Monf81801"],
"manufacturer": "Raspberry Pi (Trading) Ltd.",
"name": "RPi-{HOSTNAME-FQDN}",
"model": "RPi 4 Model B r1.5",
"sw_version": "bullseye 5.15.84-v8+"
}
}
NOTE: in this case you'll see that {HOSTNAME} is not used for the "name:" value. Instead we use the fully qualified domain name {HOSTNAME-FQDN}. On the authors' network (192.168.255.*) the internal domain is ".home" so an RPi with the name say "pip2iotgw" has an FQDN of "pip2iotgw.home" On the author's network is it common then to say ssh [email protected]
to log into the RPi.
The ~/temperature
advertisement:
{
"name": "Rpi Temp {HOSTNAME}",
"uniq_id": "RPi-e45f01Monf81801_temperature",
"dev_cla": "temperature",
"unit_of_measurement": "°C",
"stat_t": "~/monitor",
"val_tpl": "{{ value_json.info.temperature_c }}",
"~": "{BASE_TOPIC}/sensor/{SENSOR_NAME}",
"avty_t": "~/status",
"pl_avail": "online",
"pl_not_avail": "offline",
"ic": "mdi:thermometer",
"dev": {
"identifiers": ["RPi-e45f01Monf81801"]
}
}
The ~/disk_used
advertisement:
{
"name": "Rpi Disk Used {HOSTNAME}",
"uniq_id": "RPi-e45f01Monf81801_disk_used",
"unit_of_measurement": "%",
"stat_t": "~/monitor",
"val_tpl": "{{ value_json.info.fs_used_prcnt }}",
"~": "{BASE_TOPIC}/sensor/{SENSOR_NAME}",
"avty_t": "~/status",
"pl_avail": "online",
"pl_not_avail": "offline",
"ic": "mdi:sd",
"dev": {
"identifiers": ["RPi-e45f01Monf81801"]
}
}
The ~/cpu_load
advertisement:
{
"name": "Rpi Cpu Use {HOSTNAME}",
"uniq_id": "RPi-e45f01Monf81801_cpu_load",
"unit_of_measurement": "%",
"stat_t": "~/monitor",
"val_tpl": "{{ value_json.info.cpu.load_5min_prcnt }}",
"~": "{BASE_TOPIC}/sensor/{SENSOR_NAME}",
"avty_t": "~/status",
"pl_avail": "online",
"pl_not_avail": "offline",
"ic": "mdi:cpu-64-bit",
"dev": {
"identifiers": ["RPi-e45f01Monf81801"]
}
}
The ~/mem_used
advertisement:
{
"name": "Rpi Mem Used {HOSTNAME}",
"uniq_id": "RPi-e45f01Monf81801_mem_used",
"unit_of_measurement": "%",
"stat_t": "~/monitor",
"val_tpl": "{{ value_json.info.mem_used_prcnt }}",
"~": "{BASE_TOPIC}/sensor/{SENSOR_NAME}",
"avty_t": "~/status",
"pl_avail": "online",
"pl_not_avail": "offline",
"ic": "mdi:memory",
"dev": {
"identifiers": ["RPi-e45f01Monf81801"]
}
}
Once the commanding is enabled then the Daemon also reports the commanding interface for the RPi. By default we've provided examples for enabling three commands (See config.ini.dist
.) This is what the commanding interface looks like when all threee are enabled:
Name | Device Class | Description |
---|---|---|
~/shutdown |
button | Send request to this endpoint to shut the RPi down |
~/reboot |
button | Send request to this endpoint to reboot the RPi |
~/restart_service |
button | Send request to this endpoint to restart the Daemon service |
The ~/shutdown
Command advertisement:
{
"name": "Rpi Shutdown {HOSTNAME} Command",
"uniq_id": "RPi-e45f01Monf81801_shutdown",
"~": "{BASE_TOPIC}/command/{SENSOR_NAME}",
"cmd_t": "~/shutdown",
"json_attr_t": "~/shutdown/attributes",
"avty_t": "~/status",
"pl_avail": "online",
"pl_not_avail": "offline",
"ic": "mdi:power-sleep",
"dev": {
"identifiers": ["RPi-e45f01Monf81801"]
}
}
The ~/reboot
Command advertisement:
{
"name": "Rpi Reboot {HOSTNAME} Command",
"uniq_id": "RPi-e45f01Monf81801_reboot",
"~": "{BASE_TOPIC}/command/{SENSOR_NAME}",
"cmd_t": "~/reboot",
"json_attr_t": "~/reboot/attributes",
"avty_t": "~/status",
"pl_avail": "online",
"pl_not_avail": "offline",
"ic": "mdi:restart",
"dev": {
"identifiers": ["RPi-e45f01Monf81801"]
}
}
The ~/restart_service
Command advertisement:
{
"name": "Rpi Restart_Service {HOSTNAME} Command",
"uniq_id": "RPi-e45f01Monf81801_restart_service",
"~": "{BASE_TOPIC}/command/{SENSOR_NAME}",
"cmd_t": "~/restart_service",
"json_attr_t": "~/restart_service/attributes",
"avty_t": "~/status",
"pl_avail": "online",
"pl_not_avail": "offline",
"ic": "mdi:cog-counterclockwise",
"dev": {
"identifiers": ["RPi-e45f01Monf81801"]
}
}
If you like my work and/or this has helped you in some way then feel free to help me out for a couple of ☕'s or 🍕 slices!
Raspberry Pi is registered trademark of Raspberry Pi (Trading) Ltd.
This project is a community project not for commercial use. The authors will not be held responsible in the event of device failure or simply errant reporting of your RPi status.
This project is in no way affiliated with, authorized, maintained, sponsored or endorsed by Raspberry Pi (Trading) Ltd. or any of its affiliates or subsidiaries.