[SOLVED] [MQTT 2.4] tasmota switch stop working after adding channel for temperature sensor

Hello. I’m trying to set up my sonoff switch with tasmota firmware.
I’m using Sonoff basic switch with temperature sensor AM2302.
It works well when i’m using any mqtt client.

Now i’m trying to make it work with openhab.
I’ve installed mqtt 2.4 binding.

Things file:

Bridge mqtt:broker:mosquitto [ host="localhost", secure=false ]
{
    Thing topic SonoffBathroom "Sonoff Bathroom" {
    Channels:
        Type switch : fan "Bathroom fan" [ stateTopic="stat/sonoff_bathroom/POWER", commandTopic="cmnd/sonoff_bathroom/POWER", on="ON", off="OFF"]
    }
}

My items file:

Switch Bathroom_Fan "Bathroom fan" { channel="mqtt:topic:mosquitto:SonoffBathroom:fan" }

The above config works well,
but if i’m trying to add a new channel which will provide temperature/humidity status povided by the sonoff like this:

Bridge mqtt:broker:mosquitto [ host="localhost", secure=false ]
{
    Thing topic SonoffBathroom "Sonoff Bathroom" {
    Channels:
        Type switch : fan "Bathroom fan" [ stateTopic="stat/sonoff_bathroom/POWER", commandTopic="cmnd/sonoff_bathroom/POWER", on="ON", off="OFF"]
        Type string : sensor "Temperature and Humidity" [ stateTopic="tele/sonoff_bathroom/SENSOR" ]
    }
}

Switch immediately stop working through OH and it does not show any status update in the log for the switch. No any warning/error message in the log. I can only make it work when I remove temp&humidity channel AND after I restart OH.

Hi,
I had the same problem, you must add the JSON Path like
JSONPATH:$.AM2301.Humidity
for the Sensor Sorry but i can´t tell you how to add the Path because I´m using the Paper Ui to add my items.

Show her, to add the JSON Path

Sonoff Tasmota with MQTT Binding 2.4 (using config files)

Thank you, @RonnyB, your suggestion is correct:
I’ve modified my things file:

Bridge mqtt:broker:mosquitto [ host="localhost", secure=false ]
{
    Thing topic SonoffBathroom "Sonoff Bathroom" {
    Channels:
        Type switch : fan "Bathroom fan" [stateTopic="stat/sonoff_bathroom/POWER", commandTopic="cmnd/sonoff_bathroom/POWER", on="ON", off="OFF"]
        Type number : temperature "Temperature" [stateTopic="tele/sonoff_bathroom/SENSOR", transformationPattern="JSONPATH:$.AM2301.Temperature"]
        Type number : humidity "Temperature" [stateTopic="tele/sonoff_bathroom/SENSOR", transformationPattern="JSONPATH:$.AM2301.Humidity"]
    }
}

and my items file:

Switch Bathroom_Fan "Bathroom fan" { channel="mqtt:topic:mosquitto:SonoffBathroom:fan" }
Number Bathroom_Temperature "Temperature" { channel="mqtt:topic:mosquitto:SonoffBathroom:temperature" }
Number Bathroom_Humidity "Humidity" { channel="mqtt:topic:mosquitto:SonoffBathroom:humidity" }

And now switch still works and i can get my temperature and humidity from the sonoff!