OpenMQTTGateway Autodiscovery with OpenHAB following Home Assistant convention

Hi,
i have modified the command. i executed but its seems nothing change


.
mosquitto_pub -h 192.168.178.36 -p 1884 -u myusername -P mypass -t “home/OpenMQTTGateway/commands/MQTTtoSYS/config” -m ‘{“ohdiscovery”:true}’

You need to replace OpenMQTTGateway by the name of your gateway, here OMG_ESP32_BLE

mosquitto_pub -h 192.168.178.36 -p 1884 -u myusername -P mypass -t “home/OMG_ESP32_BLE/commands/MQTTtoSYS/config” -m ‘{“ohdiscovery”:true}’

wrong copy paste :slight_smile:
i change the command but still the same. even after reboot the gateway its still false

Did you try with MQTT explorer ? Also note the quote that should be used below
{"ohdiscovery":true}

1 Like

Thank you
That was the missing part. :slight_smile:

1 Like

Hi again.

Even if i have set up the ohdiscovery to true , openhab give me errors

Executing the JINJA-transformation failed: An error occurred while transformation. UnknownTokenException: Unknown token found: value_json.batt | is_defined

  • {“stat_t”:“+/+/BTtoMQTT/A4C13820695D”,“dev_cla”:“humidity”,“unit_of_meas”:“%”,“name”:“LYWSD03MMC/MJWSD05MMC_PVVX-hum”,“uniq_id”:“A4C13820695D-hum”,“val_tpl”:“{{ value_json.hum | is_defined }}”,“state_class”:“measurement”,“device”:{“identifiers”:[“A4C13820695D”],“connections”:[[“mac”,“A4C13820695D”]],“manufacturer”:“Xiaomi”,“model”:“LYWSD03MMC/MJWSD05MMC_PVVX”,“name”:“TH Sensor-20695D”,“via_device”:“OpenMQTTGateway”}}

Any idea??

Thanks Nikos

Hello,

This may be previous messages that have not been overwritten.
You may delete those messages or wait for them to be overwritten m.

Hi
i have try everything but still no go. the thing it have the wrong flag all the time | is_defined.
i did also new setup on my mosquitto broker but still the same.

Hi,

Try maybe to publish the command with a retain flag so that it is taken at start

Hi,

I fix it, but just compiled and flash it again with the openhab option true in the environment file.
It discovered the new things and become green in seconds.

Thanks for your support
Nikos

Hello,

Do you mean that using the build flag worked right away?

Hi,
Yes exactly.
With the ready firmware even if the flag was changed with the command, i could not make them work because the “| is_defined” was always there.

Thanks
Nikos

Hello,

I have added a save option to the command in this Pull Request:

Could you try it and let me know if it works ?
mosquitto_pub -t "home/OpenMQTTGateway/commands/MQTTtoSYS/config" -m '{"ohdiscovery":true, "save":true}'

Sorry for the late reply.

where exactly to find the bin for downloading. :blush:

Thanks
Nikos

No problem, build in progress:

Should be available here in a couple of hours