OK, I just went through this and it took me longer than anticipated to figure it out; hopefully you’ll find the following useful. Instead of adding the above configlet to /etc/collectd.conf on the OpenWRT router I created /etc/collectd/mqtt.conf and added it there. The reason being that on the version of OpenWRT & collectd on my router /etc/collectd.conf gets overwritten on each reboot. The Host ip address is the address of my local Home Assistant instance. On HA you’ll have to go into Settings -> People -> Users and create an account for OpenWRT MQTT to login to, then add the password in the configlet on OpenWRT. Restart the Mosquito broker on HA, followed by restarting collectd on the OpenWRT router (you can do this by logging into OpenWRT via ssh and issuing service collectd restart from the command line. You should see in the OpenWRT logfile that collectd-mqtt successfully connects to HA. You can then add sensors you are interested from: OpenWRT-collectd-MQTT-HA/configuration.yaml at 1c99b71a2f6337d18a9393caa84ef1bf06ed094f · lukdwo/OpenWRT-collectd-MQTT-HA · GitHub to your HA config and updating as needed. At first I was not seeing anything in HA but after some debugging in HA Settings -> Devices & Services -> Mosquitto broker -> Configure and setting listen to collectd/# I saw updates coming in. The main difference was that updates were coming in as collectd/<name of my OpenWRT router>. You should now have entities in HA that represent these senors and can use them in dashboards/automations.
Thanks for the details around this something small i am just missing.
Created the user and also saw i needed the mqtt config in the other folder.
Wed Mar 22 16:57:09 2023 daemon.err collectd[1772]: plugin_load: plugin “mqtt” successfully loaded.
Wed Mar 22 16:57:09 2023 daemon.err collectd[1772]: Initialization complete, entering read-loop.
Wed Mar 22 17:54:28 2023 daemon.err collectd[1772]: Sleeping only 2s because the next interval is 3399.211 seconds in the past!
This is where i am stuck now.
setting listen to collectd/# I saw updates coming in.
Left it like that for 2 hours no time changes and the listening stops …?
I am seeing the router name I created and everything created but still no data.
I installed collectd, collectd-mod-mqtt. ssh into the router I do not see /etc/collectd folder. Do I need create this folder manually? I did not reboot the router after installing these 2 packages.
Since I had many issues regarding collectd on openwrt, not sure if you solved this but here is for anyone who’s struggling with configuration:
install mqtt broker on home assistant (mosquitto)
install luci-app-statistics on openwrt (it will install collectd, some additional mods and it will provide option to select where your collectd config files will be (for those who don’t see it in /etc folder))
install collectd-mod-mqtt
change collectd main folder to /etc/collectd in luci-app-statistics setup menu
create new folder conf.d in /etc/collectd/ folder
finally create your conf file in /etc/collectd/conf.d/ folder (i.e. mqtt.conf).
Merge this guide with the main guide and you’ll be good to go.
Here is what I got at the end:
hey undeene,
Thanks for the write. luci-app-statistics was probably what I missed. I may just tried again, but I noticed the memory jumped about 10% higher when I tried with the first attempt. It was sitting at about 82%.
fixed the stats graph issue, but I don’t understand this line Connect to your OpenWRT router via SSH, create a new folder called conf.d in /etc/collectd/
there is collectd.conf file in /etc/ directory but no collected folder.
Im really trying to set up my openort router in home assistant but im receiving this error:
Home assistant
2024-06-26 22:25:01: New connection from 192.168.1.1:60656 on port 1883.
error: received null username or password for unpwd check
2024-06-26 22:25:01: Client OpenWRT disconnected, not authorised.
2024-06-26 22:25:01: New connection from 192.168.1.1:60672 on port 1883.
error: received null username or password for unpwd check
2024-06-26 22:25:01: Client OpenWRT disconnected, not authorised.
2024-06-26 22:25:20: New connection from 172.30.32.2:60140 on port 1883.
2024-06-26 22:25:20: Client closed its connection.
2024-06-26 22:25:31: New connection from 192.168.1.1:49038 on port 1883.
error: received null username or password for unpwd check
2024-06-26 22:25:31: Client OpenWRT disconnected, not authorised.
Openwrt
Connection pending.
Wed Jun 26 22:30:14 2024 daemon.err collectd[5928]: mqtt plugin: successfully reconnected to broker “192.168.1.202:1883”
Wed Jun 26 22:30:14 2024 daemon.err collectd[5928]: mqtt plugin: mosquitto_loop failed: The connection was refused.
Wed Jun 26 22:30:14 2024 daemon.err collectd[5928]: mqtt plugin: publish failed: Connection pending.
Wed Jun 26 22:30:14 2024 daemon.err collectd[5928]: mqtt plugin: successfully reconnected to broker “192.168.1.202:1883”
Wed Jun 26 22:30:14 2024 daemon.err collectd[5928]: mqtt plugin: mosquitto_loop failed: The connection was refused.
Wed Jun 26 22:30:14 2024 daemon.err collectd[5928]: mqtt plugin: publish failed: Connection pending.
Wed Jun 26 22:30:14 2024 daemon.err collectd[5928]: mqtt plugin: successfully reconnected to broker “192.168.1.202:1883”