[SOLVED] JSON mqtt

hi,

can anyone help me to get the value in a string an show that string on basicUI?

i read this values from my tuya thermostat with mqtt:
{“1”:true,“2”:125,“3”:265,“4”:“Manual”,“6”:false,“12”:0,“101”:false,“102”:false,“103”:0,“104”:1,“105”:15,“106”:true,“107”:true,“108”:true,“109”:-10,“110”:10,“111”:2,“112”:45,“113”:5,“114”:35,“115”:5,“116”:“in”,“117”:“keep”,“118”:“2days”}

how can i get the value from No.3 to string?

i tried this but it will not work:

String temp_og “Temperature:” [JSONPATH($.‘3’):%.1f °C]" {“mqtt:topic:8c44b7c4:temp”}

i hope anyone can help me :frowning_face:

Where do you read that value?

Do you have thing mqtt defined?

You can try that way.

mqtt.things

Bridge mqtt:broker:8c44b7c4 "MQTT Broker" [ host="xxx.xxx.xxx.xxx", port=1883, secure=false, username="xxx", password="xxx", clientID="xxx-1" ]
{
    Thing topic tuya_thermostat "Thermostat 1" @ "House" {
        Channels:
            Type number : temp "Temp" [ stateTopic="/topic", transformationPattern="JSONPATH:$.3" ]
    }
}

tuya.items

Number temp_og "Temperature: [%.1f °C]" { channel="mqtt:topic:8c44b7c4:tuya_thermostat:temp"}
1 Like

I Read This values with mqtt-explorer… and tuya-cli… but also with your example i won’t get the value on basic-ui

here is my code of items:

String temp_og "Temperature: [%.1f °C]" { channel="mqtt:topic:8551887f:FlurTemp"}

in sitemap:

Text item=temp_og

Thing in Paper-UI:

I hope you or anyone can help me to get the values from dps to sitemap :frowning:

Thank you for answering me

Okay need a channel called FlurTemp

That one’s called temp. The broker name is different too.

like this:

Bridge mqtt:broker:8551887f "MQTT Broker2" [ host="127.0.0.1", port=1883, secure=false, username="", password="", clientID="" ]
{
    Thing topic tuya_thermostat "Thermostat 1" @ "House" {
        Channels:
            Type number : temp "Temp" [ stateTopic="/topic", transformationPattern="JSONPATH:$.3" ]
    }
}

Number temp_og "Temperature: [%.1f °C]" { channel="mqtt:topic:8551887f:tuya_thermostat:temp"}

I tried but on basic-ui only appears “-” :frowning:

what I’m doing wrong?

I’ve found the fault :slight_smile: i’ve forgotten to install the transformation :slight_smile:

Thank you for your help an greets from germany

Sorry for my bad English

hello,

my sonoff TH16 gives me this:
Subscribed to: tele/sonoff_th16/SENSOR
{"Time":"2019-11-24T15:53:04","SI7021":{"Temperature":21.0,"Humidity":39.5},"TempUnit":"C"}

i want to read the Temperature and Humidity. How should the code look like ?

this is my test .thing ( Power and State are already working )

Thing mqtt:topic:sonoff_th16 "MQTT Thing: Sonoff TH16" (mqtt:broker:riot) @ "MQTT-Things"
{
  Channels:
    Type switch : power "Power Switch" [ 
        stateTopic="stat/sonoff_th16/POWER", 
        commandTopic="cmnd/sonoff_th16/POWER",
        on="ON",
        off="OFF"          
    ]
    Type string : state "Power State" [ 
        stateTopic="stat/sonoff_th16/POWER",
        on="ON",
        off="OFF"
    ]
    Type number : temperature "Temperature" [ 
        stateTopic="tele/sonoff_th16/SENSOR",
        transformationPattern="JSONPATH:$.Temperature"
    ]
}

thank you

EDIT: Ok i got it, sorry :grimacing:

Type number : temperature "Temperature" [ 
            stateTopic="tele/sonoff_th16/SENSOR",
            transformationPattern="JSONPATH:$.SI7021.Temperature"
        ]