Sonoff TH16 is not sending Temp to openhab

mqttsonoff
Tags: #<Tag:0x00007fe057158d28>

(Ben) #1

Hello,
I have successfully flashed and connected a Sonoff TH16 into my openhab2 system 2 weeks ago. I set my Pi up at the same time, so the software should be uptodate.

I’m able to toogle the Switch via openhab but if I want to publish the Temperature I will just receive a NULL °C, see below:
grafik

I’m able to see the current Temperature via putty or mqqt FX but not via openhab:
See example:
[19:29:38] openhabian@openHABianPi:~$ mosquitto_sub -h localhost -t “+/Sonoff_Temp_1/#” -v
tele/Sonoff_Temp_1/LWT Online
tele/Sonoff_Temp_1/STATE {“Time”:“2018-10-20T18:32:30”,“Uptime”:“0T21:01:24”,“Vcc”:3.496,“POWER”:“ON”,“Wifi”:{“AP”:1,“SSId”:“UPC7927287”,“BSSId”:“38:43:7D:67:C5:DC”,“Channel”:1,“RSSI”:100}}
tele/Sonoff_Temp_1/SENSOR {“Time”:“2018-10-20T18:32:30”,“DS18B20”:{“Temperature”:21.1},“TempUnit”:“C”}

Here is the code how configuted the item (Sonoff TH16):
Switch Sonoff_Temp_1 “Sonoff-Temp” (LR,gLight) { mqtt=">[openmqtt:cmnd/Sonoff_Temp_1/POWER:command:*:default], <[openmqtt:stat/Sonoff_Temp_1/POWER:state:default]" }

Number Sonoff_Temp_Test “Temperature Sonoff [%s %%]” {mqtt="<[openmqtt:tele/Sonoff_Temp_1/SENSOR:State:JSONPATH($.DS18x20.DS1.Temperature)]"}

Has anybody had a similar issue? I’m alreday searching for the answer since I set the system up 2 weeks ago… If some informations are missing, just let me know.
I would appreciate some hint :slight_smile:


(Vincent Regaud) #2

state not State
And your JSONPATH is incorrect
I also added the Number:Temperature so you can make use of the UoM
and changed the formatting of the label

Number:Temperature Sonoff_Temp_Test “Temperature Sonoff [%.1f °C]” {mqtt="<[openmqtt:tele/Sonoff_Temp_1/SENSOR:state:JSONPATH($.DS18B20.Temperature)]"}

(Ben) #3

Thanks for the feedback.
unfortunattely after incering you code I’m unable to connetc the sonoff at all:
[21:26:56] openhabian@openHABianPi:~$ mosquitto_sub -h control_central -t stat/Sonoff_Temp_1/STATUS -v
Unable to connect (Lookup error.).

After deleting the line and restation OH2 it workes the used way again.
I Implemented your changes to my existing line but I’m still unable to publish the Temperature in OH2

Any other idea


(Vincent Regaud) #4

That has nothing to do with my code. The binding only subscribes to the mqtt broker so has no effect on it.
There was some “smart quotes”: “” and it should be:"" in the item

This is because you are not using the How to use code fences

Your item should be:

Number:Temperature Sonoff_Temp_Test "Temperature Sonoff [%.1f °C]" { mqtt="<[openmqtt:tele/Sonoff_Temp_1/SENSOR:state:JSONPATH($.DS18B20.Temperature)]" }

(Ben) #5

you are awesome now it workes

I just created a new Sonoff_1 item

[22:18:45] openhabian@openHABianPi:~$ sudo nano /etc/openhab2/items/sonoff_1.items
Number Sonoff_Temp_Test3 "Temperature Sonoff3 [%s %%]"  {mqtt="<[openmqtt:tele/Sonoff_Temp_1/SENSOR:state:JSONPATH($.DS18B20.Temperature)]"}

I just left the Number:Temperature

and thank you for the feedback on how to use the code fences


(Vincent Regaud) #6

Please mark the thread as solved, thanks.