[SOLVED] BME280 Temperature on Sonoff Basic with Tasmota

Hi,

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”}

But it won’t display the value in my HabPanel:
grafik

What did i wrong?

Thanks!

BW

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 :slight_smile:

No, absolutely unnecessary

Please use the code fences as mentionned above:How to use code fences

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

Hi Vincet,
You’re right, I went a step further because I store the values ​​in the database.

The persistence and the things set-up have nothing to do with each other
Keep it simple

Does the switch item work?

Yes, but Maximilian has Things defined as Numbers. From sensor is JSON string so in Paper UI You see NaN because it is string not number

Yes, the switch is working…

I’ve also tried it with string, but in this case, the whole json string is displayed.

I only want to display the temperature and humidity value separately.

Can You show Log please? And do You have JSONPath Transformation installed?

No, openHAB should extract the number from the string as a number

Did you install the JSONPATH transformation?

Quick test with Number.

[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'

Is the JSONPATH transformation installed?

My thing and channel:


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

My item is:

Number:Temperature  Fridge_Temperature  "Fridge Temperature  [%.1f °C]" <temperature> (appliances, Persist, MQTTv2) { channel="mqtt:topic:FridgeFreezer:FridgeTemperature", alexa="TemperatureSensor.temperature" }

Yes, Its works but if you look in to logs, you will see warn not supported by type ‘Number Value’.
My Thing looks except Type.

I don’t get this in my logs

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.

Hi,

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’

Ok, thank you all!

Now it is working. Rebooting helped OH2 to make it working. Now the temperature is displayed.

BW Maximilian