Hello,
I’m working on a tutorial for the integration between OpenMQTTGateway BLE , Theengs and OpenHAB 3.3.
I’m able to get data into OpenHAB
I use the Home Assistant MQTT auto discovery convention and have a few questions:
- we define sensors with all their properties (pres, lux). Depending on the sensor BLE API they may not broadcast all their properties in the same payload, for example a sensor defined by
pres
andlux
will broadcast a message withpres
only, generating this warning into OpenHAB:
2022-08-11 21:27:43.351 [WARN ] [t.generic.ChannelStateTransformation] - Executing the JINJA-transformation failed: An error occurred while transformation. UnknownTokenException: Unknown token found: value_json.lux
Here is a sensor message example that triggers the warning:
{
"id": "58:XXXXXXXXXX",
"mac_type": 0,
"name": "Qingping Motion & Light",
"rssi": -79,
"pres":1,
"servicedata": "305XXXXXXXX60342d5808",
"servicedatauuid": "0xfe95"
}
A sensor message that works without warning:
{"id":"58XXXXXXXX","mac_type":0,"name":"Qingping Motion & Light","rssi":-83,"brand":"Qingping","model":"Motion & Light","model_id":"CGPR1","lux":48,"pres":1}
And the sensor definitions by auto-discovery:
{"stat_t":"+/+/BTtoMQTT/XXXXX","dev_cla":"illuminance","unit_of_meas":"lx","name":"CGPR1-lux","uniq_id":"XXXXX-lux","val_tpl":"{{ value_json.lux}}","state_class":"measurement","device":{"identifiers":["XXXX"],"connections":[["mac","XXXXX"]],"manufacturer":"Qingping","model":"CGPR1","name":"Motion & Light","via_device":"OpenMQTTGateway_ESP32_BLE"}}
{"stat_t":"+/+/BTtoMQTT/XXXXXX","name":"CGPR1-pres","uniq_id":"XXXXX-pres","val_tpl":"{{ value_json.pres}}","state_class":"measurement","device":{"identifiers":["XXXX"],"connections":[["mac","XXXXXX"]],"manufacturer":"Qingping","model":"CGPR1","name":"Motion & Light","via_device":"OpenMQTTGateway_ESP32_BLE"}}
Is there a way to avoid triggering this warning ?
- Does OpenHAB autodiscovery following Home Assistant MQTT convention supports units of properties ?
I don’t see them translated from the discovery message, example for thescreenshot above:
{"stat_t":"+/+/BTtoMQTT/XXXXX","dev_cla":"temperature","unit_of_meas":"°C","name":"LYWSD03MMC_ATC-tempc","uniq_id":"XXXX-tempc","val_tpl":"{{ value_json.tempc}}","state_class":"measurement","device":{"identifiers":["XXXX"],"connections":[["mac","XXXXX"]],"manufacturer":"Xiaomi","model":"LYWSD03MMC_ATC","name":"LYWSD03MMC","via_device":"OpenMQTTGateway_ESP32_BLE"}}
Environment:
- Jinja transformation
- MQTT broker installed through OpenHABian
- MQTT binding