I’m trying to get MQTT auto discovery working. I have the MQTT Mosquitto add-on and the MQTT integration installed. MQTT integration has “add new devices” switch turned on.
MQTT integration is configured to enable anonymous connections. I can connect with MQTT explorer on Windows. When I add the example in the documentation nothing happens.
(Example: Topic: homeassistant/binary_sensor/garden/config and payload: {“name”: “garden1”, “device_class”: “motion”, “state_topic”: “homeassistant/binary_sensor/garden/state”}
I have Home Assistant (hassio) running in docker on Ubuntu.
I see this in the log:
2020-02-29 19:08:03 DEBUG (MainThread) [homeassistant.components.mqtt] Subscribing to homeassistant/#
2020-02-29 19:08:04 DEBUG (MainThread) [homeassistant.components.mqtt] Subscribing to homeassistant/#
But nothing more when publishing example to the mqtt add-on.
But that shouldn’t be needed when using the integration.
I couldn’t find the discovery_prefix the integration uses, but the log seems to indicate “homeassistant”. (Also i’m getting port in use messages when I do try to add this to configuration.)
This put me on the right track. Those tests didn’t work. Then I removed the mqtt integration, but didn’t use the “discovered” mqtt integration, but added one myself and put in the 127.0.0.1 IP (or the network IP of course) and this worked.
Apparently when you add the “discovered” mqtt integration it doesn’t configure the mqtt integration correctly. It doesn’t offer you to put in the IP address. Bug it seems…
I’m going to test and see if discovery does work with the new configuration.
Did you figure out the issue you were having because I think I am having the same issue. The Broker is receiving all of the topics I am sending from various sources (Weather, Roon, etc) but devices never get discovered. If I manually add a sensor to the configuration.yaml that individual device (Temperature ex.) works fine.
Yes, discovery is turned on (I think it was on by default). Install steps I did; Installed MQTT in Supervisor Add-ons and then configured the auto-discovered MQTT in Integrations. Then added mqtt sensors in configuration.yaml and they work but other servers sending MQTT topics to the HA broker is not getting creating devices. Do you have to use the same mqtt user for everything? Thanks for the help!
Here is a sample from the Broker logs:
1611505264: Opening ipv4 listen socket on port 1883.
1611505264: Opening ipv6 listen socket on port 1883.
1611505264: Opening websockets listen socket on port 1884.
1611505264: Warning: Mosquitto should not be run as root/administrator.
1611505265: New connection from 192.168.0.113 on port 1883.
[INFO] found mqtt on Home Assistant
1611505265: New client connected from 192.168. as roon-extension-mqtt-exydm (p2, c1, k60, u’mqtt’).
1611505277: New connection from 192.168 on port 1883.
1611505277: New client connected from 192.168.0.9 as weewx_e (p2, c1, k60, u’mqtt’).
1611505277: Client weewx_e0473da9 disconnected.
1611505289: New connection from 172.30.32.1 on port 1883.
[INFO] found homeassistant on local database
1611505289: New client connected from 172.30.32.1 as XXXXXXXXXXXXXXXX (p2, c1, k60, u’homeassistant’).
1611505336: New connection from 192.168.0.x on port 1883.
In the screenshot you posted, it is missing a root topic named homeassistant. That’s the default topic Home Assistant uses for MQTT Discovery. It means those “other servers” are not publishing to the MQTT Discovery topic.
I remember seeing homeassistant before reinstalling the add-on and integration. I’ll try some more stuff today to get the homeassistant topic back and go from there. Thanks again for your help!
I reconfigured mqtt to use the HA “mqttuser” account I created and “homeassistant” started showing up in mqtt explorer/broker and it shows “online”. I changed the weather server to publish to homeassistant/weather. If it starts to discover where would I see what it discovers, in the log?
It requires the topic and the payload to conform to a specific format (see the link in the first line). If they do, Home Assistant will use the supplied information to create an entity.
Currently, MQTT Discovery doesn’t support the creation of a weather entity. Moreover, there is no MQTT integration for weather (so it can’t be defined manually either).
What you can do is create an MQTT Sensor for each weather-related parameter (temperature, humidity, wind speed, wind direction, precipitation amount, etc).
EDIT
Didn’t see nickrout’s post displayed until after I posted … so ninja’d again.
Awesome, well not awesome that it doesn’t support weather but now I know why it wasn’t working. I will add the sensors back to my configuration.yaml for now. You wouldn’t happen to know if roon falls under one of the categories listed in “supported devices” would you? The HA Roon integration detected and installed but Roon MQTT seems to have more details.