Broken HomeAssistant MQTT Discovery?

  • Platform information:
    • openHAB version: 3.2.0M1
  • Issue of the topic: I’m sending this to my mqtt mosquitto broker but the MQTT discovery doesn’t see anything
homeassistant/sensor/R5EE70BB9_N321346B4/config {"~":"Bedroom/BME280","dev_cla":"temperature","name":"Bedroom Temperature","stat_t":"~state","unit_of_meas":"°C","json_attributes_topic":"~state","val_tpl":"{{ value_json.temperature }}","uniq_id":"R5EE70BB9_N321346B4"
,"avty_t":"~status","pl_avail":"Online","pl_not_avail":"Offline","device":{"identifiers":["R5EE70BB9"],"connections":["mac","00155D009500","8C8CAAEE1F8F"],"name":"BME280 Bedroom"}}

I had some luck a day ago seeing some of this auto discovery working. Now I even configured the System MQTT Broker (which btw has the encryption flag broken in the UI) but nothing in the logs and no sign of discovery. I have trace enabled in the discovery.

Also there is no warning or error related to the discovery in the logs

Any suggestions?

You don’t want that, and it causes people trouble. Remove it.

Enable Discovery is an option on your proper broker bridge Thing,maybe disable/re-enable that.

1 Like

Ohhh how do I remove it? yes something was working before I touched that

How did you add it?

I never added it… I just configured some of the settings in “Other services” and then it started showing up in Inbox.

This might help

Ok I think I figured out how to get rid of the system broker but that hasn’t solved the discovery.
Something seems to be missing but I don’t have any clues because there is nothing else beside these warnings at shutdown

openhab.log.1:2021-08-03 12:11:56.066 [WARN ] [g.mqtt.handler.AbstractBrokerHandler] - Tried to unsubscribe org.openhab.binding.mqtt.homie.internal.discovery.Homie300Discovery@2de52cc4 from  discovery topic homeassistant/# on broker mqtt:broker:6f8979a9 but topic not registered for listener. Check discovery logic!
openhab.log.1:2021-08-03 12:11:56.068 [WARN ] [g.mqtt.handler.AbstractBrokerHandler] - Tried to unsubscribe org.openhab.binding.mqtt.homie.internal.discovery.Homie300Discovery@2de52cc4 from  discovery topic milight/states/# on broker mqtt:broker:6f8979a9 but topic not registered for listener. Check discovery logic!
openhab.log.1:2021-08-03 12:11:56.207 [WARN ] [g.mqtt.handler.AbstractBrokerHandler] - Tried to unsubscribe org.openhab.binding.mqtt.homeassistant.internal.discovery.HomeAssistantDiscovery@2448ff2e from  discovery topic +/+/$homie on broker mqtt:broker:6f8979a9 but topic not registered at all. Check discovery logic!
openhab.log.1:2021-08-03 12:11:56.209 [WARN ] [g.mqtt.handler.AbstractBrokerHandler] - Tried to unsubscribe org.openhab.binding.mqtt.homeassistant.internal.discovery.HomeAssistantDiscovery@2448ff2e from  discovery topic milight/states/# on broker mqtt:broker:6f8979a9 but topic not registered for listener. Check discovery logic!
openhab.log.1:2021-08-03 12:11:56.234 [WARN ] [g.mqtt.handler.AbstractBrokerHandler] - Tried to unsubscribe org.openhab.binding.mqtt.homeassistant.internal.discovery.HomeAssistantDiscovery@2448ff2e from  discovery topic homeassistant/# on broker mqtt:broker:6f8979a9 but topic not registered at all. Check discovery logic!
openhab.log.1:2021-08-03 12:11:56.234 [WARN ] [g.mqtt.handler.AbstractBrokerHandler] - Tried to unsubscribe org.openhab.binding.mqtt.homeassistant.internal.discovery.HomeAssistantDiscovery@2448ff2e from  discovery topic +/+/$homie on broker mqtt:broker:6f8979a9 but topic not registered at all. Check discovery logic!
openhab.log.1:2021-08-03 12:11:56.235 [WARN ] [g.mqtt.handler.AbstractBrokerHandler] - Tried to unsubscribe org.openhab.binding.mqtt.homeassistant.internal.discovery.HomeAssistantDiscovery@2448ff2e from  discovery topic milight/states/# on broker mqtt:broker:6f8979a9 but topic not registered for listener. Check discovery logic!
openhab.log.1:2021-08-03 12:11:56.561 [WARN ] [g.mqtt.handler.AbstractBrokerHandler] - Tried to unsubscribe org.openhab.binding.mqtt.espmilighthub.internal.discovery.EspMilightHubDiscoveryService@3478bb29 from  discovery topic homeassistant/# on broker mqtt:broker:6f8979a9 but topic not registered at all. Check discovery logic!
openhab.log.1:2021-08-03 12:11:56.562 [WARN ] [g.mqtt.handler.AbstractBrokerHandler] - Tried to unsubscribe org.openhab.binding.mqtt.espmilighthub.internal.discovery.EspMilightHubDiscoveryService@3478bb29 from  discovery topic +/+/$homie on broker mqtt:broker:6f8979a9 but topic not registered at all. Check discovery logic!
openhab.log.1:2021-08-03 12:11:57.274 [WARN ] [ROOT                                ] - bundle org.openhab.ui.habot:3.2.0.M1 (311) BundleComponentActivator is not active; not scheduling Async Deactivate: org.openhab.ui.habot.notification.internal.WebPushNotificationModuleHandlerFactory id: 2

That’s a small nuisance bug.

Have you unselected enableDiscovery on your real Bridge broker Thing?

1 Like

There is Pull Request that will fix this bug. We just have to persuade the maintainers to adopt it.

1 Like

enableDiscovery is checked on my actual mqtt broker. I did uncheck, restart openhab and rechecked.
I do have this message in my logs

2021-08-03 16:53:36.951 [TRACE] [g.mqtt.handler.AbstractBrokerHandler] - Subscribed org.openhab.binding.mqtt.homeassistant.internal.discovery.HomeAssistantDiscovery@47868a4d to discovery topic homeassistant/# on broker mqtt:broker:6f8979a9

but this doesn’t seem to be sufficient, the inbox doesn’t see my homeassistant messages and there is nothing in the logs to indicate a failure.

Not much else you can do from OH side.

If you’re confident your discovery is being published, you can create an ordinary string type channel with stateTopic homeassistant/# as well and see if the message arrives.

I can confirm the message is received by openhab.

Aug  3 17:36:49 openhab mosquitto[25528]: Sending CONNACK to f2906dab586249e29e21299abf18e7cb (0, 0)
Aug  3 17:36:49 openhab mosquitto[25528]: Received PUBLISH from f2906dab586249e29e21299abf18e7cb (d0, q0, r0, m0, 'homeassistant/sensor/R5EE70BB9_N321346B4/config', ... (399 bytes))
Aug  3 17:36:49 openhab mosquitto[25528]: Sending PUBLISH to 9b6a4b16-d35c-426f-b0ad-cdc88373e133 (d0, q0, r0, m0, 'homeassistant/sensor/R5EE70BB9_N321346B4/config', ... (399 bytes))
Aug  3 17:36:49 openhab mosquitto[25528]: Socket error on client f2906dab586249e29e21299abf18e7cb, disconnecting.

However, it looks like the message never makes it to org.openhab.binding.mqtt.homeassistant.internal.DiscoverComponent.ProcessMessage

Looking that that class - it looks like nothing would be thrown in the logs if SubscribeFail or SubscribeSuccess did fail… could these be the cause?

Strictly, the mosquitto log shows it sent to OH. At least, I guess so, maybe.

I don’t know. Have you seen a subscribe failure at mosquitto? You should see both homeassistant and homie subscribes.

I can see the subscribe in mosquitto and see my message being dispatched from mosquitto to openhab but I’m more worried about a osgi subscription issue… From what I can see, homeassistant message never gets dispatched to the discovery class although all the MQTT subscriptions are fine. Also looking at few other messages, other people have experienced similar issues since OH 3.0 with the discovery services. There is not that much logging in the discovery classes, so I’m worried there is more stuff failing silently. Is there any easy way to debug all that code?

Hi!
Possible, that logging should be resolved by [mqtt.homeassistant] Discovery exceptions processing by antroids · Pull Request #11315 · openhab/openhab-addons · GitHub

I’ll check the reason when will have a time.

Oh, it was your issue [mqtt] homeassistant discovery unreliable in OH 3.x · Issue #11085 · openhab/openhab-addons · GitHub
It should be resolved.