node-zwave-js: [bug] NAS-WR01ZE: kWh meter value displayed as negative number
Version
Checklist:
- I am not using HomeAssistant. Or: a developer has told me to come here.
- I have checked the troubleshooting section and my problem is not described there.
- I have read the changelog problem was not mentioned there.
Build/Run method
- Docker
- PKG
- Snap package
- Manually built (git clone - yarn install - yarn run build )
zwavejs2mqtt version: 4.3.1 zwave-js version: 7.5.1
Describe the bug
The kWh
meter of the NAS-WR01ZE
(https://devices.zwave-js.io/?jumpTo=0x0258:0x0200:0x1027:2.32) smart plug is reported/displayed as a negative number.
After resetting the accumulated meter values, sane positive values are reported for sometime, but at some point it flips to negative.
zwavejs2mqtt.log:
2021-05-24 20:46:26.806 DEBUG SOCKET: Event ZWAVE_API emitted to FHb1fJMDSyU3lbGJAAAB
2021-05-24 20:46:26.808 INFO ZWAVE: Calling api refreshCCValues with args: [ 42, 50, [length]: 2 ]
2021-05-24 20:46:26.971 INFO ZWAVE: Node 42: value updated: 50-0-value-65537 -21474836.13 => -21474836.13
2021-05-24 20:46:27.120 INFO ZWAVE: Node 42: value updated: 50-0-value-66049 27.85 => 27.49
2021-05-24 20:46:27.266 INFO ZWAVE: Node 42: value updated: 50-0-value-66561 234.62 => 234.93
2021-05-24 20:46:27.410 INFO ZWAVE: Node 42: value updated: 50-0-value-66817 0.25 => 0.25
zwavejs.log:
2021-05-24T20:46:26.811Z CNTRLR » [Node 042] querying meter value (type = Electric, scale = kWh, rate type = Con
sumed)...
2021-05-24T20:46:26.975Z CNTRLR » [Node 042] querying meter value (type = Electric, scale = W, rate type = Consu
med)...
2021-05-24T20:46:27.123Z CNTRLR » [Node 042] querying meter value (type = Electric, scale = V, rate type = Consu
med)...
2021-05-24T20:46:27.268Z CNTRLR » [Node 042] querying meter value (type = Electric, scale = A, rate type = Consu
med)...
The negative value also gets picked up by Home Assistant.
To Reproduce
Let the device report for some time.
Expected behavior
A sane number being reported.
Additional context
I am unsure if this is a SW issue or a quirk with the device itself, since it looks like bit 31 is being flipped.
The screenshot below was made not too long after a reset of the accumulated values. If I take the negative number and flip bit 31 from 1 to 0, we get 35
, which would be 0.35
kWh I presume, and that would make sense given that a reset was done earlier.
This is happening on multiple of the same devices I own, not only a single one.
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 32 (13 by maintainers)
This may sound cynical but I disagree. It really should become a problem of the manufacturers who release these buggy devices and don’t offer any support whatsoever. The huge bunch of workarounds that other drivers implemented (some still do, see SmartThings) make it too easy for manufacturers to reject responsibility and claim “but it works in XYZ, cannot be our fault!”
I can understand the sentiment of making things work when you’re using unofficial APIs etc, but Z-Wave is a standard, devices have to be certified and these things still happen too much. Only when we stop solving the manufacturers’ mistakes for them and make them fix them, then we can get to a point where it becomes a benefit for the smart home community.
Unfortunately, I don’t have the power to make manufacturers do that, so all I can do here is stay strong and say “I will not fix this” (and neither should the other projects), even if it is annoying for users. In the end, the users have the power to make a change:
We can help with the latter - we recently added the ability to display comments in our device configuration DB, but it isn’t used much yet:
https://devices.zwave-js.io/?jumpTo=0x0258:0x0100:0x1027:0.0
Side note: I currently have devices from 3 large manufacturers. Of these 3, I’d only buy from one again and my DO-NOT-BUY list is growing rapidly just by looking at the issues that are reported here.
@heapxor That gist also mentions this in the top-level comment:
It seems to have deduced a correction factor of 0.26 which when multiplied with the original value of
18.48
results in4.8048
:I’ve created a Template Sensor that does corrective calculations on the values reported by NAS-WR01ZE devices:
https://gist.github.com/KloudJack/4489ffcbeae58b88072f391dca55b40d
I’ve been using this successfully with my power sockets until a firmware fix is released, not holding my breath though as this issue has been known for at least 2 years.
@robertsLando Can do what he likes
@AlCalzone, @blhoward2 I can fully understand and support these statements so zwave-js can keep its high quality and speed of development. Nevertheless there might be a better approach from a overall smart home architecture perspective than making it a problem of the users (either buy new devices or implementing workarounds that create much more and duplicated complexity on other parts of the smart home system (solving this using template sensors in HA for every affected entity is a huge code duplication mess and a nightmare to maintain). Wouldn’t it be possible to support a kind of layer or hooks to do some device-specific processing before passing the values on to the applications?
@robertsLando, wouldn’t the device values configuration of zwavejs2mqtt already allow something like this? But I’m not sure, if this helps, if e.g. Home Assistent is connected directoly to the zwave-js server port of zwavejs2mqtt.
If not, maybe providing something like that as part of the zwave-js server but on top of the zwave-js driver would solve the need (not only to fix device bugs but also to do some other useful pre-processing or conversion of data) while keeping the the concerns of clearly separated from the core. Maybe the device configuration could be extended to provide device-specific implementations for hooks that are called by the driver or server.
Since I don’t know enough about the (existing or still to be created) possibilities on the driver/server level I’d like to hear your opinion on that.
Fair enough, I’ll work around it in SW on my local HA overlay. I have little hope to see FW updates for such budget devices, but lets see (the first of the two support email addresses already replied my email wasn’t delivered because the inbox quota was full 😅 )