Read ZigbeeToTasmota messages

  • Platform information:
    • Hardware: RBPi 3
    • OS: Raspbian GNU/Linux 9 (stretch)
    • Java Runtime Environment:(Zulu Embedded 8.25.0.76-linux-aarch32hf) (build 1.8.0_152-b76)
    • openHAB version: openHAB 2.5.0-1

I’ve installed the ZigbeeToTasmota and I receive the messages from broket mqtt like this:

{
	"ZigbeeReceived": {
		"0x7F70": {
			"Temperature": 21.32,
			"Humidity": 59.58,
			"PressureUnit": "hPa",
			"Pressure": 1013,
			"Scale": -1,
			"ScaledValue": 10138,
			"LinkQuality": 80
		}
	}
}

Or

{
	"ZigbeeReceived": {
		"0xB307": {
			"Power": false,
			"LinkQuality": 18
		}
	}
}

These messages may change and not always have the same elements.
Right now I have defined elements like:

	Thing topic  thpEstudio "Temperatura, humedad, presion estudio" @ "Estudio" {
		Channels:
			Type number : temperature		"Temperatura"				[ stateTopic="casa/pasillo/routerZigbee/tele/SENSOR", transformationPattern="JSONPATH:$.ZigbeeReceived.0x7F70.Temperature"]
			Type number : humidity			"Humedad"					[ stateTopic="casa/pasillo/routerZigbee/tele/SENSOR", transformationPattern="JSONPATH:$.ZigbeeReceived.0x7F70.Humidity"]
			Type number : pressure			"Presión"					[ stateTopic="casa/pasillo/routerZigbee/tele/SENSOR", transformationPattern="JSONPATH:$.ZigbeeReceived.0x7F70.Pressure"]
			Type number : batteryLevel		"Nivel bateria"				[ stateTopic="casa/pasillo/routerZigbee/tele/SENSOR", transformationPattern="JSONPATH:$.ZigbeeReceived.0x7F70.Battery"]
			Type number : linkQuality		"Zigbee Signal Strength"	[ stateTopic="casa/pasillo/routerZigbee/tele/SENSOR", transformationPattern="JSONPATH:$.ZigbeeReceived.0x7F70.LinkQuality"]
	}

But when I receive a message from something else, warnings appear in the logs. How could I avoid it?

==> /var/log/openhab2/openhab.log <==
2020-02-08 13:41:17.076 [WARN ] [t.generic.ChannelStateTransformation] - Executing the JSONPATH-transformation failed: Invalid path '$.ZigbeeReceived.0x7F70.Battery' in '{"ZigbeeReceived":{"0xB307":{"Power":true,"LinkQuality":0}}}'
2020-02-08 13:41:17.080 [WARN ] [t.generic.ChannelStateTransformation] - Executing the JSONPATH-transformation failed: Invalid path '$.ZigbeeReceived.0x7F70.LinkQuality' in '{"ZigbeeReceived":{"0xB307":{"Power":true,"LinkQuality":0}}}'
2020-02-08 13:41:17.084 [WARN ] [t.generic.ChannelStateTransformation] - Executing the JSONPATH-transformation failed: Invalid path '$.ZigbeeReceived.0x7F70.Humidity' in '{"ZigbeeReceived":{"0xB307":{"Power":true,"LinkQuality":0}}}'
2020-02-08 13:41:17.088 [WARN ] [t.generic.ChannelStateTransformation] - Executing the JSONPATH-transformation failed: Invalid path '$.ZigbeeReceived.0x7F70.Pressure' in '{"ZigbeeReceived":{"0xB307":{"Power":true,"LinkQuality":0}}}'
2020-02-08 13:41:17.092 [WARN ] [t.generic.ChannelStateTransformation] - Executing the JSONPATH-transformation failed: Invalid path '$.ZigbeeReceived.0x7F70.Temperature' in '{"ZigbeeReceived":{"0xB307":{"Power":true,"LinkQuality":0}}}'

Did you create your own items and have simple mode turned on in PaperUI? If so you have duplicate items/channels. Turn off simple mode, delete the things and rediscover.

That is normal, the transformation fails because the fields are missing in the JSON.
To resolve this you could try using a JS transformation and test if the field exists. I tried this and wasn’t very succesful with that approach.
So I receive the JSON is Node-RED and then according to the topics existing in the JSON, I republish the value into their own MQTT topics without transformation.

1 Like