OH3 Tasmota MQTT current energy

I have a Powerplug with Tasmota. In MQTT.fx it sends Power ON OFF and the SENSOR like this

{"Time":"2021-01-22T20:26:48","ENERGY":{"TotalStartTime":"2020-06-22T12:31:48","Total":2.514,"Yesterday":0.000,"Today":0.170,"Period":4,"Power":54,"ApparentPower":211,"ReactivePower":204,"Factor":0.26,"Voltage":227,"Current":0.929}}

Integrated in OH3 only the ON / OFF switch is working via Generic MQTT Device, but when I want to measure Sensor stats like the Current Power Use it shows only NULL

I opened a Channel at this Thing as Number with JSONPATH:$.ENERGY.Current it´s not working.

What I´m doing wrong?

As per example provided below JSONPath Expression try to use:
$.ENERGY.Current
instead of JSONPATH.$.ENERGY.Current

To be honest I am guessing. All my MQTT items things are created by code. And I don’t have multilevel JSON’s :slight_smile:

Helpful JSONPath Online Evaluator https://jsonpath.com/

Try this
! use your topic !

   // things
            //Sensor ENERGY
        Bridge mqtt:broker:mqtt-broker [ host="192.168.1.xx", secure=false,  clientID="OpenHABv3" ] {

        Thing topic tasmota-powr2 "Tasmota POW R2" @ "Piwnica" {

                Channels:
                    Type string : totalstarttime    "TotalStartTime"        [ stateTopic="tele/tasmota-powr2/SENSOR", transformationPattern="JSONPATH:$.ENERGY.TotalStartTime"]

                    Type number : total             "Total"                 [ stateTopic="tele/tasmota-powr2/SENSOR", transformationPattern="JSONPATH:$.ENERGY.Total"]

                    Type number : yesterday         "Yesterday"             [ stateTopic="tele/tasmota-powr2/SENSOR", transformationPattern="JSONPATH:$.ENERGY.Yesterday"]

                    Type number : today             "Today"                 [ stateTopic="tele/tasmota-powr2/SENSOR", transformationPattern="JSONPATH:$.ENERGY.Today"]

                    Type number : period            "Period"                [ stateTopic="tele/tasmota-powr2/SENSOR", transformationPattern="JSONPATH:$.ENERGY.Period"]

                    Type number : energypower       "Power"                 [ stateTopic="tele/tasmota-powr2/SENSOR", transformationPattern="JSONPATH:$.ENERGY.Power"]

                    Type number : apparentpower     "ApparentPower"         [ stateTopic="tele/tasmota-powr2/SENSOR", transformationPattern="JSONPATH:$.ENERGY.ApparentPower"]

                    Type number : reactivepower     "ReactivePower"         [ stateTopic="tele/tasmota-powr2/SENSOR", transformationPattern="JSONPATH:$.ENERGY.ReactivePower"]

                    Type number : factor            "Factor"                [ stateTopic="tele/tasmota-powr2/SENSOR", transformationPattern="JSONPATH:$.ENERGY.Factor"]

                    Type number : voltage           "Voltage"               [ stateTopic="tele/tasmota-powr2/SENSOR", transformationPattern="JSONPATH:$.ENERGY.Voltage"]

                    Type number : current           "Current"               [ stateTopic="tele/tasmota-powr2/SENSOR", transformationPattern="JSONPATH:$.ENERGY.Current"]

items
//Sensor ENERGY

String powr2_totalstarttime  "TotalStartTime:  [%s]"              <time>               (gPowR2)             { channel="mqtt:topic:mqtt-broker:tasmota-powr2:totalstarttime" }

Number powr2_total           "Energy Total: [%.3f kWh]"           <my_kwh>             (gPowR2)             { channel="mqtt:topic:mqtt-broker:tasmota-powr2:total" }

Number powr2_yesterday       "Energy Yesterday: [%.3f kWh]"       <my_kwh>             (gPowR2)             { channel="mqtt:topic:mqtt-broker:tasmota-powr2:yesterday" }

Number powr2_today           "Energy Today: [%.3f kWh]"           <my_kwh>             (gPowR2)             { channel="mqtt:topic:mqtt-broker:tasmota-powr2:today" }

Number powr2_period          "Period"                             <text>               (gPowR2)             { channel="mqtt:topic:mqtt-broker:tasmota-powr2:period" }

Number powr2_energypower     "Power: [%d W]"                      <my_watt>            (gPowR2)             { channel="mqtt:topic:mqtt-broker:tasmota-powr2:energypower" }

Number powr2_apparentpower   "ApparentPower: [%d VA]"             <text>               (gPowR2)             { channel="mqtt:topic:mqtt-broker:tasmota-powr2:apparentpower" }

Number powr2_reactivepower   "ReactivePower: [%d VAr]"            <text>               (gPowR2)             { channel="mqtt:topic:mqtt-broker:tasmota-powr2:reactivepower" }

Number powr2_factor          "Factor: [%.2f]"                     <text>               (gPowR2)             { channel="mqtt:topic:mqtt-broker:tasmota-powr2:factor" }

Number powr2_voltage         "Voltage: [%d V]"                    <energy>             (gPowR2)             { channel="mqtt:topic:mqtt-broker:tasmota-powr2:voltage" }

Number powr2_current         "Current: [%.3f A]"                  <my_amper>           (gPowR2)             { channel="mqtt:topic:mqtt-broker:tasmota-powr2:current" }

Thank you, but I don´t know where to put at OH3 :frowning:

Thank you 4 your Link, but I think JSONPATH. have to be in front

Did you try it? Because you selected JSONPATH above the expression field, it looks like you don’t need it in the expression field itself. See the example underneath the expression field.

Yes, sure I tried it first - thank you :grinning:

Try to do it manually:


go to the newly greated Thing and add below code

UID: mqtt:topic:Waschmachine:Waschmachine1
label: Waschmachine
thingTypeUID: mqtt:topic
configuration: {}
bridgeUID: mqtt:broker:Waschmachine
location: 
channels:
  - id: Cyrrent
    channelTypeUID: mqtt:number
    label: Current
    description: null
    configuration:
      stateTopic: HERE_YOU_NEED_TO_PUT_MQTT_TOPIC
      transformationPattern: JSONPATH:$.ENERGY.Current


Be carefull with stateTopic.

In next step create the link for this new channel.

:crossed_fingers:

Hi !

I have a Sonoff POW Elite (16A Version) and i have a problem importing the MQTT …
in the telegram with SENSOR the value are not updated or in a real long timeframe…
in STATUS10 i get always the real values. but JSON looks diffrent (StatusSNS before)
I tried to change in my setup but w/o success

Ciao Gerd

I think you can change the interval with the parameter TelePeriod in the tasmota console.

Hi !

You can only set it down to 10 seconds (same as STATUS10) but it would be fine if it transfers only on change… i guess this would be the best…

Ciao Gerd

You can use Tasmota Rules to publish on sensor change.

See also here

Ok… my last problem is to activae the switch … i set it up like i read here but no reaction… direct on mqtt its working.
thing

Thing mqtt:topic:home:output “Tasmota POW Elite BKW”
(mqtt:broker:home) @ “Intel NUC5 i3”
{
Channels:
Type switch : bkw_onoff “BKW on off” [ stateTopic=“bkw/output/POWER”, commandTopic=“bkw/output/cmnd/POWER”, on=“ON”, off=“OFF”]
}

item

Switch bkw_on_off “BKW on off” { channel=“mqtt:topic:home:output:bkw_onoff” }

What command did you send to which topic to test the activation ‘direct on mqtt’?

yes diret to mosquitto via mqtt explorer… this worked… via openhab not…

Ciao gerd