-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Smart energy meter _TZE200_nslr42tt reports inadequate power values #18603
Comments
This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 7 days |
any clues? |
This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 7 days |
I'll bring up the topic, have you decided in any way? I have the same problem, the same power 2 phase (I think I need to update) |
The crazy readings are "negative" values. I measured a single line with two clamps. one reversed of the other.
dt0, dp6 = 0,0,19
dt0, dp8 = 153,153,134
I assume the conversion is wrong and doesn't mind the negative value. The Meter i use has the Fingerprint: _TZE200_nslr42tt |
could it be that either your L2 clamp is clipped arroud the cable in reverse (mind the direction arrow printed on the clamp) or L2 is producing and not consuming. Maybe a balcony solar on L2 or something similar. Because the crazy numbers seem to be negative power values (production). |
FFFF = 39321 so if the value is bigger then 30000 then the real value is ((39321-VLAUE) * -1) in my example this would be: which is correct, since the reversed clamp on the same phase measured: i have no clue how to implement this into the tuya.js |
@Koenkk |
Hi everyone, I'm having this issue too, and following what @eokgnah it makes total sense that those values are just negative numbers What I'm unsure about is the global energy number format quick edit as im very new to the whole zigbee and Z2M stuff i'm not sure where or how to "debug" the values or see the data transfer |
I was too tired yesterday, @eokgnah was right, and my load may have changed power during measurements those arbitrary numbers seem a bit off to me tho What happens to the whole 0x999A to 0xFFFF range?? anyway, I would read the docs today and try to get measurements |
after running some more test Total positive: By the pictures, we can deduct that 39125W is -197W ,39124W is -198W and 39123W is -199WSo we should be using correct me if I'm wrong, please regarding the global power value if the above calculations are okay, then here we find: -199 (39123) + 198 -198 (39124), which would result in 199W (429496531) leaving the global value to the formula `((429496730−VALUE)* -1)` if value is above 0x0FFFFFFF (268435455W).More images here: I sadly notice that even if we have the negative values for the inmediate power, the energy usage when values are negative rises as if they were positive @Koenkk in a bit familliar with js and ts, but i dont think im up to the task, nevertheless, where can i lear a bit more on how the converters works and how to test them? |
Could you check if the issue is fixed with the following external converter:
external_converters:
- ext_converter.js
|
Hi @Koenkk, thank you for replying |
Hello again @Koenkk it shows the same measurements as the original And i have this error repeated in the logs Im using version |
Okay so i added now i have these readings Those readings seem very accurate to me (taking into account the A*V = W formula) Now what would be left to do is "fix" the global reading |
So we at last got both functions to get accurate negative readings on this device Regarding the accumulated energy consumption, a Riemann integral can be used in home assistant to get a pretty accurate value, I've already tested that on other devices. Here's the external converter code i am using right now, in case there's any doubts ext_converter.jsconst fz = require('zigbee-herdsman-converters/converters/fromZigbee');
const tz = require('zigbee-herdsman-converters/converters/toZigbee');
const exposes = require('zigbee-herdsman-converters/lib/exposes');
const reporting = require('zigbee-herdsman-converters/lib/reporting');
const tuya = require('zigbee-herdsman-converters/lib/tuya');
const e = exposes.presets;
const ea = exposes.access;
const legacy = require('zigbee-herdsman-converters/lib/legacy');
const lumi = require('zigbee-herdsman-converters/lib/lumi');
const utils = require('zigbee-herdsman-converters/lib/utils');
const {Buffer} = require('buffer');
const valueConverter = {
phaseVariant2WithPhaseCustom: (phase) => {
return {
from: (v) => {
// https://github.com/Koenkk/zigbee2mqtt/issues/18603#issuecomment-2277697295
const buf = Buffer.from(v, 'base64');
let power = buf[7] | (buf[6] << 8);
if (power > 0x7fff) {
power = (0x999a - power) * -1;
}
return {
[`voltage_${phase}`]: (buf[1] | (buf[0] << 8)) / 10,
[`current_${phase}`]: (buf[4] | (buf[3] << 8)) / 1000,
[`power_${phase}`]: power,
};
},
};
},
globalVariant2Custom: () => {
return {
from: (v) => {
let power = v;
if (power > 0x0FFFFFFF) {
power = (0x1999999c - power) * -1;
}
return power;
},
};
},
};
const definition = {
fingerprint: tuya.fingerprint('TS0601', ['_TZE200_nslr42tt']),
model: 'TS0601_3_phase_clamp_meter',
vendor: 'Tuya',
description: '3-phase clamp power meter CUSTOM',
fromZigbee: [tuya.fz.datapoints],
toZigbee: [tuya.tz.datapoints],
configure: tuya.configureMagicPacket,
whiteLabel: [
{vendor: 'MatSee Plus', model: 'PC321-Z-TY'},
{vendor: 'Owon', model: 'PC321-Z-TY'},
],
exposes: [
e.ac_frequency(),
e.temperature(),
e.current(),
e.power(),
e.energy(),
tuya.exposes.energyWithPhase('a'),
tuya.exposes.energyWithPhase('b'),
tuya.exposes.energyWithPhase('c'),
tuya.exposes.voltageWithPhase('a'),
tuya.exposes.voltageWithPhase('b'),
tuya.exposes.voltageWithPhase('c'),
tuya.exposes.powerWithPhase('a'),
tuya.exposes.powerWithPhase('b'),
tuya.exposes.powerWithPhase('c'),
tuya.exposes.currentWithPhase('a'),
tuya.exposes.currentWithPhase('b'),
tuya.exposes.currentWithPhase('c'),
tuya.exposes.powerFactorWithPhase('a'),
tuya.exposes.powerFactorWithPhase('b'),
tuya.exposes.powerFactorWithPhase('c'),
],
meta: {
multiEndpointSkip: ['power_factor', 'power_factor_phase_b', 'power_factor_phase_c', 'energy'],
tuyaDatapoints: [
[132, 'ac_frequency', tuya.valueConverter.raw],
[133, 'temperature', tuya.valueConverter.divideBy10],
[1, 'energy', tuya.valueConverter.divideBy100],
[101, 'energy_a', tuya.valueConverter.divideBy1000],
[111, 'energy_b', tuya.valueConverter.divideBy1000],
[121, 'energy_c', tuya.valueConverter.divideBy1000],
[131, 'current', tuya.valueConverter.divideBy1000],
// [9, 'power', tuya.valueConverter.raw],
[9, 'power', valueConverter.globalVariant2Custom()],
[102, 'power_factor_a', tuya.valueConverter.raw],
[112, 'power_factor_b', tuya.valueConverter.raw],
[122, 'power_factor_c', tuya.valueConverter.raw],
[6, null, valueConverter.phaseVariant2WithPhaseCustom('a')],
[7, null, valueConverter.phaseVariant2WithPhaseCustom('b')],
[8, null, valueConverter.phaseVariant2WithPhaseCustom('c')],
[134, 'device_status', tuya.valueConverter.raw],
],
},
};
module.exports = definition; of course, it should be refined, as i got little idea of how it does actually work |
Thanks, I've integrated the code. Assuming this can be closed now. Changes will be available in the dev branch in a few hours from now. |
Hi @Koenkk Thank you so much the accumulated energy consumption being wrong when we have negative readings (they are counted as positive) is something that is device dependent and (imo) out of the scope of Z2M. |
after updating tothe latest z2m power_[x] is now correctly displayed/calculated. would love to see that fixed too. and thanks for the affords so far! |
@Darkangeel-hd does the power show the correct value for you? |
I tested with a fresh install of z2m. |
also the overall power? |
Sorry, i only looked at the negative values on the L1-3 with a quick test setup. |
Yes, but i'm still using the external converter, as i did not update z2m to the latest version (i'm using alpine repos one, not docker) Pardon my very late reply, I was very busy all this time |
On another note... @Koenkk should we deal with this in z2m or in the receiving end? EDIT: |
So probably we are using the wrong data points, to figure those out: https://www.zigbee2mqtt.io/advanced/support-new-devices/03_find_tuya_data_points.html |
What happened?
HA via z2m on Sonoff ZBDongle-P; Tuya _TZE200_nslr42tt pairs OK and all values are reported; however power readings are well off the adequate line. Especially power readings go crazy when usage exceed 1.5kW.
What did you expect to happen?
power readings correlate with voltage and current from this universe
How to reproduce it (minimal and precise)
No response
Zigbee2MQTT version
1.32.2-1
Adapter firmware version
20210708
Adapter
SONOFF Zigbee 3.0 USB Dongle Plus ZBDongle-P
Debug log
No response
The text was updated successfully, but these errors were encountered: