Blitzwolf SHP15 zigbee power socket - MQTT energy reading

This is a cheap Zigbee Tuya socket.
It advertizes

"ModelId":"TS011F","Manufacturer":"_TZ3000_u5u4cakc"

It can only control the switch and report the total energy consumption

I use a Sonoff ZB Bridge Pro as a coordinator with Zigbee2Tasmota.

So, i can read a status update every 5 min on the tasmota console

{"ZbReceived":{"SALN_TV [SHP-15]":{"Device":"0x6AAF","Name":"SALN_TV [SHP-15]","CurrentSummationDelivered":"0x000000000024","Endpoint":1,"LinkQuality":123}}}

So, the CurrentSummationDelivered is the only stat i can get, which is fine.
On documentation i see this is USINT48.

Right now i get this as a OH string item.

  - id: BW-SHP15-B_energy
    channelTypeUID: mqtt:string
    label: BW-SHP15-B Energy
    description: ""
    configuration:
      stateTopic: tele/ZigBee2Tasmota/SENSOR
      transformationPattern: REGEX:(.*\"BW-SHP15-B\"\,\"CurrentSummationDelivered\".*)∩JSONPATH:$.ZbReceived.BW-SHP15-B.CurrentSummationDelivered

Is there a better way to import this as integer, on the MQTT channel properties?
I think it can be done by profile use on the OH item?
usint48 is an unusuall data type and not sure how to handle. I try to avoid a proxy item, i think there is a better solution.

Seems nobody uses these power sockets :slight_smile:

Ok, i post my solution.

I am using a JS transformation for Thing → Item

(function(data) {
  if(data == "NULL" || data == "UNDEF") return data;
  return parseInt(data) / 100;   // Convert to kWh
})(input)

The reading for CurrentSummationDelivered i think its 10W units so i am converting the reading to kWh while i am converting from String (channel reading) to Item value.

I just set kWh as Item unit and it’s ok.

I hoped someone else was using these Blitzwolf sockets to give me confirmation.

So i only get the total (historical) reading for energy consuption, i will use this to get a daily consumption every midnight.

I will also get the Power reading from the socket but i have to manually poll every socket. I think this is because of latest firmware changes.
No big deal, i made a rule to kick every two minutes.

configuration: {}
triggers:
  - id: "1"
    configuration:
      cronExpression: 0 0/2 * * * ? *
    type: timer.GenericCronTrigger
conditions: []
actions:
  - inputs: {}
    id: "2"
    configuration:
      type: application/vnd.openhab.dsl.rule
      script: >2-
          val mqttActions = getActions("mqtt","mqtt:broker:MQTT1")
          mqttActions.publishMQTT("cmnd/ZigBee2Tasmota/ZbSend",'{"device":"BW-SHP15-A","read":{"activepower":true}}')
          mqttActions.publishMQTT("cmnd/ZigBee2Tasmota/ZbSend",'{"device":"BW-SHP15-B","read":{"activepower":true}}')
          mqttActions.publishMQTT("cmnd/ZigBee2Tasmota/ZbSend",'{"device":"BW-SHP15-C","read":{"activepower":true}}')
          mqttActions.publishMQTT("cmnd/ZigBee2Tasmota/ZbSend",'{"device":"BW-SHP15-D","read":{"activepower":true}}')
    type: script.ScriptAction

The forum is usually much more active during the week.

It is very unclear what you are all doing here.

The usual approach for something like this would be:

  1. use a number MQTT Channel type
  2. set the unit on the MQTT Channel to daWh (deca Watt hours) (see the Metric Prefixes table at Units Of Measurement | openHAB)
  3. set the unit of the Item to kWh and the state description pattern to %.0f %unit%

If you tell OH what the units are originally and what unit you want and how you want to show it, you don’t need a transformation to convert between units or anything like that. That’s the point of UoM.

As usual you have the best experience, i didn’t think of daWh (deca Watt hours).

My main question was if i could to the string to integer tranformation on the MQTT binding only, without the need for a JS transformation with just one line for the

parseInt(data);

As i said, i pull a string from MQTT. I guess it’s the only way to pull a uint48 number?

If you use a number Channel instead of a string Channel it will be parsed into a number automatically.

Choose ā€œnumber valueā€ when creating the Channel.

As long as the result of your transformationPattern returns the String of a parsable number, it will be parsed into a number for you. You don’t need to parse the Item itself in a transformation.

All transformations always return Strings all the time anyway. If the Channel is something other than a String, OH will parse it.

Oh, that was the first thing i did. Throws an error.

  - id: SHP15-test-energy
    channelTypeUID: mqtt:number
    label: SHP15-test-energy
    description: ""
    configuration:
      stateTopic: tele/ZigBee2Tasmota/SENSOR
      transformationPattern: REGEX:(.*\"BW-SHP15-B\"\,\"CurrentSummationDelivered\".*)∩JSONPATH:$.ZbReceived.BW-SHP15-B.CurrentSummationDelivered
      unit: daWh

[WARN ] [ab.binding.mqtt.generic.ChannelState] - Command ā€˜0x0000000000CF’ from channel ā€˜mqtt:topic:MQTT1:ZigBee2Tasmota:SHP15-test-energy’ not supported by type ā€˜NumberValue’: Character x is neither a decimal digit number, decimal point, nor ā€œeā€ notation exponential mark.

Ah, well that’s not a sectional number. It’s hex. You will need to use a transform to parse that. OH doesn’t handle hex automatically.

I also use this Smart Plug for a while an didn’t need to transform or trigger anything. But I’m using Zigbee2Mqtt and that does the polling and mqtt messaging for me. As units I get A for current, W for power and kwh for energy, so no calculation at all is needed.
Screenshot_20241103_094053_org.mozilla.firefox

Btw: There is a similar plug from Nous, that has a little smaller size. For that reason I prefer that now. It works similar in my environment.

1 Like