OpenHAB does not read Tasmota state?

  • Platform information:

    • Hardware: Orangepi 3 LTS
    • OS: Armbian with 5.15 kernel
    • Java Runtime Environment: which java platform is used and what version
    • openHAB version: 3.4
  • Issue of the topic: please be detailed explaining your issue
    My Tasmota device is a esp01 and it is reading a switch connected to GPIO2 and publishing the data at
    tele/Nibe1245/SENSOR

The sensor data looks like this:
{“Time”:“2023-01-22T22:12:56”,“Switch1”:“OFF”}

Openhab does not like this and churns out the following warning in its log:

2023-01-22 22:12:56.901 [WARN ] [ab.binding.mqtt.generic.ChannelState] - Command ‘{“Time”:“2023-01-22T22:12:56”,“Switch1”:“OFF”}’ from channel ‘mqtt:topic:8d0380cfbd:b7819349c3:Nibe1245PumpStatus’ not supported by type ‘OnOffValue’: No enum constant org.openhab.core.library.types.OnOffType.{“Time”:“2023-01-22T22:12:56”,“Switch1”:“OFF”}

This is my configuration:
UID: mqtt:topic:8d0380cfbd:b7819349c3
label: Nibe 1245 Status
thingTypeUID: mqtt:topic
configuration:
payloadNotAvailable: Offline
availabilityTopic: tele/Nibe1245/LWT
payloadAvailable: Online
bridgeUID: mqtt:broker:8d0380cfbd
location: BoilerRoom
channels:

  • id: Nibe1245PumpStatus
    channelTypeUID: mqtt:switch
    label: Sensor data
    description: “”
    configuration:
    stateTopic: tele/Nibe1245/SENSOR
    off: ‘“Switch1”: “ON”’
    on: ‘“Switch1”: “OFF”’

The same tasmota device is also controlling a relay that works as expected.

This will not work - Tasmota is publishing a JSON string, so you first need to configure the Channel to extract the section of the JSON string you’re interested in using the JSONPATH Transformation Service, in the Channel’s transformationPattern parameter.

1 Like

Thanks for the tip
After reading the Openhab JSONPath transformation description and examples, in:

I have tried
$.device.Switch1
$.device.Nibe1245.Switch1
$.Nibe1245.Switch1

None of these seem to work
Apparently I have not fully understood how JSONPath transformation works? Any hints on how to propery configure this would be greatly appreciated.

JSONPath online says $.Switch1 should do the trick:

Unfortunately that, too, fails.

Hi.
You’vego wrong configuration.
Try something like this:

label: Sonoff Dori Lampka
thingTypeUID: mqtt:topic
configuration:
  payloadNotAvailable: Offline
  availabilityTopic: tele/tasmota_lampka_Dori/LWT
  payloadAvailable: Online
bridgeUID: mqtt:broker:8862487c38
channels:
  - id: Sonoff_Lampka_Dori_LWT
    channelTypeUID: mqtt:string
    label: Lampka u Dorotki Sonoff LWT
    description: null
    configuration:
      postCommand: false
      retained: true
      formatBeforePublish: "%s"
      stateTopic: tele/tasmota_lampka_Dori/LWT
  - id: Sonoff_Lampka_Dori_IP
    channelTypeUID: mqtt:string
    label: Sonoff Lampka u Dorotki IP
    description: null
    configuration:
      postCommand: false
      retained: false
      formatBeforePublish: "%s"
      stateTopic: tele/tasmota_lampka_Dori/INFO2
      transformationPattern: JSONPATH:$.IPAddress
  - id: Sonoff_Lampka_Dori_Power1
    channelTypeUID: mqtt:switch
    label: Lampka u Dorotki
    description: null
    configuration:
      postCommand: false
      retained: false
      formatBeforePublish: "%s"
      commandTopic: cmnd/tasmota_lampka_Dori/POWER
      stateTopic: stat/tasmota_lampka_Dori/RESULT
      transformationPattern: JSONPATH:$.POWER
      off: OFF
      on: ON

your code goes here
1 Like

Maybe this will help you undersand “tasmota”.

1 Like

You’re doing two different things here.

In your first post, you showed your Thing Channel configuration, and an attempt at parsing the JSON there.

In your subsequent post you show your Link Profile configuration, and an attempt at parsing the JSON there.

The Link Profile will work on data sent from the Thing Channel, so if you didn’t change that compared to the first post then it definitely won’t work, whatever you put in it.

Here’s what to do:

  • Remove the Link Profile entirely. Get rid of it.
  • Change your Thing Channel to look like below
UID: mqtt:topic:8d0380cfbd:b7819349c3
label: Nibe 1245 Status
thingTypeUID: mqtt:topic
configuration: {}
payloadNotAvailable: Offline
availabilityTopic: tele/Nibe1245/LWT
payloadAvailable: Online
bridgeUID: mqtt:broker:8d0380cfbd
location: BoilerRoom
channels:
  - id: Nibe1245PumpStatus
    channelTypeUID: mqtt:switch
    label: Sensor data
    description: null
    configuration:
      stateTopic: tele/Nibe1245/SENSOR
      transformationPattern: JSONPATH:$.Switch1
      off: ON
      on: OFF

Thanks for the help! I really appreciate this as this is a rather steep uphill for me.
I made the changes. Will let the system run over night and report.

Progress: I do now get readings from the switch.

I use a tasmotized esp01 and its RXD pin as input. It is connected to a relay output of my Nibe 1245 ground source heat pump. The relay output pulls when the pump starts and opens when the pump stops. I would like monitor this in influxdb. The esp01 RXD pin input was a bit unstable, so I put a 5kOhm pullup resistor to +5V to it. It improved the situation.

I now stumbled upon the problem that I can not invert the status reading in OpenHAB whatever I do. I would like OH to read ON when the the relay closes and OFF when it is open. I have not found the right configuration to do so. OFF, “OFF”, 0, all result in the same.

Could you post your tasmota console output when the switch was swiched, but not only one line and use code fences.

How to use code fences.

Here we go. Not only one line, right?

19:45:35.452 MQT: tele/Nibe1245/SENSOR = {"Time":"2023-01-25T19:45:35","Switch1":"ON"}
19:50:00.731 MQT: stat/Nibe1245/RESULT = {"POWER":"OFF"}
19:50:00.734 MQT: stat/Nibe1245/POWER = OFF
19:50:35.447 MQT: tele/Nibe1245/STATE = {"Time":"2023-01-25T19:50:35","Uptime":"0T11:35:11","UptimeSec":41711,"Heap":26,"SleepMode":"Dynamic","Sleep":50,"LoadAvg":19,"MqttCount":1,"POWER":"OFF","Wifi":{"AP":1,"SSId":"TP-Link_AFD4","BSSId":"54:AF:97:1B:AF:D4","Channel":11,"Mode":"11n","RSSI":94,"Signal":-53,"LinkCount":1,"Downtime":"0T00:00:03"}}
19:50:35.455 MQT: tele/Nibe1245/SENSOR = {"Time":"2023-01-25T19:50:35","Switch1":"ON"}
19:55:35.416 MQT: tele/Nibe1245/STATE = {"Time":"2023-01-25T19:55:35","Uptime":"0T11:40:11","UptimeSec":42011,"Heap":24,"SleepMode":"Dynamic","Sleep":50,"LoadAvg":19,"MqttCount":1,"POWER":"OFF","Wifi":{"AP":1,"SSId":"TP-Link_AFD4","BSSId":"54:AF:97:1B:AF:D4","Channel":11,"Mode":"11n","RSSI":92,"Signal":-54,"LinkCount":1,"Downtime":"0T00:00:03"}}
19:55:35.423 MQT: tele/Nibe1245/SENSOR = {"Time":"2023-01-25T19:55:35","Switch1":"ON"}
19:56:37.173 MQT: stat/Nibe1245/RESULT = {"POWER":"ON"}
19:56:37.176 MQT: stat/Nibe1245/POWER = ON
20:00:00.772 MQT: stat/Nibe1245/RESULT = {"POWER":"OFF"}
20:00:00.775 MQT: stat/Nibe1245/POWER = OFF
20:00:35.406 MQT: tele/Nibe1245/STATE = {"Time":"2023-01-25T20:00:35","Uptime":"0T11:45:11","UptimeSec":42311,"Heap":25,"SleepMode":"Dynamic","Sleep":50,"LoadAvg":19,"MqttCount":1,"POWER":"OFF","Wifi":{"AP":1,"SSId":"TP-Link_AFD4","BSSId":"54:AF:97:1B:AF:D4","Channel":11,"Mode":"11n","RSSI":94,"Signal":-53,"LinkCount":1,"Downtime":"0T00:00:03"}}
20:00:35.413 MQT: tele/Nibe1245/SENSOR = {"Time":"2023-01-25T20:00:35","Switch1":"OFF"}
20:05:35.446 MQT: tele/Nibe1245/STATE = {"Time":"2023-01-25T20:05:35","Uptime":"0T11:50:11","UptimeSec":42611,"Heap":26,"SleepMode":"Dynamic","Sleep":50,"LoadAvg":19,"MqttCount":1,"POWER":"OFF","Wifi":{"AP":1,"SSId":"TP-Link_AFD4","BSSId":"54:AF:97:1B:AF:D4","Channel":11,"Mode":"11n","RSSI":84,"Signal":-58,"LinkCount":1,"Downtime":"0T00:00:03"}}
20:05:35.453 MQT: tele/Nibe1245/SENSOR = {"Time":"2023-01-25T20:05:35","Switch1":"OFF"}
20:10:00.686 MQT: stat/Nibe1245/RESULT = {"POWER":"OFF"}
20:10:00.689 MQT: stat/Nibe1245/POWER = OFF
20:10:35.427 MQT: tele/Nibe1245/STATE = {"Time":"2023-01-25T20:10:35","Uptime":"0T11:55:11","UptimeSec":42911,"Heap":26,"SleepMode":"Dynamic","Sleep":50,"LoadAvg":19,"MqttCount":1,"POWER":"OFF","Wifi":{"AP":1,"SSId":"TP-Link_AFD4","BSSId":"54:AF:97:1B:AF:D4","Channel":11,"Mode":"11n","RSSI":86,"Signal":-57,"LinkCount":1,"Downtime":"0T00:00:03"}}
20:10:35.433 MQT: tele/Nibe1245/SENSOR = {"Time":"2023-01-25T20:10:35","Switch1":"OFF"}
20:15:35.414 MQT: tele/Nibe1245/STATE = {"Time":"2023-01-25T20:15:35","Uptime":"0T12:00:11","UptimeSec":43211,"Heap":26,"SleepMode":"Dynamic","Sleep":50,"LoadAvg":19,"MqttCount":1,"POWER":"OFF","Wifi":{"AP":1,"SSId":"TP-Link_AFD4","BSSId":"54:AF:97:1B:AF:D4","Channel":11,"Mode":"11n","RSSI":86,"Signal":-57,"LinkCount":1,"Downtime":"0T00:00:03"}}
20:15:35.421 MQT: tele/Nibe1245/SENSOR = {"Time":"2023-01-25T20:15:35","Switch1":"OFF"}
20:18:16.650 MQT: stat/Nibe1245/RESULT = {"POWER":"ON"}
20:18:16.655 MQT: stat/Nibe1245/POWER = ON
20:20:00.625 MQT: stat/Nibe1245/RESULT = {"POWER":"OFF"}
20:20:00.628 MQT: stat/Nibe1245/POWER = OFF
20:20:35.404 MQT: tele/Nibe1245/STATE = {"Time":"2023-01-25T20:20:35","Uptime":"0T12:05:11","UptimeSec":43511,"Heap":26,"SleepMode":"Dynamic","Sleep":50,"LoadAvg":19,"MqttCount":1,"POWER":"OFF","Wifi":{"AP":1,"SSId":"TP-Link_AFD4","BSSId":"54:AF:97:1B:AF:D4","Channel":11,"Mode":"11n","RSSI":84,"Signal":-58,"LinkCount":1,"Downtime":"0T00:00:03"}}
20:20:35.412 MQT: tele/Nibe1245/SENSOR = {"Time":"2023-01-25T20:20:35","Switch1":"ON"}

I hope I used the right code fences?

To achive this you can use a MAP Transformation on your channel

ON=OFF
OFF=ON

or you invert your switch directly in tasmota with the command

Switchmode 2
1 Like

Inverting the Tasmota output with issuing “switchmode 2” at the Tasmota console solved the state problem. In addition I set the MQTT qos to 2, which made the relay control stable. System seems working fine now.
Thank you.