[solved] Openhab 3 unable to discover mqtt things with auto discovery

Hi All,

I am using homeassistant standard as below, and manually publishing the topic, but OH3 is unable to discover anything, even if I click the scan button, it is not able to find it.

homeassistant/binary_sensor/253/pir/config

Logs:

19:34:54.214 [DEBUG] [.core.karaf.internal.FeatureInstaller] - Running scheduled sync job
19:35:53.253 [DEBUG] [internal.DiscoveryServiceRegistryImpl] - Trying to start 2 scans with an aggregating listener.
19:35:53.255 [DEBUG] [internal.DiscoveryServiceRegistryImpl] - Triggering scan for thing types ‘[mqtt:systemBroker, mqtt:broker]’ on ‘MqttServiceDiscoveryService’…
19:35:53.256 [DEBUG] [internal.DiscoveryServiceRegistryImpl] - Finished 1 of 2 discovery services.
19:35:53.257 [DEBUG] [internal.DiscoveryServiceRegistryImpl] - Triggering scan for thing types ‘[mqtt:homie300]’ on ‘Homie300Discovery’…
19:35:53.258 [DEBUG] [internal.DiscoveryServiceRegistryImpl] - Finished 2 of 2 discovery services.
19:35:53.259 [DEBUG] [.internal.discovery.DiscoveryResource] - Scan for binding ‘mqtt’ successfully finished.

runtimeInfo:
  version: 3.1.0
  buildString: "Build #2143"
locale: en_US
systemInfo:
  configFolder: /openhab/conf
  userdataFolder: /openhab/userdata
  logFolder: /openhab/userdata/logs
  javaVersion: 11.0.9
  javaVendor: Azul Systems, Inc.
  javaVendorVersion: Zulu11.43+21-CA
  osName: Linux
  osVersion: 5.8.0-38-generic
  osArchitecture: amd64
  availableProcessors: 8
  freeMemory: 799574744
  totalMemory: 1522532352
bindings:
  - mqtt
clientInfo:
  device:
    ios: false
    android: false
    androidChrome: false
    desktop: true
    iphone: false
    ipod: false
    ipad: false
    edge: false
    ie: false
    firefox: false
    macos: false
    windows: false
    cordova: false
    phonegap: false
    electron: false
    nwjs: false
    webView: false
    webview: false
    standalone: false
    pixelRatio: 1
    prefersColorScheme: light
  isSecureContext: true
  locationbarVisible: true
  menubarVisible: true
  navigator:
    cookieEnabled: true
    deviceMemory: 8
    hardwareConcurrency: 8
    language: en-US
    languages:
      - en-US
      - en
    onLine: true
    platform: Linux x86_64
  screen:
    width: 1920
    height: 1080
    colorDepth: 24
  support:
    touch: false
    pointerEvents: true
    observer: true
    passiveListener: true
    gestures: false
    intersectionObserver: true
  themeOptions:
    dark: light
    filled: true
    pageTransitionAnimation: default
    bars: filled
    homeNavbar: default
    homeBackground: default
    expandableCardAnimation: default
  userAgent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like
    Gecko) Chrome/87.0.4280.141 Safari/537.36
timestamp: 2021-01-15T15:44:26.212Z

Do you have the JINJA and JSONPATH Transformation Services installed?

Yes,

233 │ Active │ 75 │ 3.1.0.202101150350 │ openHAB Add-ons :: Bundles :: Transformation Service :: Jinja
235 │ Active │ 75 │ 3.1.0.202101150350 │ openHAB Add-ons :: Bundles :: Transformation Service :: JSonPath

There is a toggle on the MQTT Broker thing to enable/disable autodiscovery. Is autodiscovery turned on?

Yes,

UID: mqtt:broker:gateway
label: MQTT Gateway
thingTypeUID: mqtt:broker
configuration:
lwtQos: 0
publickeypin: true
clientID: openhab
keepAlive: 60
qos: 0
reconnectTime: 60000
port: 1883
host: 192.168.1.101
secure: false
certificatepin: true
lwtRetain: true
enableDiscovery: true
location: Workshop

Here are the logs If I manually create HomeAssistant MQTT Component

20:19:04.833 [TRACE] [o.transport.mqtt.MqttBrokerConnection] - subscribeRaw message consumer for topic ‘homeassistant/sensor/253/temperature/state’ from broker ‘192.168.1.101’
20:19:04.837 [TRACE] [o.transport.mqtt.MqttBrokerConnection] - Successfully subscribed to topic homeassistant/sensor/253/temperature/state
20:19:04.838 [DEBUG] [hab.binding.mqtt.generic.ChannelState] - Subscribed channel mqtt:homeassistant:gateway:7f7891901f:253_5Ftemperature_5Fsensor#sensor to topic: homeassistant/sensor/253/temperature/state
20:19:31.863 [TRACE] [assistant.internal.DiscoverComponents] - Found HomeAssistant thing temperature component sensor

But not via auto-discovery.

Either this is a bug or you have to manually create the HomeAssistant Things like your log seems to indicate. It does say that it “Found HomeAssistant thing” so there is some sort of discovery going on. You wouldn’t see those logs if you created a Generic MQTT Thing.

No, I did not create the Generic MQTT Think. but HomeAssistant MQTT Component as below.

1 Like

So, did you create the Broker Thing?

Yes, below rite? Or, is it something else?

UID: mqtt:broker:gateway
label: MQTT Gateway
thingTypeUID: mqtt:broker
configuration:
  lwtQos: 0
  publickeypin: true
  clientID: openhab2.5
  keepAlive: 60
  qos: 0
  reconnectTime: 60000
  port: 1883
  host: 192.168.1.101
  secure: false
  certificatepin: true
  lwtRetain: true
  enableDiscovery: true
location: Workshop

Issue resolved.

sudo systemctl stop openhab.service
sudo openhab-cli clean-cache
sudo systemctl start openhab.service

I have the same issue, but running docker…there

systemctl does not exists… Any idea so soöve this at Docker ?

So the container.
Delete the contents of the cache and temp folders under the userdata.
Restart the container.

Thank you,

…but this did not solve my problem with the “auto discovery” for zigbee2mqtt…

Any Idea ?

I don’t the l use zigbee2mqtt do I’ve no ideas. I know zigbee2mqtt head multiple modes, maybe you are not using one of the discoverable modes.