i want to display the humidity and temperature of my bathroom in OH2. Therefore i want to use a Sonoff Basic with a BME280 Sensor.
The sensor is working and it gives me the following JSON string: 19:49:34 MQT: tele/Badluefter/SENSOR = {"Time":"2019-12-04T19:49:34","BME280":{"Temperature":21.0,"Humidity":44.1,"Pressure":952.4,"SeaPressure":1021.0},"PressureUnit":"hPa","TempUnit":"C"}
This is my things file:
Thing topic BadluefterSchalter “Badlüfter Schalter” {
Channels:
Type switch : BadluefterPower [ stateTopic=“stat/Badluefter/POWER”, commandTopic=“cmnd/Badluefter/POWER” ]
Type number : Temperature [ stateTopic=“tele/Badluefter/SENSOR”, transformationPattern=“JSONPATH:$.BME280.Temperature”]
Type number : Humidity [ stateTopic=“tele/Badluefter/SENSOR”, transformationPattern=“JSONPATH:$.BME280.Humidity”]
}
And this my items:
Switch BadluefterSchalter “Badlüfter” { channel=“mqtt:topic:ikarus:BadluefterSchalter:BadluefterPower”}
Number BadluefterTemp “Bad Temperatur [%s °C]” { channel=“mqtt:topic:ikarus:BadluefterSchalter:Temperature”}
Number BadluefterHumidity “Bad Luftfeuchtigkeit [%s %]” { channel=“mqtt:topic:ikarus:BadluefterSchalter:Humidity”}
Hi You must convert string to a number see here. Your Things and Items should be String type then converted to a Number. Put your code in to the code fences please. It is easier to read formatted code
Does the switch work?
Why did you use textual things files?
Define your things and channels with the PaperUI and your items with files. It’s much easier and you can’t really make mistakes
[ab.binding.mqtt.generic.ChannelState] - Incoming payload '{"Time":"2019-12-05T00:01:49","BME280":{"Temperature":21.6,"Humidity":61.6,"Pressure":1020.9,"SeaPressure":1024.3},"PressureUnit":"hPa","TempUnit":"C"}' not supported by type 'NumberValue'
Works on the same payload as above with JSONPATH on a number channel
There is NO need whatsoever to create a string channel and change it into a Number Item
May need to restart and or clean cache after making changes to files (assume you are on OH 2.4 b/c it’s not mentioned). After that see what show’s in the logs.
JSON path transformation was not installed. Now it is. But it doesn’t change anything.
This is my log before installing the JSON path transformation binding:
2019-12-05 17:34:35.507 [WARN ] [t.generic.ChannelStateTransformation] - Transformation service JSONPATH for pattern $.BME280.Humidity not found!
2019-12-05 17:34:35.507 [WARN ] [t.generic.ChannelStateTransformation] - Transformation service JSONPATH for pattern $.BME280.Humidity not found!
2019-12-05 17:34:35.509 [WARN ] [ab.binding.mqtt.generic.ChannelState] - Incoming payload ‘{“Time”:“2019-12-05T17:34:35”,“BME280”:{“Temperature”:19.8,“Humidity”:44.8,“Pressure”:954.8,“SeaPressure”:1023.7},“PressureUnit”:“hPa”,“TempUnit”:“C”}’ not supported by type ‘NumberValue’
2019-12-05 17:34:35.511 [WARN ] [ab.binding.mqtt.generic.ChannelState] - Incoming payload ‘{“Time”:“2019-12-05T17:34:35”,“BME280”:{“Temperature”:19.8,“Humidity”:44.8,“Pressure”:954.8,“SeaPressure”:1023.7},“PressureUnit”:“hPa”,“TempUnit”:“C”}’ not supported by type ‘NumberValue’
2019-12-05 17:34:35.511 [WARN ] [t.generic.ChannelStateTransformation] - Transformation service JSONPATH for pattern $.BME280.Temperature not found!
2019-12-05 17:34:35.513 [WARN ] [t.generic.ChannelStateTransformation] - Transformation service JSONPATH for pattern $.BME280.Temperature not found!
2019-12-05 17:34:35.513 [WARN ] [ab.binding.mqtt.generic.ChannelState] - Incoming payload ‘{“Time”:“2019-12-05T17:34:35”,“BME280”:{“Temperature”:19.8,“Humidity”:44.8,“Pressure”:954.8,“SeaPressure”:1023.7},“PressureUnit”:“hPa”,“TempUnit”:“C”}’ not supported by type ‘NumberValue’
2019-12-05 17:34:35.515 [WARN ] [ab.binding.mqtt.generic.ChannelState] - Incoming payload ‘{“Time”:“2019-12-05T17:34:35”,“BME280”:{“Temperature”:19.8,“Humidity”:44.8,“Pressure”:954.8,“SeaPressure”:1023.7},“PressureUnit”:“hPa”,“TempUnit”:“C”}’ not supported by type ‘NumberValue’