The problem
I am having problems connecting Home Assistant (HA) to public MQTT.
(also see HA issue 119064 and HA issue 39581, what did not solve my problem).
In my case also connecting Home Assistant to mqtt.flespi.io. I have set up a token with ACL in Flespi, but I keep getting an authorization error in HA:
2024-06-07 14:38:07.523 DEBUG (MainThread) [homeassistant.components.mqtt.client] mqtt.flespi.io: connection opened 39
2024-06-07 14:38:07.523 DEBUG (MainThread) [homeassistant.components.mqtt.client] mqtt.flespi.io: Starting client misc loop
2024-06-07 14:38:07.524 DEBUG (MainThread) [homeassistant.components.mqtt.client] mqtt.flespi.io: register write 39
2024-06-07 14:38:07.528 DEBUG (MainThread) [homeassistant.components.mqtt.client] mqtt.flespi.io: unregister write 39
2024-06-07 14:38:07.549 ERROR (MainThread) [homeassistant.components.mqtt.client] Unable to connect to the MQTT broker: Connection Refused: not authorised.
2024-06-07 14:38:07.549 DEBUG (MainThread) [homeassistant.components.mqtt.client] mqtt.flespi.io: connection closed 39
What version of Home Assistant Core has the issue?
2024.6.0
What was the last working version of Home Assistant Core?
never got it working...
What type of installation are you running?
HA on Docker on Linux
Integration causing the issue
mqtt
Link to integration documentation on our website
https://www.home-assistant.io/integrations/mqtt
Diagnostics information
Troubleshooting I already did:
- Tried deleting the token in Flespi and creating a new. Tried different ACL's
- found a similar issue at Openhab, and tried the same. This taught me to investigate if MQTT might not work with 64-byte tokens. So I tried to set up a shorter token in Flespi. Unfort. that is not possible. Only 64-byte tokens are allowed.
- do not use birth message (Configurations -> Integrations -> MQTT -> Configure -> Re-Configure MQTT -> Submit -> Untick "Enable birth message" -> Submit), as per suggestion here
- Tried MQTT protocol v5, but that gave me an "unknown reason" error:
2024-06-07 14:37:54.572 DEBUG (MainThread) [homeassistant.components.mqtt.client] mqtt.flespi.io: connection opened 27
2024-06-07 14:37:54.573 DEBUG (MainThread) [homeassistant.components.mqtt.client] mqtt.flespi.io: Starting client misc loop
2024-06-07 14:37:54.573 DEBUG (MainThread) [homeassistant.components.mqtt.client] mqtt.flespi.io: register write 27
2024-06-07 14:37:54.575 DEBUG (MainThread) [homeassistant.components.mqtt.client] mqtt.flespi.io: unregister write 27
2024-06-07 14:37:54.599 ERROR (MainThread) [homeassistant.components.mqtt.client] Unable to connect to the MQTT broker: Connection Refused: unknown reason.
2024-06-07 14:37:54.599 DEBUG (MainThread) [homeassistant.components.mqtt.client] mqtt.flespi.io: connection closed 27
Additional information
MQTT Token in Flespi:
{
"ips": "",
"enabled": true,
"expire": 0,
"ttl": 31536000,
"info": "Home Assistant",
"access": {
"acl": [
{
"ids": "all",
"methods": [
"GET"
],
"uri": "gw/devices"
}
],
"type": 2
},
"metadata": {}
}