Openhab vs. MQTT vs. Tasmota - Switching okay, unable to read extended data

Hi everyone,

I’m setting up a new OpenHab2 installation on an old mobile Computer, it’s a lot of faster then a RasPi3 :slight_smile:
I moved my configuration successful but with the new MQTT Binding I’m struggling a lot.

Here’s my configuration:

  • Platform information:
    • Hardware: Lenovo X1 Yoga Gen4, Core i5, 256GB SSD, 8GB RAM
    • OS: Debian 9 Stretch
    • Java Runtime Environment: openjdk version “1.8.0_222”, OpenJDK Runtime Environment (Zulu 8.40.0.25-CA-linux64) (build 1.8.0_222-b10), OpenJDK 64-Bit Server VM (Zulu 8.40.0.25-CA-linux64) (build 25.222-b10, mixed mode)
    • openHAB version: 2.4.0-1
  • Issue of the topic: I’m able to switch on/off SonOff Pow R2 with Tasmota firmware but not able to read extended data like Voltage, Uptime, etc.
  • Embedded MQTT-Broker because Mosquitto doesn’t work (409 Error)
  • Please post configurations (if applicable):
    • Items configuration related to the issue
  //SonoffPowR2-02
    Switch SZ_Multimedia "Multimedia" <cinema> { channel="mqtt:topic:SonoffPs02:switch" }
    Number SZ_Multimedia_Power "Multimedia Verbrauch Live [%.1f W]" <text> { channel="mqtt:topic:SonoffPs02:powerlive" }
    Number SZ_Multimedia_Power_Total "Multimedia Verbrauch Gesamt [%.1f kWh]" <text> { channel="mqtt:topic:SonoffPs02:powertotal" }
    Number SZ_Multimedia_Power_Today "Multimedia Verbrauch Heute [%.1f kWh]" <text> { channel="mqtt:topic:SonoffPs02:powertoday" }
    Number SZ_Multimedia_Uptime "Uptime [%s]" { channel="mqtt:topic:SonoffPs02:uptime" }
  • Sitemap configuration related to the issue
	Text label="Steckdosen" icon="poweroutlet" {
		Frame label="Steckdosen" {
			Switch item=IT_Steckdose_Code4_ON icon="poweroutlet" mappings=[ON=ON, OFF=OFF]
			Switch item=SZ_Multimedia icon="poweroutlet" mappings=[ON=ON, OFF=OFF]
			}
		Frame label="Verbräuche" {
			Text item=SZ_Multimedia_Power  icon="battery-100" {
		    Switch item=CHART_PERIOD label="Zeitspanne" mappings=[0="Stunde", 1="Tag", 2="Woche"]
		    Chart item=SZ_Multimedia_Power period=h refresh=300000 visibility=[CHART_PERIOD==0, CHART_PERIOD=="Uninitialized"]
		    Chart item=SZ_Multimedia_Power period=D refresh=1800000 visibility=[CHART_PERIOD==1]
		    Chart item=SZ_Multimedia_Power period=W refresh=3600000 visibility=[CHART_PERIOD==2]
			}
		Text item=SZ_Multimedia_Power_Total  icon="battery-100" {
		    Switch item=CHART_PERIOD label="Zeitspanne" mappings=[0="Stunde", 1="Tag", 2="Woche"]
	    	Chart item=SZ_Multimedia_Power_Total period=h refresh=300000 visibility=[CHART_PERIOD==0, CHART_PERIOD=="Uninitialized"]
	    	Chart item=SZ_Multimedia_Power_Total period=D refresh=1800000 visibility=[CHART_PERIOD==1]
		    Chart item=SZ_Multimedia_Power_Total period=W refresh=3600000 visibility=[CHART_PERIOD==2]
			}
		}
	}
  • Things File
Bridge mqtt:broker:MosquittoMqttBroker "Mosquitto MQTT Broker" @ "MQTT" [ 
  host="192.168.178.3",
  secure=false,
  port=1883,
  qos=0,
  retain=false,
  clientid="Oh2Mqtt2Thing",
  keep_alive_time=30000,
  reconnect_time=60000,
  username="openhabian",
  password="openhabian"
]
{
    // Sonoff Power Switch 02
    Thing mqtt:topic:SonoffPs02 "Sonoff Power Switch 02" @ "MQTT"  {
      Channels:
          Type switch : switch "Power Switch" [ 
            stateTopic="house/schlafzimmer/POWER", 
            commandTopic="house/schlafzimmer/cmnd/POWER",
            //retained=false,
            //postCommand="",
            //transformationPattern="JSONPATH:$.POWER", 
            //formatBeforePublish="%s",
            on="ON",
            off="OFF"          
 		  ]
          Type string : powerlive "Verbrauch Live" [ 
            stateTopic="house/schlafzimmer/SENSOR",
            transformationPattern="JSONPATH:$.ENERGY.Power"
          ]
		  Type string : powertotal "Verbrauch Total" [ 
            stateTopic="house/schlafzimmer/SENSOR",
            transformationPattern="JSONPATH:$.ENERGY.Total"
          ]
		  Type string : powertoday "Verbrauch Heute" [ 
            stateTopic="house/schlafzimmer/SENSOR",
            transformationPattern="JSONPATH:$.ENERGY.Today"
          ]
		  Type string : uptime "Uptime" [ 
            stateTopic="house/schlafzimmer/STATE",
            transformationPattern="JSONPATH:$.Uptime",
			formatBeforePublish="%s"
          ]
    }
 }
  • Rules code related to the issue
No Rules atm
  • Services configuration related to the issue
No Services

Switching the PowR2 is no problem, I can switch it on and off.
But I’m unable to read extended data.

The String from the PowR2 looks like this:

09:28:47 MQT: house/schlafzimmer/STATE = {"Time":"2019-08-11T09:28:47","Uptime":"1T15:46:03","Vcc":3.240,"SleepMode":"Dynamic","Sleep":50,"LoadAvg":19,"POWER":"OFF","Wifi":{"AP":1,"SSId":"WLAN-SCHAEFER","BSSId":"FC:EC:DA:1D:69:59","Channel":6,"RSSI":52,"LinkCount":2,"Downtime":"0T00:02:11"}}
09:28:47 MQT: house/schlafzimmer/SENSOR = {"Time":"2019-08-11T09:28:47","ENERGY":{"TotalStartTime":"2019-01-01T13:41:05","Total":49.757,"Yesterday":0.130,"Today":0.000,"Period":0,"Power":0,"ApparentPower":0,"ReactivePower":0,"Factor":0.00,"Voltage":0,"Current":0.000}}

I like to read the Data from Power, Total, Today and Uptime.

The Control Section in PaperUI shows only emtpy fields:
PowR2_2

The Transformation Plugin is installed correctly:

Before the new installation I used the old OH1 Binding which was working perfectly but in the new installation I would like to do it right with the new binding.

Is there anyone who have a clue for me?

Have a nice sunny sunday!

try channel type “number”…this works for me with pow r2:

Type number: powertotal "Verbrauch Total" [ 
            stateTopic="house/schlafzimmer/SENSOR",
            transformationPattern="JSONPATH:$.ENERGY.Total"
]

Thanks a lot, hopefully it’s that easy.
I’ll try it after I fix my MQTT, something is broken at the moment. Played to much in the last days :slight_smile:

It’s working! Thank you very much!
The only thing which isn’t shown is the update because I think “Number” is the wrong type. But I don’t need this value in my sitemap.