Koenkk / zigbee2mqtt

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

TuYa BW-SHP13 "TS011F_plug_1" - False zero Watt power data #16709

Closed SaturnusDJ closed 1 year ago

SaturnusDJ commented 1 year ago

What happened?

(Opening this as problem because incorrect information is at play.)

Got two TuYa BW-SHP13 "TS011F_plug_1" today. I actually was not surprised to see that this looks the same as the ten I got almost three years ago, yet have different internals... Basic TuYa politics...

And this different version thus comes with a problem: The power and current attributes drop to 0 (W, A) every 4.5 minutes. Those are false readings.

22:01:20: '{"child_lock":"UNLOCK","current":0.03,"energy":0.3,"indicator_mode":"off/on","linkquality":134,"power":12,"power_outage_memory":"restore","state":"ON","update":{"state":"idle"},"voltage":234}'
22:01:25: '{"child_lock":"UNLOCK","current":0.09,"energy":0.3,"indicator_mode":"off/on","linkquality":134,"power":12,"power_outage_memory":"restore","state":"ON","update":{"state":"idle"},"voltage":234}'
22:04:20: '{"child_lock":"UNLOCK","current":0.09,"energy":0.3,"indicator_mode":"off/on","linkquality":134,"power":12,"power_outage_memory":"restore","state":"ON","update":{"state":"idle"},"voltage":234}'
22:04:20: '{"child_lock":"UNLOCK","current":0.09,"energy":0.3,"indicator_mode":"off/on","linkquality":134,"power":13,"power_outage_memory":"restore","state":"ON","update":{"state":"idle"},"voltage":234}'
22:05:18: '{"child_lock":"UNLOCK","current":0,"energy":0.3,"indicator_mode":"off/on","linkquality":134,"power":13,"power_outage_memory":"restore","state":"ON","update":{"state":"idle"},"voltage":234}'
22:05:18: '{"child_lock":"UNLOCK","current":0,"energy":0.3,"indicator_mode":"off/on","linkquality":138,"power":0,"power_outage_memory":"restore","state":"ON","update":{"state":"idle"},"voltage":234}'
22:05:23: '{"child_lock":"UNLOCK","current":0.09,"energy":0.3,"indicator_mode":"off/on","linkquality":134,"power":0,"power_outage_memory":"restore","state":"ON","update":{"state":"idle"},"voltage":234}'
22:05:23: '{"child_lock":"UNLOCK","current":0.09,"energy":0.3,"indicator_mode":"off/on","linkquality":134,"power":12,"power_outage_memory":"restore","state":"ON","update":{"state":"idle"},"voltage":234}'
22:09:41: '{"child_lock":"UNLOCK","current":0.09,"energy":0.3,"indicator_mode":"off/on","linkquality":134,"power":12,"power_outage_memory":"restore","state":"ON","update":{"state":"idle"},"voltage":234}'
22:09:42: '{"child_lock":"UNLOCK","current":0.09,"energy":0.3,"indicator_mode":"off/on","linkquality":134,"power":13,"power_outage_memory":"restore","state":"ON","update":{"state":"idle"},"voltage":234}'
22:09:46: '{"child_lock":"UNLOCK","current":0,"energy":0.3,"indicator_mode":"off/on","linkquality":134,"power":13,"power_outage_memory":"restore","state":"ON","update":{"state":"idle"},"voltage":234}'
22:09:46: '{"child_lock":"UNLOCK","current":0,"energy":0.3,"indicator_mode":"off/on","linkquality":138,"power":0,"power_outage_memory":"restore","state":"ON","update":{"state":"idle"},"voltage":234}'
22:09:51: '{"child_lock":"UNLOCK","current":0.09,"energy":0.3,"indicator_mode":"off/on","linkquality":134,"power":0,"power_outage_memory":"restore","state":"ON","update":{"state":"idle"},"voltage":234}'
22:09:54: '{"child_lock":"UNLOCK","current":0.09,"energy":0.3,"indicator_mode":"off/on","linkquality":134,"power":12,"power_outage_memory":"restore","state":"ON","update":{"state":"idle"},"voltage":234}'

(Cut out some column for readability)

Can we filter this? Maybe a device_specific option to only accept zero if it is zero for x seconds. Where x should be 6 for the log above.

Oh and where measurement_poll_interval was available for the 'older' version I got of this plug, it is not available for this one, and also does not do anything when added to the configuration file.

What did you expect to happen?

No response

How to reproduce it (minimal and precise)

No response

Zigbee2MQTT version

1.28.4

Adapter firmware version

20220219

Adapter

zzh! CC2652R

Debug log

No response

ceesvanegmond commented 1 year ago

@SaturnusDJ Having the same problem It seems to be hardware related issue https://github.com/Koenkk/zigbee2mqtt/issues/12421

ceesvanegmond commented 1 year ago

@SaturnusDJ Having these kind of graphs at the moment 😆

Screenshot 2023-03-04 at 11 54 32
SaturnusDJ commented 1 year ago

That is truly nuts... I get the feeling these are not hardware defects but bad design. Unless there are users with no dips? Please post.

Therefore I hope it is possible to add a setting to only accept zero values after three zero values have been reported.

SaturnusDJ commented 1 year ago

I reported the issue to BlitzWolf now.

ceesvanegmond commented 1 year ago

@SaturnusDJ Yeah; they probably aren't going to do anything with it... Unfortunately...

SaturnusDJ commented 1 year ago

First they asked where I bought them, then they told me to contact that platform for a restock date. Completely irrelevant replies. What an idiots. Guess BlitzWolf does nothing more than put a label on boxes. Will try TuYa.

SaturnusDJ commented 1 year ago

TuYa also can't help because by buying from them, BlitzWolf takes all responsibility/accountability I guess. I wrote again to BlitzWolf. After that I will mention Koen here, hopefully he is open to a workaround. Otherwise it's game-over.

SaturnusDJ commented 1 year ago

@Koenkk Can you share your idea of what this is and what to do with it? BlitzWolf is unwilling to look at their firmware.

Koenkk commented 1 year ago

My expectation is that the firmware is bugged and incorrectly reports 0, to confirm, please provide the debug log when zero is reported.

See https://www.zigbee2mqtt.io/guide/usage/debug.html on how to enable debug logging.

vincentscode commented 1 year ago

The device does seem to report 0.

Debug 2023-04-13 22:12:04   Received Zigbee message from 'Server Socket', type 'attributeReport', cluster 'haElectricalMeasurement', data '{"activePower":69}' from endpoint 1 with groupID null
Debug 2023-04-13 22:12:06   Received Zigbee message from 'Server Socket', type 'attributeReport', cluster 'haElectricalMeasurement', data '{"activePower":65}' from endpoint 1 with groupID null
Debug 2023-04-13 22:12:11   Received Zigbee message from 'Server Socket', type 'attributeReport', cluster 'haElectricalMeasurement', data '{"activePower":0}' from endpoint 1 with groupID null
Debug 2023-04-13 22:12:13   Received Zigbee message from 'Server Socket', type 'attributeReport', cluster 'haElectricalMeasurement', data '{"activePower":66}' from endpoint 1 with groupID null
Debug 2023-04-13 22:12:22   Received Zigbee message from 'Server Socket', type 'attributeReport', cluster 'haElectricalMeasurement', data '{"activePower":69}' from endpoint 1 with groupID null
Debug 2023-04-13 22:12:27   Received Zigbee message from 'Server Socket', type 'attributeReport', cluster 'haElectricalMeasurement', data '{"activePower":65}' from endpoint 1 with groupID null
Debug 2023-04-13 22:12:30   Received Zigbee message from 'Server Socket', type 'attributeReport', cluster 'haElectricalMeasurement', data '{"activePower":63}' from endpoint 1 with groupID null
Koenkk commented 1 year ago

I see, I cannot fix it from the z2m side, it's an issue of the device itself.

vincentscode commented 1 year ago

That's unfortunate, but understandable. I assume contacting some tuya whitelabel company will have little effect. Is there any way to filter this in z2m?

Koenkk commented 1 year ago

@vincentscode how do you want to filter it? You don't know whether the 0 report is a false report or a real measurement.

vincentscode commented 1 year ago

@Koenkk Sure, but it seems like it's a very short singular measurement (<=2s until next message) and is surrounded by wildly different values. This seems like something that would never occur in real-world use.

Koenkk commented 1 year ago

The debounce option might do the trick: https://www.zigbee2mqtt.io/guide/configuration/devices-groups.html#common-device-options

vincentscode commented 1 year ago

Unfortunately using a debounce value just causes it to send no data at all to Home Assistant. (the flat sections are with using different debounce values, between is without) image

Koenkk commented 1 year ago

@vincentscode can you provide the debug log when load is removed from the plug (so 0 is the real value)? What we can can is e.g. always ignore the first 0 value

vincentscode commented 1 year ago

@Koenkk Sure. I've not removed the other attributeReports this time:

Debug 2023-04-15 09:28:09Received Zigbee message from 'Test Socket 2', type 'attributeReport', cluster 'haElectricalMeasurement', data '{"activePower":0}' from endpoint 1 with groupID null
Debug 2023-04-15 09:28:09Received Zigbee message from 'Test Socket 2', type 'attributeReport', cluster 'seMetering', data '{"currentSummDelivered":[0,0]}' from endpoint 1 with groupID null
Debug 2023-04-15 09:28:10Received Zigbee message from 'Test Socket 2', type 'attributeReport', cluster 'haElectricalMeasurement', data '{"rmsCurrent":0}' from endpoint 1 with groupID null
Debug 2023-04-15 09:28:19Received Zigbee message from 'Test Socket 2', type 'attributeReport', cluster 'haElectricalMeasurement', data '{"activePower":0}' from endpoint 1 with groupID null
Debug 2023-04-15 09:28:19Received Zigbee message from 'Test Socket 2', type 'attributeReport', cluster 'seMetering', data '{"currentSummDelivered":[0,0]}' from endpoint 1 with groupID null
Debug 2023-04-15 09:28:20Received Zigbee message from 'Test Socket 2', type 'attributeReport', cluster 'haElectricalMeasurement', data '{"rmsCurrent":0}' from endpoint 1 with groupID null
Debug 2023-04-15 09:28:21Received Zigbee message from 'Test Socket 2', type 'attributeReport', cluster 'haElectricalMeasurement', data '{"rmsVoltage":227}' from endpoint 1 with groupID null
Debug 2023-04-15 09:28:28Received Zigbee message from 'Test Socket 2', type 'attributeReport', cluster 'haElectricalMeasurement', data '{"rmsVoltage":226}' from endpoint 1 with groupID null
Debug 2023-04-15 09:28:29Received Zigbee message from 'Test Socket 2', type 'attributeReport', cluster 'seMetering', data '{"currentSummDelivered":[0,0]}' from endpoint 1 with groupID null
Debug 2023-04-15 09:28:29Received Zigbee message from 'Test Socket 2', type 'attributeReport', cluster 'haElectricalMeasurement', data '{"activePower":0}' from endpoint 1 with groupID null
Debug 2023-04-15 09:28:30Received Zigbee message from 'Test Socket 2', type 'attributeReport', cluster 'haElectricalMeasurement', data '{"rmsCurrent":0}' from endpoint 1 with groupID null
Debug 2023-04-15 09:28:33Received Zigbee message from 'Test Socket 2', type 'attributeReport', cluster 'haElectricalMeasurement', data '{"rmsVoltage":227}' from endpoint 1 with groupID null
Debug 2023-04-15 09:28:39Received Zigbee message from 'Test Socket 2', type 'attributeReport', cluster 'haElectricalMeasurement', data '{"activePower":0}' from endpoint 1 with groupID null
Debug 2023-04-15 09:28:39Received Zigbee message from 'Test Socket 2', type 'attributeReport', cluster 'seMetering', data '{"currentSummDelivered":[0,0]}' from endpoint 1 with groupID null
Debug 2023-04-15 09:28:40Received Zigbee message from 'Test Socket 2', type 'attributeReport', cluster 'haElectricalMeasurement', data '{"rmsCurrent":0}' from endpoint 1 with groupID null
Debug 2023-04-15 09:28:42Received Zigbee message from 'Test Socket 2', type 'attributeReport', cluster 'haElectricalMeasurement', data '{"rmsVoltage":226}' from endpoint 1 with groupID null
Debug 2023-04-15 09:28:47Received Zigbee message from 'Test Socket 2', type 'attributeReport', cluster 'haElectricalMeasurement', data '{"rmsVoltage":225}' from endpoint 1 with groupID null
Debug 2023-04-15 09:28:49Received Zigbee message from 'Test Socket 2', type 'attributeReport', cluster 'haElectricalMeasurement', data '{"activePower":0}' from endpoint 1 with groupID null
Debug 2023-04-15 09:28:49Received Zigbee message from 'Test Socket 2', type 'attributeReport', cluster 'seMetering', data '{"currentSummDelivered":[0,0]}' from endpoint 1 with groupID null
Debug 2023-04-15 09:28:50Received Zigbee message from 'Test Socket 2', type 'attributeReport', cluster 'haElectricalMeasurement', data '{"rmsCurrent":0}' from endpoint 1 with groupID null

It seems from the log that removing the first 0 (or having the option to) should work fine as long as the reporting frequency is set high enough.

Koenkk commented 1 year ago

Could you check if the issue is fixed with the following external converter: https://gist.github.com/Koenkk/9a00f014c9b4c4588a49db6f49cfe0be

vincentscode commented 1 year ago

Thanks, this seems to be working! I do get the log messages about as frequently as I was getting the 0 data so it appears to be filtering correctly.

While we're at it: The same issue seems to also affect current measurement (which makes sense i suppose): image

Voltage also drops to zero sometimes for 1 dataframe but it's a lot less frequent: image

Additionally I've noticed that when testing with a very low intermittent load (such as a laptop loading with a full battery) "TEMPORARY LOG: SKIPPING 0 VALUE" get's spammed quite a lot and no data is reported, I am unsure as to why that's the case but it seems like it likely won't be an issue for most people.

Koenkk commented 1 year ago

Updated https://gist.github.com/Koenkk/9a00f014c9b4c4588a49db6f49cfe0be to also apply the fix to current and voltage, can you check it?

Note that the TEMPORARY LOG: SKIPPING 0 VALUE logging will be removed in the final fix.

vincentscode commented 1 year ago

It seems to be working just fine with the new version.

Koenkk commented 1 year ago

@vincentscode @SaturnusDJ can you both provide the data/database.db entry of your device? Then I will make sure this fix only gets applied to your device version.

vincentscode commented 1 year ago

I've got these two:

{"id":8,"type":"Router","ieeeAddr":"0xa4c1389e67732ef2","nwkAddr":32527,"manufId":4417,"manufName":"_TZ3000_gvn91tmx","powerSource":"Mains (single phase)","modelId":"TS011F","epList":[1,242],"endpoints":{"1":{"profId":260,"epId":1,"devId":266,"inClusterList":[3,4,5,6,1794,2820,57344,57345,0],"outClusterList":[25,10],"clusters":{"genBasic":{"attributes":{"65503":"\u0005L�+\u0003","65506":54,"65508":0,"65534":0,"modelId":"TS011F","manufacturerName":"_TZ3000_gvn91tmx","powerSource":1,"zclVersion":3,"appVersion":192,"stackVersion":0,"hwVersion":1,"dateCode":""}},"haElectricalMeasurement":{"attributes":{"acCurrentDivisor":1000,"acCurrentMultiplier":1,"rmsVoltage":225,"rmsCurrent":342,"activePower":67}},"seMetering":{"attributes":{"divisor":100,"multiplier":1,"currentSummDelivered":[0,1437]}},"genOnOff":{"attributes":{"32768":0,"onOff":1,"onTime":0,"offWaitTime":0,"tuyaBacklightMode":0,"moesStartUpOnOff":2,"tuyaBacklightSwitch":1}},"manuSpecificTuya_3":{"attributes":{"53248":1,"53249":0,"53250":2862919,"53251":121,"53252":10714,"53253":1257,"powerOnBehavior":2,"switchType":0}}},"binds":[{"cluster":6,"type":"endpoint","deviceIeeeAddress":"0x00212effff051b33","endpointID":1},{"cluster":2820,"type":"endpoint","deviceIeeeAddress":"0x00212effff051b33","endpointID":1},{"cluster":1794,"type":"endpoint","deviceIeeeAddress":"0x00212effff051b33","endpointID":1}],"configuredReportings":[{"cluster":1794,"attrId":0,"minRepIntval":5,"maxRepIntval":3600,"repChange":[1,1]},{"cluster":2820,"attrId":1291,"minRepIntval":1,"maxRepIntval":10,"repChange":1},{"cluster":2820,"attrId":1288,"minRepIntval":1,"maxRepIntval":10,"repChange":1},{"cluster":2820,"attrId":1285,"minRepIntval":1,"maxRepIntval":10,"repChange":1}],"meta":{}},"242":{"profId":41440,"epId":242,"devId":97,"inClusterList":[],"outClusterList":[33],"clusters":{},"binds":[],"configuredReportings":[],"meta":{}}},"appVersion":192,"stackVersion":0,"hwVersion":1,"dateCode":"","zclVersion":3,"interviewCompleted":true,"meta":{"configured":-892627439},"lastSeen":1681640527425,"defaultSendRequestWhen":"immediate"}
{"id":9,"type":"Router","ieeeAddr":"0xa4c1385a9b06c337","nwkAddr":46847,"manufId":4417,"manufName":"_TZ3000_gvn91tmx","powerSource":"Mains (single phase)","modelId":"TS011F","epList":[1,242],"endpoints":{"1":{"profId":260,"epId":1,"devId":266,"inClusterList":[3,4,5,6,1794,2820,57344,57345,0],"outClusterList":[25,10],"clusters":{"genBasic":{"attributes":{"65506":54,"65508":0,"65534":0,"modelId":"TS011F","manufacturerName":"_TZ3000_gvn91tmx","powerSource":1,"zclVersion":3,"appVersion":77,"stackVersion":0,"hwVersion":1,"dateCode":""}},"haElectricalMeasurement":{"attributes":{"acCurrentDivisor":1000,"acCurrentMultiplier":1,"rmsVoltage":226,"rmsCurrent":0,"activePower":0}},"seMetering":{"attributes":{"divisor":100,"multiplier":1,"currentSummDelivered":[0,0]}},"genOnOff":{"attributes":{"32768":0,"onOff":1,"onTime":0,"offWaitTime":0,"tuyaBacklightMode":0,"moesStartUpOnOff":2,"tuyaBacklightSwitch":1}},"manuSpecificTuya_3":{"attributes":{"53248":1,"53249":0,"53250":2767245,"53251":122,"53252":11118,"53253":1300,"powerOnBehavior":2,"switchType":0}}},"binds":[{"cluster":6,"type":"endpoint","deviceIeeeAddress":"0x00212effff051b33","endpointID":1},{"cluster":2820,"type":"endpoint","deviceIeeeAddress":"0x00212effff051b33","endpointID":1},{"cluster":1794,"type":"endpoint","deviceIeeeAddress":"0x00212effff051b33","endpointID":1}],"configuredReportings":[{"cluster":1794,"attrId":0,"minRepIntval":5,"maxRepIntval":10,"repChange":1},{"cluster":2820,"attrId":1291,"minRepIntval":5,"maxRepIntval":10,"repChange":1},{"cluster":2820,"attrId":1288,"minRepIntval":5,"maxRepIntval":10,"repChange":1},{"cluster":2820,"attrId":1285,"minRepIntval":5,"maxRepIntval":3600,"repChange":0}],"meta":{}},"242":{"profId":41440,"epId":242,"devId":97,"inClusterList":[],"outClusterList":[33],"clusters":{},"binds":[],"configuredReportings":[],"meta":{}}},"appVersion":77,"stackVersion":0,"hwVersion":1,"dateCode":"","zclVersion":3,"interviewCompleted":true,"meta":{"configured":-892627439},"lastSeen":1681546683144,"defaultSendRequestWhen":"immediate"}
SaturnusDJ commented 1 year ago

Hey guys, sorry I was away. Thanks for the progress. 👍🏼👌🏼

Currently also two in the network here:

{"id":53,"type":"Router","ieeeAddr":"0x","nwkAddr":14527,"manufId":4417,"manufName":"_TZ3000_amdymr7l","powerSource":"Mains (single phase)","modelId":"TS011F","epList":[1,242],"endpoints":{"1":{"profId":260,"epId":1,"devId":266,"inClusterList":[3,4,5,6,1794,2820,57344,57345,0],"outClusterList":[25,10],"clusters":{"genBasic":{"attributes":{"65503":"\u0013W�+\u0003","65506":54,"65508":0,"65534":0,"modelId":"TS011F","manufacturerName":"_TZ3000_amdymr7l","powerSource":1,"zclVersion":3,"appVersion":192,"stackVersion":0,"hwVersion":1,"dateCode":""}},"haElectricalMeasurement":{"attributes":{"acCurrentDivisor":1000,"acCurrentMultiplier":1,"rmsVoltage":233,"rmsCurrent":0,"activePower":0}},"seMetering":{"attributes":{"divisor":100,"multiplier":1,"currentSummDelivered":[0,432]}},"genOnOff":{"attributes":{"32768":0,"onOff":1,"onTime":0,"offWaitTime":0,"tuyaBacklightMode":1,"moesStartUpOnOff":2,"tuyaBacklightSwitch":1}},"manuSpecificTuya_3":{"attributes":{"53248":1,"53249":0,"53250":2793982,"53251":133,"53252":9207,"53253":1288,"powerOnBehavior":2,"switchType":0}}},"binds":[{"cluster":6,"type":"endpoint","deviceIeeeAddress":"0x","endpointID":1},{"cluster":2820,"type":"endpoint","deviceIeeeAddress":"0x","endpointID":1},{"cluster":1794,"type":"endpoint","deviceIeeeAddress":"0x","endpointID":1}],"configuredReportings":[{"cluster":2820,"attrId":1285,"minRepIntval":5,"maxRepIntval":3600,"repChange":5},{"cluster":2820,"attrId":1288,"minRepIntval":5,"maxRepIntval":3600,"repChange":50},{"cluster":2820,"attrId":1291,"minRepIntval":5,"maxRepIntval":3600,"repChange":10},{"cluster":1794,"attrId":0,"minRepIntval":5,"maxRepIntval":3600,"repChange":[1,1]}],"meta":{}},"242":{"profId":41440,"epId":242,"devId":97,"inClusterList":[],"outClusterList":[33],"clusters":{},"binds":[],"configuredReportings":[],"meta":{}}},"appVersion":192,"stackVersion":0,"hwVersion":1,"dateCode":"","zclVersion":3,"interviewCompleted":true,"meta":{"configured":-892627439},"lastSeen":1681425489969,"defaultSendRequestWhen":"immediate"}
{"id":58,"type":"Router","ieeeAddr":"0x","nwkAddr":15544,"manufId":4417,"manufName":"_TZ3000_amdymr7l","powerSource":"Mains (single phase)","modelId":"TS011F","epList":[1,242],"endpoints":{"1":{"profId":260,"epId":1,"devId":266,"inClusterList":[3,4,5,6,1794,2820,57344,57345,0],"outClusterList":[25,10],"clusters":{"genBasic":{"attributes":{"65503":"���+\u0003","65506":54,"65508":0,"65534":0,"modelId":"TS011F","manufacturerName":"_TZ3000_amdymr7l","powerSource":1,"zclVersion":3,"appVersion":192,"stackVersion":0,"hwVersion":1,"dateCode":""}},"haElectricalMeasurement":{"attributes":{"acCurrentDivisor":1000,"acCurrentMultiplier":1,"rmsVoltage":234,"rmsCurrent":492,"activePower":75}},"seMetering":{"attributes":{"divisor":100,"multiplier":1,"currentSummDelivered":[0,9300]}},"genOnOff":{"attributes":{"32768":0,"onOff":1,"onTime":0,"offWaitTime":0,"tuyaBacklightMode":1,"moesStartUpOnOff":2,"tuyaBacklightSwitch":1}},"manuSpecificTuya_3":{"attributes":{"53248":1,"53249":0,"53250":2581720,"53251":142,"53252":9987,"53253":1394,"powerOnBehavior":2,"switchType":0}}},"binds":[{"cluster":6,"type":"endpoint","deviceIeeeAddress":"0x","endpointID":1},{"cluster":2820,"type":"endpoint","deviceIeeeAddress":"0x","endpointID":1},{"cluster":1794,"type":"endpoint","deviceIeeeAddress":"0x","endpointID":1}],"configuredReportings":[{"cluster":2820,"attrId":1285,"minRepIntval":5,"maxRepIntval":3600,"repChange":5},{"cluster":2820,"attrId":1288,"minRepIntval":5,"maxRepIntval":3600,"repChange":50},{"cluster":2820,"attrId":1291,"minRepIntval":5,"maxRepIntval":3600,"repChange":10},{"cluster":1794,"attrId":0,"minRepIntval":5,"maxRepIntval":3600,"repChange":[1,1]}],"meta":{}},"242":{"profId":41440,"epId":242,"devId":97,"inClusterList":[],"outClusterList":[33],"clusters":{},"binds":[],"configuredReportings":[],"meta":{}}},"appVersion":192,"stackVersion":0,"hwVersion":1,"dateCode":"","zclVersion":3,"interviewCompleted":true,"meta":{"configured":-892627439},"lastSeen":1681645586163,"defaultSendRequestWhen":"immediate"}
Koenkk commented 1 year ago

Integrated the fix!

Changes will be available in the dev branch in a few hours from now. (https://www.zigbee2mqtt.io/advanced/more/switch-to-dev-branch.html)

izb2000 commented 1 year ago

It does not work correctly. If you remove the load, power and current do not show 0, they continue to show the last load value. Is it possible to add a forced poll at a zero value?

stathismes commented 1 year ago

I confirm this too. Last loaded value remains once you turn the power off.

PunyIron commented 1 year ago

@Koenkk, I can confirm wrong behaviour too. Your modification made above works correctly only if non-zero power load is continuous. If zero load is occuring, reporting is wrong - it reports last non-zero value. So it is never possible to achieve zero reporting. Is it possible to repair it? Thanks.

SaturnusDJ commented 1 year ago

Maybe my initial suggestion would work?

Maybe a device_specific option to only accept zero if it is zero for x seconds. Where x should be 6 for the log above.

So basically to hold back on the zero for a few seconds because if it is a wrong zero, the plug soon enough will report >0. But if it does not, then we know that it really is zero.

starlightbg commented 1 year ago

Version 1.30.4 broke _TZ3000_gvn91tmx (Aubess 20A TS011F_plug_1) on my side too. Now it shows the last value that is >0. Even if the plug is off, it does not show "0".

{ "child_lock": "UNLOCK", "current": 8.46, "energy": 56.32, "indicator_mode": "off", "last_seen": "2023-05-02T13:55:20.077Z", "linkquality": 164, "power": 1582, "power_outage_memory": "restore", "state": "OFF", "update": { "installed_version": 192, "latest_version": 192, "state": "idle" }, "voltage": 228, "update_available": null }

When i try to set the min reporting change to 0 for the power i get: error 2023-05-02 18:04:45 Exception while calling fromZigbee converter: Cannot read properties of undefined (reading 'power')}

vincentscode commented 1 year ago

I'm also seeing this bug @Koenkk. I think the error is a result of deleting the key (delete result[key], L.733) before putting it into the globalStore (L.736). https://github.com/Koenkk/zigbee-herdsman-converters/commit/4a4b156103a8790e199560bf72254315821ec6fd#diff-7ae23d3c13c2d7f7e37106590684c791aba8093f8be813b7c74a4f1484017c3bR733-R736

The fix would then be to replace result[key] with zero.

-if (result[key] === 0 && globalStore.getValue(msg.endpoint, key) !== 0) {
-    delete result[key];
-}
-globalStore.putValue(msg.endpoint, key, result[key]);
+if (result[key] === 0 && globalStore.getValue(msg.endpoint, key) !== 0) {
+   delete result[key];
+   globalStore.putValue(msg.endpoint, key, 0);
+} else {
+   globalStore.putValue(msg.endpoint, key, result[key]);
+}
Koenkk commented 1 year ago

@vincentscode applied the fix, thanks!

Can you check if it works?

Changes will be available in the dev branch in a few hours from now. (https://www.zigbee2mqtt.io/advanced/more/switch-to-dev-branch.html)

temasnick commented 1 year ago

@vincentscode applied the fix, thanks!

Can you check if it works?

It's working but delayed. To show 0 watt must be pass 5 to 10 mins. And works unreliably.

Thanks for your work.

squadramunter commented 1 year ago

@vincentscode Can confirm. Still does have a high delay in updating Wattage when from powererd off state to turned on state. During 5 tot 7 minutes before Wattage reach 0 Watt while the Current updates immediately wattage

Koenkk commented 1 year ago

Could you check if the issue is fixed with the following external converter: https://gist.github.com/Koenkk/c7bb3c0a01bf48fd1c9ee89aaf2316bb

temasnick commented 1 year ago

@Koenkk, yes it's working with external converter. Only 5 to 8 secs delay for 0 watt to appear. Thanks...

starlightbg commented 1 year ago

@Koenkk Still not ok, with the latest external converter..

If the "Min rep change" is more than the max value it not working. In my case min rep change is 10 , the val of the power is 7W

Screenshot 2023-05-03 at 22 04 26
squadramunter commented 1 year ago

Same here running Home Assistant Z2M Edge version. Still not updating as quickly as usual. Still takes around 5 to 7 minutes even with external addon added in the configuration.

My Wattage is 9 Watt and take a long time to update.

starlightbg commented 1 year ago

More logs when powered on from zero:

"last_seen":"2023-05-03T19:14:48.769Z","linkquality":220,"power":0,"power_outage_memory":"restore","state":"OFF" "last_seen":"2023-05-03T19:14:48.769Z","linkquality":220,"power":0,"power_outage_memory":"restore","state":"ON" "last_seen":"2023-05-03T19:14:48.778Z","linkquality":220,"power":0,"power_outage_memory":"restore","state":"ON" "last_seen":"2023-05-03T19:15:40.532Z","linkquality":220,"power":0,"power_outage_memory":"restore","state":"ON" "last_seen":"2023-05-03T19:15:40.627Z","linkquality":220,"power":7,"power_outage_memory":"restore","state":"ON" "last_seen":"2023-05-03T19:15:42.415Z","linkquality":220,"power":7,"power_outage_memory":"restore","state":"ON"

temasnick commented 1 year ago

If the "Min rep change" is more than the max value it not working. In my case min rep change is 10 , the val of the power is 7W

@starlightbg, isn't it expected behaviour? When active power below min rep change it is only tirigger reporting for time variable, am i right? I installed my device couple days ago. I don't know expected behaviour.

starlightbg commented 1 year ago

@temasnick you are correct, but in the first screenshot more that 1 minute passed since the plug was powered off and the power was still 7 , not 0 :)

mrdroopy commented 1 year ago

javascript fix works like a charm here, though its all plugs doing >10W loads.

starlightbg commented 1 year ago

I just noticed that on a plug with high load the power is set to 0 on power off after some seconds, bit the "current" keeps the last value.

Screenshot 2023-05-03 at 23 31 47
squadramunter commented 1 year ago

@mrdroopy Could you check with a lamp that uses less then 10W of power? Does it update as quickly or does it still have a delay? With my setup it has still a delay

squadramunter commented 1 year ago

@starlightbg Even with Wattage under 10 Watt current still takes a long time before it reaches 0A

But when I turn it on the current updates immediately

Do you see the same behavior?

mrdroopy commented 1 year ago

@squadramunter will have to check when i'm home. Can confirm @starlightbg observation:

image

The current value stays at the last value for 1-2 minutes after Wattage drops to 0. Does drop to 0 A eventually.

starlightbg commented 1 year ago

@squadramunter Same here :)

As far as i can see only "current" and "power" are affected. Filtering these false zero reports will be very tricky.

First when the state is OFF, zero values should not be delayed or ignored. When the state is ON - this is probably the hard part as every delay will brake other stuff. If we ignore the zero reading we should be able to force the device to send another report ASAP. Not sure if @Koenkk can implement some logic like : if value is 0 -> wait for example 5 seconds -> if no new value arrives during this 5 second period -> set the original value if new value arrives during this period to use it.

Not sure if all these hacks for these two plugs deserve the effort :) Yes they send false zero reports from time to time, but otherwise they work fine. I didn't notice the problem, as i use them on some heaters which start from time to time and i take only the total energy.

squadramunter commented 1 year ago

@starlightbg I would like to see that Power and Current is updating realtime or at least updating in seconds rather then minutes what it is doing now. I use a graph in Home Assistant that is time based and use automations when something turns on and off like my lights in house. Should be good to know it turned on the exact time off and on. Now I need to guess everytime when it turned on or off :-)

I hope there is a solution to this problem.

Koenkk commented 1 year ago

@starlightbg

Not sure if @Koenkk can implement some logic like : if value is 0 -> wait for example 5 seconds -> if no new value arrives during this 5 second period -> set the original value if new value arrives during this period to use it.

That is exactly what this ext converter should be doing. I've updated the converter with some logging so we can better see what is happening. Please test https://gist.github.com/Koenkk/c7bb3c0a01bf48fd1c9ee89aaf2316bb