Koenkk / zigbee2mqtt

Zigbee 🐝 to MQTT bridge 🌉, get rid of your proprietary Zigbee bridges 🔨
https://www.zigbee2mqtt.io
GNU General Public License v3.0
12.07k stars 1.67k forks source link

[Feature request]: Improvements to PJ-1203A - Reset Energy Sum and Channel Multiplier #24447

Open tdashmike opened 1 week ago

tdashmike commented 1 week ago

Is your feature request related to a problem? Please describe

There is currently no way to reset the total energy consumption and use a CT clamp with a higher current rating.

Describe the solution you'd like

An option to reset the total energy consumption and a multiplier for each channel for different CT clamps.

For example, the energy monitor came with 1000:1 CT clamps. If I buy a 3000:1 clamp, the reading would be 1/3 of the 1000:1 CT clamp. In this case I would want a multiplier of 3. This would allow me to go over the 80 A max limit safely.

Describe alternatives you've considered

You can probably reset the energy sum in the Tuya app but I did not install it yet.

Additional context

@schauveau Is this something you can help with? Thanks!

schauveau commented 1 week ago

You can reset the Energy (and all datapoints) by resetting the device (a very long press?) and pair it again.

At one point, I had the calibrations datapoints working but I did not find them very useful because the multipliers are applied independently of each others. For example, the Current calibration was not affecting power (i.e. calibration of I and U is ignored when computing P=UI) and the Power calibration was not affecting Energy. Even worse, Energy calibration is applied to the final result and not during the "accumulation" meaning that changing the calibration introduces a huge jumps in the reported value. I still have a few huge nonsensical energy values in my HomeAssistant database because of that.

Anyways, if you want to try it yourself then look at the commented code in my old repo https://github.com/schauveau/z2m_PJ-1203A/blob/main/PJ-1203A-v3.js

You will notice in my code that the calibration ranges are limited to [ 0.5 , 2 ]. .withValueMin(0.5).withValueMax(2.0)

I do not remember if this is an actual limitation of the device or something I introduced myself.

If the calibration range is really limited to [0.5,2] then another approach could be to replace [106, 'energy_a', tuya.valueConverter.divideBy100 ] by something like [106, 'energy_a', tuya.valueConverterBasic.divideBy(N) ] where N is either 300 or 33.3

The easiest way to experiment is probably to copy and modify my latest external converter PJ-1203A-v4.js . I did not try it since the code was accepted in Z2M 6 months ago but it should hopefully still work.

schauveau commented 1 week ago

Also, it may be easier to scale the values in the final application. If you are using HomeAssistant, create a copy of each entity scaled by the proper factor.

digitlength commented 6 days ago

(a very long press?)

For those trying this, for me it wouldn't reset after holding for 1 minute, but would after holding for 2 minutes.