openHAB2 + Sonoff TH10 Tasmota Temperature problem

Hi all,

I installed MQTT and openHAB2 on my Raspberry PI3. My Sonoff Switches are already working perfectly.
I’m preaty happy about that.

But now i just want to read the Temperature of my Sonoff TH10 but i never got any information.

When i look at the broker i get this information :

mosquitto_sub -t “#” -v

tele/sonoff_vu/SENSOR {“Time”:“2017-06-24T12:14:17”, “AM2301”:{“Temperature”:24.2, “Humidity”:49.7}, “TempUnit”:“C”}

can someone plese send me an example for an item and sitemap please?
I try it now for 3 days and don’t get it working.
Tanks

It seems that you should use the json xform
See here:

https://groups.google.com/d/msg/sonoffusers/dP8U19h9Zg8/JdkneaT-AwAJ

1 Like

I have a general question. Why does it work for some without json and not for me?

I will try it nevertheless and thanks for the tip.

I assume that it depends on how the SonOff publishes the info.
If it publishes Temp info on a seperate topic (e.g. /tele/sonoff_vu/SENSOR/Temp) you wouldn’t need a transformation
In this case, the MQTT message is not a simple string or number but a json payload so you need to “extract” the desired info from it.

1 Like

can I influence how the message is sent

Not sure… I still haven’t received my Sonoff devices to test :slight_smile:
Maybe you can find the answer to your question here:

& here maybe:

Thanks for your help. I extrated the information now and got it working

1 Like

How did you get it working? I don’t get mine. I just installed Sonoff TH16, and I see it sends string:

tele/sonoff-tp/SENSOR {"Time":"2017-07-02T21:16:13", "DHT22":{"Temperature":18.9, "Humidity":56.5}, "TempUnit":"C"}

This is monitored from my MQTT bus by using mosquitto_sub

Then I’ve added JSONPath transformation tool from paperUI to OpenHab. I have done the MQTT item using the json transformer:

$ grep back_ /etc/openhab2/{items,sitemaps}/kodin.*
/etc/openhab2/items/kodin.items:Number   back_temp  "Takapihan lämpömittari [%.2f °C]"   { mqtt="<[mosquitto:tele/sonoff-tp/SENSOR:state:JSONPATH($.DTH22.Temperature)]" }
/etc/openhab2/items/kodin.items:Number   back_hum   "Takapihan kosteusmittari [%.2f °C]" { mqtt="<[mosquitto:tele/sonoff-tp/SENSOR:state:JSONPATH($.DTH22.Humidity)]" }
/etc/openhab2/sitemaps/kodin.sitemap:        Text item=back_temp icon="temperature" valuecolor=[>20="orange",>15="green",>5="orange",<=5="blue"]
/etc/openhab2/sitemaps/kodin.sitemap:        Text item=back_hum icon="humidity"

I see the items in my panel, but there is just a “-” instead of value. The log says this every time sonoff updates the temp&hum:

22:26:14.941 [WARN ] [b.core.events.EventPublisherDelegate] - given new state is NULL, couldn't post update for 'back_temp'
22:26:14.943 [WARN ] [b.core.events.EventPublisherDelegate] - given new state is NULL, couldn't post update for 'back_hum'

Does someone know what the warning is about? Sounds a bit like the JSON transformer would not work?

BTW, JSON transformer is on the bundles:
openhab> bundle:list |grep -i jsonpath
198 | Active | 75 | 0.9.0.b4 | Eclipse SmartHome JSonPath Transformation Service

… one more thing, so the warning repeats each time the MQTT message is coming out from sonoff. So OpenHab receives the string, but somehow doesn’t get the value.

uuuuughh… Damned. I just copy pasted the lines from your another post without checking it all. The DHT is misspelled there, it should be DHT instead of DTH. Works now. Well, hopefully someone gets to reuse these settings :slight_smile:

Thanks for the thread, you got me going with this!

Hello,

I have the same problem as descibed in the 1st post.
5 DS18B20 should be connected via OneWire at a Sonoff Basic (GPIO14).

The shown values in the Sonoff webbrowser are OK, but Openhab doesn’t show anything. The solution of the 1st post doesnt’t help.
Jsonpath AddOn is installed (is there anything to do?)
Switching of the Sonoff relay is possible. Maybe any value is wrong in the .items or any selection in the Sonoff.

The entry in the .items is following:

Number HWR1_Temp2 “Temperature Kreis 2[%.2f °C]” (La_Labor)
{mqtt="<[broker:tele/sonoff_Heizung1/SENSOR:state:JSONPATH($.DS18x20.DS1.Temperature)]"}
Number HWR1_Temp3 “Temperature Kreis 3[%.2f °C]” (La_Labor)
{mqtt="<[broker:tele/sonoff_Heizung1/SENSOR:state:JSONPATH($.DS18x20.DS2.Temperature)]"}

Thanks

Hello,

the problem with the DS18x20 Sensors is solved. The Topics of the Sonoff and the MQTT-Message in the .items have not matched.

Now, I have a new problem. All is working fine, if I connect max. 4 sensors. If I connect a 5th sensor, a huge error message occurs in the openhab logs and all sensors are off. In the Sonoff browser all 5 sensors are working correct. I have changed the sensors - all sensors are working only in a combination of 4 sensors.

I have no idea, how I can find the cause.
Does somebody has any idea?

Thanks

Could you please provide a step by step process of how you solved the multiple DS18x20 sensors? I am also trying to figure out how to make this work and haven’t hit on the right answer yet.

Thanks

I’m not sure, if I’m can solve your problem (I’m a newby).

First test your setup with one sensor. My setup works only with 4 sensors. If I connect the 5th sensor, a large errormessage occurs and all sensors are off.

The Sonoff has to be programmed with a software supporting multiple sensors. In the user_config.h following change has to be made:

//#define USE_DS18x20                              // Optional for more than one DS18x20 sensors with id sort, single scan and read retry (+1.3k code)
#define USE_DS18x20_LEGACY                       // Optional for more than one DS18x20 sensors with dynamic scan using library OneWire (+1.5k code)

Here is an example of my .items:

	Number	Sonoff_Basic_03_Temp1		"Temperature Heizkreis 1 - Puffer Mitte[%.2f °C]"		<temperature>	(EG_HWR,Grafic_Temp_Heiz)
		{mqtt="<[broker:sonoff/tele/sonoff_Heizung1/SENSOR:state:JSONPATH($.DS18x20.DS1.Temperature)]"}
	Number	Sonoff_Basic_03_Temp2		"Temperature Heizkreis 2 - Warmwasser[%.2f °C]"			<temperature>	(EG_HWR,Grafic_Temp_Heiz)
		{mqtt="<[broker:sonoff/tele/sonoff_Heizung1/SENSOR:state:JSONPATH($.DS18x20.DS2.Temperature)]"}	

The sector “broker:sonoff/tele/sonoff_Heizung1/SENSOR” must match with the entries in the Sonoff MQTT parameters:

Topic = %topic% (sonoff)

sonoff_Heizung1

Full Topic (sonoff/%prefix%/%topic%/)

sonoff/%prefix%/%topic%/

I hope one of these information solve your problem.

I’m a newby too. I have the multiple sensors sending mqtt data to my raspberrypi with mosquito installed. I just couldn’t figure out the items part. Thank you so much for sharing your config. I will try replicating that on mine tonight after work. Thanks again.