Hello,
I'm trying to connect my openwrt router with Home Assistant via this topic:
So I create an account in Home Assistant for OpenWRT to login.
Installed the following:
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
opkg list-installed | grep mosquitto
libmosquitto-nossl - 2.0.18-2
mosquitto-client-nossl - 2.0.18-2
I've created the config in /etc/collectd.conf,
LoadPlugin mqtt
<Plugin "mqtt">
<Publish "OpenWRT">
Host "192.168.1.202"
Port "1883"
User "mqtt"
Password "1234"
ClientId "OpenWRT"
Prefix "collectd"
Retain true
</Publish>
</Plugin>
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
Mqtt explorer shows me nothing...
Buuuut, now comes the problem:
Somehow they can't connect with each other, pw wrong:
logread -f | grep collectd shows:
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.
I even made changes to the firewall:
firewall.@rule[9]=rule
firewall.@rule[9].name='Allow-MQTT'
firewall.@rule[9].src='lan'
firewall.@rule[9].dest_ip='192.168.1.202'
firewall.@rule[9].dest_port='1883'
firewall.@rule[9].proto='tcp'
firewall.@rule[9].target='ACCEPT'
Can anyone help me?