I did not have to restart OpenWRT, but I restarted collectd
. The new instructions are quite detailed!
I get this error when I try to statistics > graphs
and this is my collected config.
and MQTT device
and mqtt conf file is located here
/etc/collectd/conf.d
Something is wrong in your OpenWRT setup: you should be able to see Graphs by simply installing luci-app-statistics
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.
content of that file
BaseDir "/etc/collectd"
Include "/etc/collectd/conf.d/*.conf"
PIDFile "/var/run/collectd.pid"
PluginDir "/usr/lib/collectd"
TypesDB "/usr/share/collectd/types.db"
Interval 30
ReadThreads 2
LoadPlugin cpu
<Plugin cpu>
ValuesPercentage true
ReportByCpu true
ReportByState true
</Plugin>
LoadPlugin interface
<Plugin interface>
IgnoreSelected false
Interface "br-lan"
</Plugin>
LoadPlugin iwinfo
LoadPlugin load
LoadPlugin memory
<Plugin memory>
ValuesPercentage false
ValuesAbsolute true
</Plugin>
LoadPlugin rrdtool
<Plugin rrdtool>
DataDir "/tmp/rrd"
RRARows 288
RRASingle true
RRATimespan 7200
RRATimespan 86400
RRATimespan 604800
RRATimespan 2678400
RRATimespan 31622400
</Plugin>
Have you installed collectd-mod-mqtt
as well?
I don’t understand why these folders are missing in your setup, they’re even referenced in the config as you see.
Try re-installing the custom packages for this guide.
Can you please share how you get the “Connected” and “Up” states from OpenWrt?
hey… just a question:
why did you choose to use collectd
and mqtt
?
What about ubus
and node_exporter
? seems to me very low on ressources.
Hello,
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”
I’ve set on both the same username+ PW…
Any idea?
This is mine mqtt.conf on router
LoadPlugin mqtt
<Plugin "mqtt">
<Publish "OpenWRT">
Host "Home_assistant_ip"
Port "1883"
User "username_for_mqtt"
Password "passwd_mqtt"
ClientId "OpenWRT"
Prefix "collectd"
Retain true
</Publish>
</Plugin>
You can use something like mqtt explorer to see if router is publishing packages.
In my example I have a topic collectd/OpenWRT.
mqtt.conf file live in /etc/collectd/conf.d If you don’t have this directory, create it.
All you have to do is check in luci that mqtt plugin is enabled in collectd conf and restart collectd service. And that is it. It should start publishing packages in a few seconds.
And this is /etc/collectd.conf
BaseDir "/var/run/collectd"
Include "/etc/collectd/conf.d/*.conf"
PIDFile "/var/run/collectd.pid"
PluginDir "/usr/lib/collectd"
TypesDB "/usr/share/collectd/types.db"
Interval 30
ReadThreads 2
...........
My collect.conf:
BaseDir “/etc/collectd/”
Include “/etc/collectd/conf.d/*.conf”
PIDFile “/var/run/collectd.pid”
PluginDir “/usr/lib/collectd”
TypesDB “/usr/share/collectd/types.db”
Interval 30
ReadThreads 2
“check in luci that mqtt plugin is enabled” do you mean the graphs?
I’ll guess everything is working, just they cant connect propably?
Sorry had to log in to my wrt luci to check it. There is no mqtt plugin. For some reason it seems that your topics are not being published. As I set this up a few months ago, I can’t remember all the details and I do experiment a lot with settings.
opkg list-installed | grep collect
collectd - 5.12.0-49
collectd-mod-conntrack - 5.12.0-49
collectd-mod-cpu - 5.12.0-49
collectd-mod-exec - 5.12.0-49
collectd-mod-interface - 5.12.0-49
collectd-mod-iwinfo - 5.12.0-49
collectd-mod-load - 5.12.0-49
collectd-mod-memory - 5.12.0-49
collectd-mod-mqtt - 5.12.0-49
collectd-mod-network - 5.12.0-49
collectd-mod-rrdtool - 5.12.0-49
collectd-mod-snmp - 5.12.0-49
collectd-mod-thermal - 5.12.0-49
collectd-mod-uptime - 5.12.0-49
I don’t remember did I need a mosquitto package for that. I dont think so… but I have it.
opkg list-installed | grep mosquitto
libmosquitto-ssl - 2.0.18-2
mosquitto-client-ssl - 2.0.18-2
It should at least publish topics and you should be able to see it in mqtt explorer.
But you can restart collectd services and see does wrt logs are throwing some error on it with logread.
logread -f | grep collectd
Gives me this:
connected to broker "192.168.1.202:1883"
Wed Jun 26 22:00:33 2024 daemon.err collectd[4806]: mqtt plugin: mosquitto_loop failed: The connection was refused.
Wed Jun 26 22:00:33 2024 daemon.err collectd[4806]: mqtt plugin: publish failed: Connection pending.
Wed Jun 26 22:00:33 2024 daemon.err collectd[4806]: mqtt plugin: successfully reconnected to broker "192.168.1.202:1883"
Wed Jun 26 22:00:33 2024 daemon.err collectd[4806]: mqtt plugin: mosquitto_loop failed: The connection was refused.
Wed Jun 26 22:00:33 2024 daemon.err collectd[4806]: mqtt plugin: publish failed: Connection pending.
Wed Jun 26 22:00:33 2024 daemon.err collectd[4806]: mqtt plugin: successfully reconnected to broker "192.168.1.202:1883"
Wed Jun 26 22:00:33 2024 daemon.err collectd[4806]: mqtt plugin: mosquitto_loop failed: The connection was refused.
Wed Jun 26 22:00:33 2024 daemon.err collectd[4806]: mqtt plugin: publish failed: Connection pending.
Wed Jun 26 22:00:33 2024 daemon.err collectd[4806]: mqtt plugin: successfully reconnected to broker "192.168.1.202:1883"
Wed Jun 26 22:00:33 2024 daemon.err collectd[4806]: mqtt plugin: mosquitto_loop failed: The connection was refused.
Wed Jun 26 22:00:33 2024 daemon.err collectd[4806]: mqtt plugin: publish failed: Connection pending.
Wed Jun 26 22:00:33 2024 daemon.err collectd[4806]: mqtt plugin: successfully reconnected to broker "192.168.1.202:1883"
Mqtt in home assistant gives me this as error:
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 <unknown> 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.
As i see it you have wrong username and/or password set in your mqtt.conf file on openwrt.
Yes… but i dont know why…
Same username, in both/ same password, I created a user in Home assistant.
Any idea?
My guess is that there is some problem with mqtt authentication or maybe firewall.
I didn’t add anything to home assistant, any user or something like that. I just installed collectd and mqtt plugin, configured mqtt.conf file as people wrote before me and that was it.
Topic was published and I could see it in mqtt explorer. Your topic for some reason isnt even published.
You could maybe try to configure mqtt broker with out password and see will then topic be published.
Further more I did create file mqtt_sensor.yaml and put everything in it, but… you have some other problem.
Ok, thank you very much. I think I’m going to open a new thread here, “can’t connect to Matt broker”.
Hi, I’m new to HA, ESPHome, My goal is to send a message from DDWRT to HA that a device re-connected to my router.
This is an old thread, but it is on a subject I’m researching. The question is to set my expectations before I invest time in testing this configuration: Will this work if DDWRT and HA are on different Vlans? My router can open communication with HA but all messages from HA will be dropped.