Replacing "zigbee switch" driver with small changes for a frient smart plug with power consumption, help needed

Hey everyone, in the nightmarish (and desperate) course of wanting to make a device work with smartthings, I want to alter the standard zigbee switch driver that it apparantly runs on.
This should be open source right? Can anyone link me to it?
And then I’d need to know how to alter that code and integrate it into smartthings. (The code i can edit myself using a text editor i suppose, but how to get it back into smartthings is the problem)

The device reports watts as minus, and prevents me from making automations. I hope that changing the driver slightly, i can make it report watt without going “minus”, or strip that function away from the code if possible.

Hi, @goosetapo!

This is the official repo where you can find the drivers published by ST.
Here’s the Zigbee Switch driver:

You need to download the code from GitHub:

Unzip the file and you’ll find the driver in drivers/SmartThings/zigbee-switch and you can update its content in a code editor like Visual Studio, Atom, Brackets, etc.

To upload the driver and install it, you can take a look at this tutorial, the section called “Uploading Your Driver to SmartThings”

Do you mean it reports negative values? In the driver’s logs (logcat command), do you see the incoming reports with that value?

1 Like

It is perfectly reasonable for power to be a negative quantity. Unfortunately it seems that the authors of the capability presentations don’t know this.


Yep. I have previously discussed this with a smartthings staff member, but they are no longer with the company.

In modern solar systems, for example, it is common for power to be able to flow in two directions. You might be sharing power to the grid, or consuming power from it, depending on time of day and usage. :sun_with_face:

In electrical engineering:

In electrical engineering, power represents the rate of electrical energy flowing into or out of a given device (electrical component) or control volume. Power is a signed quantity; negative power represents power flowing in the opposite direction from positive power .

You may have a similar setup with a local generator system. Sometimes power is flowing in, sometimes power is flowing out. So in engineering specifications, power is a signed quantity. ↔️


For the OP:

And all of that said, what’s the model number of this device? And since it’s a Zigbee device, by any chance is it using cluster 0702?

There have been issues in the past with smartthings and other ZHA coordinators only pulling in one endpoint for the “smart meter” cluster, so instead of getting watts, voltage, and current, you only get one of the three. But I don’t know if that’s affecting this particular issue. It has been an issue in the past with frient model SPLZB131.

Hmmm…if it’s the model above, it looks like @Diegocampy has those and has been using them with the custom edge driver here:

You might check to see if that has the same problem you are seeing.

thanks for all the replies so far!

The device i’m using is the Frient Smart plug mini.
It’s reporting fast and accurate. (every 1 second reporting)

I used the smartthings outlet, which does not support feeding energy (stays 0), the devolo smart plug and fibaro smart plug also do not measure feeding power. I used the aqara smart plug, but it’s values on solar panels are jumping up and down wildly inaccurately, and finally the aeotec smart switch 7 which works but only updates once per minute. (and reports feeding power also as consumed watts, therefore works with routines)
As you can see, i tried a lot and really want this setup to work to save costs on the energy bill. But because smartthings doesn’t allow a minus in the routines, i want to edit the driver to make it work.

no, the socket I use is different. It too has problems, but on consumption, it’s not the same thing :slight_smile:

1 Like

I noticed on some devices that yes, it only shows watts and on/off. But not on this frient plug. I just checked and yes its the same model.
I tried @Mariano_Colmenarejo’s driver but it will then only show watts and kwh usage. It doesn’t show on/off anymore so smartthings doesn’t see it as a switch.

So i checked the code from @nayelyz’s link, but cannot seem to find what i need to make changes. For power consumption reports it calls functions placed elsewhere. So i don’t think it’s possible to change minus into plus power for reporting sake on the driver code… :frowning:

I’m guessing you’re referring to the default handlers. You can find them in the ST Lua Libraries for you to take a reference (here you can download them), and configure custom zigbee handlers instead to make the corresponding conversion.

Please, let us know if you need help with this process. :smiley: