MQTT Sonoff Sensor not reading Temp/Humidty but Power works

Hi All

Using 3.4 and having issues reading temp/humidty

My sonoff sensor is configured as so:

My MQTT Thing has:

And the Channel has this value, which is very old/wrong (Actual sonof shows humidity 51% for example)

May someone point me in the right direction?

Thanks!

You have two times the same screenshot but missing the thing definition.

Can you share your thing definition(copy and paste from the code tab instead of doing a screenshot)?

Also if I would be you: I would connect to mqtt with a3rd party tool, e.g. mqtt explorer, to validate topic name and what’s really send from sonoff to mqtt, so that you know if the issue is with sonoff or OH

Sorry! apologies

UID: mqtt:topic:59b16930c3
label: Subfloor Ventilation
thingTypeUID: mqtt:topic
configuration:
  payloadNotAvailable: Offline
  availabilityTopic: tele/subfloortemp/LWT
  payloadAvailable: Online
bridgeUID: mqtt:broker:MQTT_Broker
location: Subfloor
channels:
  - id: Subfloor_Fan_Power
    channelTypeUID: mqtt:switch
    label: Subfloor Fan Power
    description: ""
    configuration:
      commandTopic: cmnd/subfloortemp/POWER
      stateTopic: stat/subfloortemp/POWER
  - id: Subfloor_Temperature
    channelTypeUID: mqtt:number
    label: Subfloor Temperature
    description: ""
    configuration:
      stateTopic: tele/subfloortemp/SENSOR
      transformationPattern: JSONPATH:$.AM2301.Temperature
      unit: °C
  - id: Subfloor_Humidity
    channelTypeUID: mqtt:number
    label: Subfloor Humidity
    description: ""
    configuration:
      stateTopic: tele/subfloortemp/SENSOR
      transformationPattern: JSONPATH:$.AM2301.Humidity
      unit: "%"

The power topic (working as per your headline) has

stat/subfloortemp/POWER

as a topic, but humidity and temp have a different topic.
I’m not familiar with sonoff but I would try e.g.

stat/subfloortemp/HUMIDITY

as a topic.

Without knowing what data is really published from your device to mqtt, it’s hard to help. Therefore still recommending to verify published mqtt messages with another tool before configuring your thing

Thanks and sorry updating the topic name is under the item?

It’s within the thing configuration you have posted before. Have a look at the “stateTopic” records

But that’s just a guess, as all state topics normally have the same pattern.
Without knowing what’s really send by your device, it’s hard to help

Under logging on the device do you have a value for the Telemetry period because if it doesn’t send anything you won’t see any values.

Yes, 300. And the state topics are correct I believe.

I have a TH16 but my json path is:
JSONPATH:$.SI7021.Humidity

What does you tele topic look like?

MQTT Explorer has this:

So i think the topic is the same for Temp, Humidity right?

What does the tele topic look like on the device console?

23:14:13 LOG: SerialLog 2, WebLog 2, SysLog 0, LogHost domus1, LogPort 514, TelePeriod 300
23:14:33 LOG: SerialLog 2, WebLog 2, SysLog 0, LogHost domus1, LogPort 514, TelePeriod 60
23:14:33 MQT: tele/subfloortemp/STATE = {"Time":"2023-10-14T23:14:33","Uptime":"0T00:15:04","Vcc":3.171,"SleepMode":"Dynamic","Sleep":50,"LoadAvg":19,"POWER":"OFF","Wifi":{"AP":1,"SSId":"Tard","BSSId":"FC:EC:DA:11:AC:9A","Channel":1,"RSSI":100,"LinkCount":1,"Downtime":"0T00:00:03"}}
23:14:33 MQT: tele/subfloortemp/SENSOR = {"Time":"2023-10-14T23:14:33","AM2301":{"Temperature":18.7,"Humidity":56.0},"TempUnit":"C"}

Mine looks similar:

09:30:30 MQT: tele/sonoffth16/SENSOR = {"Time":"2023-10-15T09:30:30","SI7021":{"Temperature":16.9,"Humidity":52.5},"TempUnit":"C"}

Here is my setup so you can compare.

UID: mqtt:topic:8e609206
label: Sonoff TH16
thingTypeUID: mqtt:topic
configuration:
  payloadNotAvailable: Offline
  availabilityTopic: tele/sonoffth16/LWT
  payloadAvailable: Online
bridgeUID: mqtt:broker:mqttbroker
channels:
  - id: sonoffth16
    channelTypeUID: mqtt:switch
    label: Sonoff TH16
    description: null
    configuration:
      commandTopic: cmnd/sonoffth16/POWER
      stateTopic: stat/sonoffth16/POWER
      off: OFF
      on: ON
  - id: th16humidity
    channelTypeUID: mqtt:number
    label: Sonoff TH16 humidity
    description: null
    configuration:
      stateTopic: tele/sonoffth16/SENSOR
      transformationPattern: JSONPATH:$.SI7021.Humidity
  - id: sonoffth16temperature
    channelTypeUID: mqtt:number
    label: Sonoff TH16 temperature
    description: null
    configuration:
      stateTopic: tele/sonoffth16/SENSOR
      transformationPattern: JSONPATH:$.SI7021.Temperature
      unit: °C

Mine is working.

Yep its the same, I just recreated the MQTT thing, same issue. The sensor is working because the values on the sonoff console are correct

Ive got another in my ceiling that has the same configuration, it too works

This must be a Openhab bug

If it was a bug then no MQTT would work and your other devices wouldn’t work either.
Maybe remove the % in the unit measurement for humidity

The only difference I have is I don’t bother with password for my mqtt. But if that were the case the power switch would not work either.

Other than that is looks like it “should” work.

Are there any message in OH log?
Is your item constantly showing the same wrong value → not updating at all OR randomly showing different values, but updating?

Your humidity item is number:temperature - as humidity is % and not °C I would choose number: dimensionless as type.

1 Like

My items are just numbers and they work:

Edit: plain ol number seems to have fixed it! Thankyou!