- Platform information:
- Hardware: Raspberry Pi 4 Model B Rev 1.1
- OS: Raspbian GNU/Linux 10 (buster)
- Java Runtime Environment: N/A
- openHAB version:openHAB 2.5.12 (Release Build)
Hi,
I am looking for an idea how to handle the data sent by MQTT Tasmota devices. I suspect that a rule and a group will be necessary, but maybe you can suggest something else?
First things first. The data I get from ESP32 tasmota all come from “tele/tasmota_16C04C/SENSOR” five lines within five seconds.
19:55:41.797 MQT: tele/tasmota_16C04C/SENSOR = {"Time":"2021-03-22T19:55:41","ATC675cc6":{"mac":"a4c138675cc6","Temperature":21.5,"Humidity":36.0,"DewPoint":5.8,"Battery":86,"RSSI":-71},"ATC80058f":{"mac":"a4c13880058f","Temperature":22.0,"Humidity":35.0,"DewPoint":5.8,"Battery":67,"RSSI":-91}}
19:55:42.798 MQT: tele/tasmota_16C04C/SENSOR = {"Time":"2021-03-22T19:55:42","ATCda736b":{"mac":"a4c138da736b","Temperature":22.4,"Humidity":34.0,"DewPoint":5.7,"Battery":86,"RSSI":-79},"ATC10aee6":{"mac":"a4c13810aee6","Temperature":21.9,"Humidity":37.0,"DewPoint":6.5,"Battery":87,"RSSI":-62}}
19:55:43.804 MQT: tele/tasmota_16C04C/SENSOR = {"Time":"2021-03-22T19:55:43","ATC0b8a58":{"mac":"a4c1380b8a58","Temperature":22.2,"Humidity":32.0,"DewPoint":4.7,"Battery":82,"RSSI":-69},"ATC987532":{"mac":"a4c138987532","Temperature":22.5,"Humidity":35.0,"DewPoint":6.2,"Battery":51,"RSSI":-82}}
19:55:44.796 MQT: tele/tasmota_16C04C/SENSOR = {"Time":"2021-03-22T19:55:44","MJ_HT_V1343db2":{"mac":"582d34343db2","Temperature":21.8,"Humidity":39.8,"DewPoint":7.5,"Battery":87,"RSSI":-84},"ATC5d574e":{"mac":"a4c1385d574e","Temperature":22.4,"Humidity":32.0,"DewPoint":4.9,"Battery":76,"RSSI":-74}}
19:55:45.794 MQT: tele/tasmota_16C04C/SENSOR = {"Time":"2021-03-22T19:55:45","ATC887989":{"mac":"a4c138887989","Temperature":23.8,"Humidity":37.0,"DewPoint":8.2,"Battery":80,"RSSI":-77}}
If each recognized sensor had its own number /SENSOR1 /SENSOR2 … life would be easier and it wouldn’t be a problem because you could rigidly address it. At the moment I tried as below:
Thing mqtt:topic:bleSYP32 "32Mijia Syp" (mqtt:broker:xyz) {
Channels:
Type number : temp "32Temp" [
stateTopic="tele/tasmota_16C04C/SENSOR",
transformationPattern="JSONPATH:$.ATC0b8a58.Temperature"
]
Type number : humi "32Humi" [
stateTopic="tele/tasmota_16C04C/SENSOR",
transformationPattern="JSONPATH:$.ATC0b8a58.Humidity"
]
Thing mqtt:topic:bleSALr32 "32Mijia Sal" (mqtt:broker:xyz) {
Channels:
Type number : temp "32Temp" [
stateTopic="tele/tasmota_16C04C/SENSOR",
transformationPattern="JSONPATH:$.ATC675cc6.Temperature"
]
Type number : humi "32Humi" [
stateTopic="tele/tasmota_16C04C/SENSOR",
transformationPattern="JSONPATH:$.ATC675cc6.Humidity"
]
Items
Number MijiaSalRTemp32 "32 temp salon regał" (ESP32) {channel="mqtt:topic:bleSALr32:temp"}
Number MijiaSalRHumi32 "32 humi salon regał" (ESP32) {channel="mqtt:topic:bleSALr32:humi"}
Number MijiaSypTemp32 "32 temp sypialnia" (ESP32) {channel="mqtt:topic:bleSYP32:temp"}
Number MijiaSypHumi32 "32 humi sypialnia" (ESP32) {channel="mqtt:topic:bleSYP32:humi"}
Unfortunately, currently hard addressing causes dozens of error messages with every MQTT message sent.
Below are only three of them
2021-03-22 20:03:43.793 [WARN ] [t.generic.ChannelStateTransformation] - Executing the JSONPATH-transformation failed: Invalid path '$.ATC675cc6.Temperature' in '{"Time":"2021-03-22T20:03:43","ATC0b8a58":{"mac":"a4c1380b8a58","Temperature":22.1,"Humidity":32.0,"DewPoint":4.6,"Battery":81,"RSSI":-68},"ATC987532":{"mac":"a4c138987532","Temperature":22.5,"Humidity":36.0,"DewPoint":6.7,"Battery":50,"RSSI":-83}}'
2021-03-22 20:03:43.796 [WARN ] [t.generic.ChannelStateTransformation] - Executing the JSONPATH-transformation failed: Invalid path '$.ATC675cc6.Humidity' in '{"Time":"2021-03-22T20:03:43","ATC0b8a58":{"mac":"a4c1380b8a58","Temperature":22.1,"Humidity":32.0,"DewPoint":4.6,"Battery":81,"RSSI":-68},"ATC987532":{"mac":"a4c138987532","Temperature":22.5,"Humidity":36.0,"DewPoint":6.7,"Battery":50,"RSSI":-83}}'
2021-03-22 20:03:44.722 [WARN ] [t.generic.ChannelStateTransformation] - Executing the JSONPATH-transformation failed: Invalid path '$.ATC0b8a58.Temperature' in '{"Time":"2021-03-22T20:03:44","MJ_HT_V1343db2":{"mac":"582d34343db2","Temperature":21.9,"Humidity":39.2,"DewPoint":7.4,"Battery":87,"RSSI":-86},"ATC5d574e":{"mac":"a4c1385d574e","Temperature":22.4,"Humidity":32.0,"DewPoint":4.9,"Battery":76,"RSSI":-80}}'
In your opinion, it is possible to embrace it as a rule if the (ESP32) group contains ATC675cc6 or ATC0b8a58 or 12345678 or 53425132 (other known data to filter) make the transformation like:
JSONPATH-transformation ‘$ .ATC675cc6.Temperature’
So basically to extract somehow data like Temperature Humidity and DewPoint?
Tasmota behaves similarly when reporting changes from MCP23017. All information about state changes is sent as same “stat/K/MCP230XX_INT” which currently prevents from easy updating variables from D0 to D8.
20:11:43 MQT: stat/K/MCP230XX_INT = {"Time":"2021-03-22T20:11:43","MCP230XX_INT":{"D5":1,"MS":1456991978}}
20:11:43 MQT: stat/K/EVENT = {"Event":"Done"}
20:11:44 MQT: stat/K/MCP230XX_INT = {"Time":"2021-03-22T20:11:44","MCP230XX_INT":{"D8":0,"MS":303}}
20:11:44 MQT: stat/K/EVENT = {"Event":"Done"}