OpenWRT & Home Assistant: evaluate, visualize, automate
Access in your own network usually takes place centrally via the router, so certain conclusions can be drawn about its data. In addition to the utilization of the Internet access or the individual interfaces, the data from the OpenWRT router can also provide information about the status of certain devices. For example, the presence status of certain devices in the WiFi can be recorded via the device tracker. Using collectd and mqtt it is also possible to read out the CPU and RAM usage as well as the current bandwidth of individual interfaces. After using several OpenWrt devices as access points for a common for a common WLAN, Home Assistant offers the possibility to display the performance data of the individual devices in an overview.
Device Tracker
As already mentioned, the device tracker lists the presence status of all network devices. Prerequisite for the device tracker is the OpenWrt package: luci-mod-rpc, see: Home-Assistant integrations.
On the part of Home-Assistant the device tracker can be added in the configuration.yaml file.
Performance data and bandwidth -> Collectd -> MQTT -> HA
OpenWrt can collect its performance data with the Collectd deamon and send it according to the following example to a MQTT broker, which makes the data available in Home Assistant.
Setup OpenWrt
After the setup of MQTT at the router is done via SSH access, I activated the necessary packages not in the GUI, but also in the SSH session with opkg install.
First I used Putty to connect to the IP address of the first OpenWrt device:
In the terminal, the packages can then be installed with the following command:
Afterwards, in the GUI via Statistics and Setup, I adjusted the path of the collectd-deamon to "/etc/collectd":
To ensure that the settings are also available in the backup, I have changed the path for conf.d to a folder below /etc/config:
Interfaces:
RRDTool Output
Back to the terminal, we need the MQTT endpoint as the destination for the statistics data, which can be stored in the mqtt.conf file:
root@OpenWrt:~# mkdir /etc/config/collectd_conf.d
root@OpenWrt:/etc/collectd# vi /etc/config/collectd_conf.d/mqtt.conf
I filled the mqtt.conf file with the following content:
LoadPlugin mqtt
<Plugin "mqtt">
<Publish "OpenWRT">
Host "192.168.1.5"
Port "1883"
User "mqtt"
Password "???"
ClientId "OpenWRT"
Prefix "collectd"
Retain true
Of course, the IP address of the MQTT-BROKER, the username and the password for the connection must be adjusted.
After restarting the OpenWrt router, we can already display certain data in Home-Assistant from this point on. To do this, go to the settings of the MQTT integration:
On "Configure".
By means of "Listen to" and the configured topic: "collectd/OpenWrt/#" the transmitted data can be displayed:
For use in Home-Assistant as entities, I created the topics in the configuration.yaml file and prepared them using "value_template". Here is an excerpt from my configuration.yaml file for the main router. I left out my additional access points for the sake of simplicity.
Since there is a custom HACS integration for OpenWrt, I also tested it briefly, unfortunately only a few counters are provided for my router: WRT3200: https://github.com/kvj/hass_openwrt. In contrast to the MQTT connection described here, Home Assistant actively connects to the OpenWrt device, for which a custom user and permissions are used on the router:
First, the following packages are needed for the mentioned HACS integration on the OpenWrt:
config rpcd
option socket /var/run/ubus/ubus.sock
option timeout 30
config login
option username 'root'
option password '$p$root'
list read '*'
list write '*'
config login
option username 'hass'
option password '$p$hass'
list read hass
list read unauthenticated
list write hass
~
In Home Assistant, the repository can be downloaded and the integration added:
Conclusion
Both OpenWrt as well as Home Assistant are two systems that rely on open standards. This allows, for example, the performance data of the router and the access points to be visualized in Home Assistant, or the presence status of individual WLAN devices to be displayed for certain automations be used for certain automations.
Webhook: curl and cron
created:
2025-08-07
from
Bernhard
a simple cron job (Scheduled Tasks) on an Openwrt access point, everything that the Linux terminal makes available can be transmitted to Home-Assistant. As an example, my OpenWrt devices provide the following information:
... continue reading
Questions / Comments