家庭助理 Mosquitto Tasmota 设备套接字错误
我刚刚在 Raspberry Pi 4 上完成了 Home Assistant OS 6.4(核心 2021.9.7 升级到 2021.10.0,supervisor-2021.09.6)的全新安装,以及配置为附加组件的Mosquitto 6.0.1 。据我所知,安装似乎工作正常。
但是我遇到的问题是在尝试通过 MQTT 配置我的第一个 Tasmoto (9.5.0) 设备时。我得到一个
1633680390: New connection from 192.168.1.28 on port 1883.
1633680390: Socket error on client <unknown>, disconnecting.
此错误似乎在其他帖子中经常出现,并且大多数情况下归结为身份验证问题。但是无论我做什么,我似乎都无法解决问题,甚至无法对其产生影响。我总是得到同样的错误。
有没有人知道问题可能是什么,或者更重要的是我如何诊断问题?虽然 Tasmoto 设备似乎工作正常,但我不能排除这是问题的根源。
按照此处描述的说明安装 HA:https : //www.home-assistant.io/installation/raspberrypi/在 Pi 4 上并完成了入职流程,这一步似乎已经完成。
我使用此处描述的过程将 Mosquito 作为 MQTT 代理安装为家庭助理附加组件:https : //github.com/home-assistant/addons/blob/master/mosquitto/DOCS.md,这似乎工作正常也。
该MQTT配置看起来是这样,但我已经尝试过用logins: []
和anonymous: true
为好。
logins:
- username: username
password: password
customize:
active: false
folder: mosquitto
certfile: fullchain.pem
keyfile: privkey.pem
require_certificate: false
anonymous: false
- 我已经使用以下 MQTT 确认信息配置了 MQTT 设备,这是一个Localbytes 预闪存 tasmota 插件。
192.168.1.32 是 Home Assistant 节点的地址。192.168.1.28 是 Tasmota 设备。我曾经SetOption19 1
让 Tasmota 设备可被发现。
日志文件如下所示:
- 通过 HA 的 MQTT 代理
[s6-init] making user provided files available at /var/run/s6/etc...exited 0.
[s6-init] ensuring user provided files have correct perms...exited 0.
[fix-attrs.d] applying ownership & permissions fixes...
[fix-attrs.d] done.
[cont-init.d] executing container initialization scripts...
[cont-init.d] mosquitto.sh: executing...
[09:02:51] INFO: SSL is not enabled
[cont-init.d] mosquitto.sh: exited 0.
[cont-init.d] nginx.sh: executing...
[cont-init.d] nginx.sh: exited 0.
[cont-init.d] done.
[services.d] starting services
[services.d] done.
[09:02:52] INFO: Starting NGINX for authentication handling...
[09:02:52] INFO: Starting mosquitto MQTT broker...
1633680172: mosquitto version 1.6.12 starting
1633680172: |-- *** auth-plug: startup
[09:02:53] INFO: Successfully send discovery information to Home Assistant.
[09:02:53] INFO: Successfully send service information to the Supervisor.
1633680172: Config loaded from /etc/mosquitto/mosquitto.conf.
1633680172: Loading plugin: /usr/share/mosquitto/auth-plug.so
1633680172: ├── Username/password checking enabled.
1633680172: ├── TLS-PSK checking enabled.
1633680172: └── Extended authentication not enabled.
1633680172: Opening ipv4 listen socket on port 1883.
1633680172: Opening ipv6 listen socket on port 1883.
1633680172: Opening websockets listen socket on port 1884.
1633680172: Warning: Mosquitto should not be run as root/administrator.
1633680172: mosquitto version 1.6.12 running
1633680172: New connection from 127.0.0.1 on port 1883.
1633680172: Socket error on client <unknown>, disconnecting.
1633680177: New connection from 172.30.32.1 on port 1883.
401: Unauthorized1633680178: Socket error on client <unknown>, disconnecting.
1633680179: New connection from 192.168.1.28 on port 1883.
401: Unauthorized1633680179: Socket error on client <unknown>, disconnecting.
1633680200: New connection from 192.168.1.28 on port 1883.
1633680200: Socket error on client <unknown>, disconnecting.
1633680231: New connection from 192.168.1.28 on port 1883.
1633680231: Socket error on client <unknown>, disconnecting.
- 从 Tasmota 设备..
09:21:12.302 MQT: Attempting connection...
09:21:12.324 MQT: Connect failed to 192.168.1.32:1883, rc 5. Retry in 120 sec
09:23:13.518 MQT: Attempting connection...
09:23:13.542 MQT: Connect failed to 192.168.1.32:1883, rc 5. Retry in 120 sec
09:25:14.541 MQT: Attempting connection...
09:25:14.564 MQT: Connect failed to 192.168.1.32:1883, rc 5. Retry in 120 sec
09:25:54.414 RSL: HASS_STATE = {"Version":"9.5.0(tasmota)","BuildDateTime":"2021-06-17T08:26:35","Module or Template":"LocalBytes PM","RestartReason":"Software/System restart","Uptime":"0T00:20:00","Hostname":"plug1-3601","IPAddress":"192.168.1.28","RSSI":"100","Signal (dBm)":"-50","WiFi LinkCount":1,"WiFi Downtime":"0T00:00:03","MqttCount":0,"LoadAvg":19}
09:25:58.392 RSL: STATE = {"Time":"2021-10-08T09:25:58","Uptime":"0T00:20:04","UptimeSec":1204,"Heap":27,"SleepMode":"Dynamic","Sleep":50,"LoadAvg":19,"MqttCount":0,"POWER":"ON","Wifi":{"AP":1,"SSId":"<redacted>","BSSId":"00:50:7F:F1:42:9A","Channel":12,"Mode":"11n","RSSI":96,"Signal":-52,"LinkCount":1,"Downtime":"0T00:00:03"}}
09:25:58.399 RSL: SENSOR = {"Time":"2021-10-08T09:25:58","ENERGY":{"TotalStartTime":"2021-09-29T17:59:48","Total":0.011,"Yesterday":0.000,"Today":0.000,"Period":0,"Power":0,"ApparentPower":0,"ReactivePower":0,"Factor":0.00,"Voltage":232,"Current":0.000}}
09:27:15.528 MQT: Attempting connection...