[Solved] OpenMQTTGateway v0.9.5 with openHab 2.5.10 does not show values

I try to use OpenMQTTGateway with openHab for BLE devices and most of it looks OK. I see my devices in the Inbox and can add the devices to things and create items but for some reason everything keeps status Unknown of offline.

What I see in mosquitto

homeassistant/sensor/3C71BFC3B83CgatewayBT/config {“stat_t”:“myhouse_ble/OpenMQTTGateway_ESP32_BLE/BTtoMQTT”,“name”:“gatewayBT”,“uniq_id”:“3C71BFC3B83CgatewayBT”,“val_tpl”:“{{ value_json.id | is_defined }}”,“device”:{“name”:“OpenMQTTGateway_ESP32_BLE”,“manufacturer”:“OMG_community”,“sw_version”:“v0.9.5”,“identifiers”:[“3C71BFC3B83C”]}}
homeassistant/sensor/A4C1385E2D55-LYWSD03MMC-batt/config {“stat_t”:“myhouse_ble/OpenMQTTGateway_ESP32_BLE/BTtoMQTT/A4C1385E2D55”,“name”:“LYWSD03MMC-batt”,“uniq_id”:“A4C1385E2D55-LYWSD03MMC-batt”,“dev_cla”:“battery”,“val_tpl”:“{{ value_json.batt | is_defined }}”,“unit_of_meas”:“%”}
homeassistant/sensor/A4C1385E2D55-LYWSD03MMC-volt/config {“stat_t”:“myhouse_ble/OpenMQTTGateway_ESP32_BLE/BTtoMQTT/A4C1385E2D55”,“name”:“LYWSD03MMC-volt”,“uniq_id”:“A4C1385E2D55-LYWSD03MMC-volt”,“val_tpl”:“{{ value_json.volt | is_defined }}”,“unit_of_meas”:“V”}
homeassistant/sensor/A4C1385E2D55-LYWSD03MMC-tempc/config {“stat_t”:“myhouse_ble/OpenMQTTGateway_ESP32_BLE/BTtoMQTT/A4C1385E2D55”,“name”:“LYWSD03MMC-tempc”,“uniq_id”:“A4C1385E2D55-LYWSD03MMC-tempc”,“dev_cla”:“temperature”,“val_tpl”:“{{ value_json.tempc | is_defined }}”,“unit_of_meas”:“C”}
homeassistant/sensor/A4C1385E2D55-LYWSD03MMC-tempf/config {“stat_t”:“myhouse_ble/OpenMQTTGateway_ESP32_BLE/BTtoMQTT/A4C1385E2D55”,“name”:“LYWSD03MMC-tempf”,“uniq_id”:“A4C1385E2D55-LYWSD03MMC-tempf”,“dev_cla”:“temperature”,“val_tpl”:“{{ value_json.tempf | is_defined }}”,“unit_of_meas”:“F”}
homeassistant/sensor/A4C1385E2D55-LYWSD03MMC-hum/config {“stat_t”:“myhouse_ble/OpenMQTTGateway_ESP32_BLE/BTtoMQTT/A4C1385E2D55”,“name”:“LYWSD03MMC-hum”,“uniq_id”:“A4C1385E2D55-LYWSD03MMC-hum”,“dev_cla”:“humidity”,“val_tpl”:“{{ value_json.hum | is_defined }}”,“unit_of_meas”:“%”}
homeassistant/binary_sensor/3C71BFC3B83C/config {“stat_t”:“myhouse_ble/OpenMQTTGateway_ESP32_BLE/LWT”,“name”:“OpenMQTTGateway_ESP32_BLE”,“uniq_id”:“3C71BFC3B83C”,“dev_cla”:“connectivity”,“pl_on”:“online”,“pl_off”:“offline”,“pl_avail”:“online”,“pl_not_avail”:“offline”}
homeassistant/switch/3C71BFC3B83Crestart/config {“stat_t”:“myhouse_ble/OpenMQTTGateway_ESP32_BLE/LWT”,“name”:“restart OMG”,“uniq_id”:“3C71BFC3B83Crestart”,“pl_on”:“{"cmd":"restart"}”,“pl_avail”:“online”,“pl_not_avail”:“offline”,“cmd_t”:“myhouse_ble/OpenMQTTGateway_ESP32_BLE/commands/MQTTtoSYS/config”,“device”:{“name”:“OpenMQTTGateway_ESP32_BLE”,“manufacturer”:“OMG_community”,“sw_version”:“v0.9.5”,“identifiers”:[“3C71BFC3B83C”]}}
homeassistant/switch/3C71BFC3B83Cerase/config {“stat_t”:“myhouse_ble/OpenMQTTGateway_ESP32_BLE/LWT”,“name”:“erase OMG”,“uniq_id”:“3C71BFC3B83Cerase”,“pl_on”:“{"cmd":"erase"}”,“pl_avail”:“online”,“pl_not_avail”:“offline”,“cmd_t”:“myhouse_ble/OpenMQTTGateway_ESP32_BLE/commands/MQTTtoSYS/config”,“device”:{“name”:“OpenMQTTGateway_ESP32_BLE”,“manufacturer”:“OMG_community”,“sw_version”:“v0.9.5”,“identifiers”:[“3C71BFC3B83C”]}}
hostname/lwt_topic offline
ble/lwt_topic offline
myhouse_ble/OpenMQTTGateway_ESP32_BLE/LWT online
myhouse_ble/OpenMQTTGateway_ESP32_BLE/version v0.9.5
home/home_presence/OpenMQTTGateway_ESP32_BLE {“id”:“A4:C1:38:5E:2D:55”,“name”:“LYWSD03MMC”,“rssi”:-72,“distance”:4.287841}
myhouse_ble/OpenMQTTGateway_ESP32_BLE/BTtoMQTT/A4C1385E2D55 {“id”:“A4:C1:38:5E:2D:55”,“name”:“LYWSD03MMC”,“rssi”:-72,“distance”:4.287841,“servicedata”:“30585b0501552d5e38c1a4280100”}

I think this looks OK but for some reason I get errors in the log when I create an item.

[ab.binding.mqtt.generic.ChannelState] - Incoming payload ‘’ not supported by type ‘NumberValue’

Is this a known bug?

Well, the error is telling you that the Thing is receiving and parsing the message and expecting to get a Number as a result. But it’s not getting a number, it’s getting something else (probably a String or the like). The messages appear to be all JSON formatted strings.

I don’t know anything about OpenMQTTGateway nor the home assistant MQTT standard so I can’t tell you whether the problem is with openHAB’s binding or OpenMQTTGateway not conforming to the standard correctly. I know with the Homie standard it tells you what type of data to expect.

Hi @mgb,

So as to use OpenMQTTGateway + OpenHAB auto discovery function with Home Assistant convention you need to set this macro to true into config_mqttDiscovery.h
#define OpenHABDiscovery true

1 Like

So is there something that the openHAB binding is not doing right regarding the HA MQTT standard? If so an issue should be files.

I don’t think so, once the OMG configuration is changed he should be able to see the values

Ok, after some problems I compiled a version in the Arduino IDE and uploaded the new sketch to my ESP32Dev.
Before I uploaded the binary.
After recompile, uploading and reset the device is working again but now I do not receive the homeassistant/sensor/… part. Therefore therefore the devices do not get added to the inbox of OpenHAB.

My understanding was that the openHAB mqtt implementation was fully compatible with homeassistant. But that is clearly not the case.

So it’s still not working because on reset of the ESP32 I do not see the homeassistant/sensor/… topic.

Any ideas?

I recompiled my esp32 several times with

#define OpenHABDiscovery

in config_mqttDiscovery.h both true and false but both ways I do not see the discovery topic in my mqtt stream.
Cleared the mosquitto cache but that that also didn’t make a difference.

I see the only difference between Openhab and Home Assistant auto discovery is the following:

Openhab: “{{ value_json.batt }}”
Home Assistant: “{{ value_json.batt | is_defined }}”

Is there a specific reason the “is_defined” part is added so this does not work inside Openhab?

Got a bit further,

Forgot to enable #define ZmqttDiscovery “HADiscovery” in the User_config.h file.

Recompiled and erased settings and now I get the following homeassistant info:

homeassistant/sensor/A4C138A19755-LYWSD03MMC-batt/config {“stat_t”:“home/OpenMQTTGateway/BTtoMQTT/A4C138A19755”,“name”:“LYWSD03MMC-batt”,“uniq_id”:“A4C138A19755-LYWSD03MMC-batt”,“dev_cla”:“battery”,“val_tpl”:“{{ value_json.batt }}”,“unit_of_meas”:“%”}
homeassistant/sensor/A4C138A19755-LYWSD03MMC-volt/config {“stat_t”:“home/OpenMQTTGateway/BTtoMQTT/A4C138A19755”,“name”:“LYWSD03MMC-volt”,“uniq_id”:“A4C138A19755-LYWSD03MMC-volt”,“val_tpl”:“{{ value_json.volt }}”,“unit_of_meas”:“V”}

This looks OK to me. At least different than the previous time.

Now I received the following data but I still get an error in openhab2.log

home/home_presence/OpenMQTTGateway {“id”:“A4:C1:38:A1:97:55”,“name”:“LYWSD03MMC”,“rssi”:-56,“distance”:0.593417}
home/OpenMQTTGateway/BTtoMQTT/A4C138A19755 {“id”:“A4:C1:38:A1:97:55”,“name”:“LYWSD03MMC”,“rssi”:-56,“distance”:0.593417,“servicedata”:“30585b05015597a138c1a4280100”}

The error in the log is still the same:

2020-11-13 13:35:28.742 [WARN ] [ab.binding.mqtt.generic.ChannelState] - Incoming payload ‘’ not supported by type ‘NumberValue’

I cleaned the cache of Openhab again and also the cache from mosquitto but still no valid data.

Did you updated the LYWSD03MMC firmware?

You can use this tutorial:

Thanks @1technophile,

This solved my problem. I have 8 sensors and some gave info and others didn’t. After flashing all the devices all devices work.

1 Like