ebaauw / homebridge-p1

Homebridge plugin for DSMR end-consumer (P1) interface
Apache License 2.0
53 stars 11 forks source link

Eve history crash: `RangeError: The value of "value" is out of range. It must be >= 32768 and <32676. Received 35940` #70

Closed wimleers closed 1 year ago

wimleers commented 1 year ago

This plugin has been working wonderfully. The Eve history charts are super valuable. They still work great for Electricity Delivered and Gas, but my Electricity suddenly stopped working yesterday!

9B2A6426-9952-4FC5-AAF1-0B28CA6BECC1

Then I was able to screenshot this, the actual error: 😨

A990EE60-4C2D-44E5-8D7F-533A777A55F9

RangeError: The value of "value" is out of range. It must be >= 32768 and <32676. Received 35940

Happy to provide you with a dump of anything you need. Happy to investigate myself if you can give pointers 😊

wimleers commented 1 year ago

P.S.: I just posted a very detailed response to your questions on the PR — which you merged while I was working on it, so I'm now worried you won't see it 😅 https://github.com/ebaauw/homebridge-p1/pull/69#issuecomment-1425648028

ebaauw commented 1 year ago

The value should have been treated as an unsigned int, so it can handle values up to 65535, see https://github.com/ebaauw/homebridge-lib/commit/4a1ddf006b876fe129ca69fd175d6b1311bce8c4.

I am a bit worried about the history value of 35940. This would indicate that you consumed 3596 Wh or 3.5940 kWh since the previous history entry (presumably 10 minutes ago). Was the P1 cable disconnected, causing consumption to be added over multiple 10-min periods?

wimleers commented 1 year ago

As written at https://github.com/ebaauw/homebridge-p1/pull/69#issuecomment-1427000431:

git cloned https://github.com/ebaauw/homebridge-p1/commit/e07fc82b69da3b0f48562ee47d4296ec5d177397 and npm linked it.

That still resulted in this:

[2/13/2023, 12:21:41 PM] [P1] Electricity History: History Entries: error: RangeError: The value of "value" is out of range. It must be >= -32768 and <= 32767. Received 35940
    at new NodeError (node:internal/errors:399:5)
    at checkInt (node:internal/buffer:74:11)
    at writeU_Int16LE (node:internal/buffer:724:3)
    at Buffer.writeInt16LE (node:internal/buffer:867:10)
    at ConsumptionValue.writeEntry (/Users/admin/Desktop/homebridge-p1/node_modules/homebridge-lib/lib/ServiceDelegate/History.js:79:47)
    at History.entryToBuffer (/Users/admin/Desktop/homebridge-p1/node_modules/homebridge-lib/lib/ServiceDelegate/History.js:602:19)
    at History._onGetEntries (/Users/admin/Desktop/homebridge-p1/node_modules/homebridge-lib/lib/ServiceDelegate/History.js:687:24)
    at CharacteristicDelegate._onGet (/Users/admin/Desktop/homebridge-p1/node_modules/homebridge-lib/lib/CharacteristicDelegate.js:353:26)
    at Characteristic.emit (node:events:513:28)
    at /usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/src/lib/Characteristic.ts:2463:14
[2/13/2023, 12:21:42 PM] [P1] Electricity History: History Entries: error: RangeError: The value of "value" is out of range. It must be >= -32768 and <= 32767. Received 35940
    at new NodeError (node:internal/errors:399:5)
    at checkInt (node:internal/buffer:74:11)
    at writeU_Int16LE (node:internal/buffer:724:3)
    at Buffer.writeInt16LE (node:internal/buffer:867:10)
    at ConsumptionValue.writeEntry (/Users/admin/Desktop/homebridge-p1/node_modules/homebridge-lib/lib/ServiceDelegate/History.js:79:47)
    at History.entryToBuffer (/Users/admin/Desktop/homebridge-p1/node_modules/homebridge-lib/lib/ServiceDelegate/History.js:602:19)
    at History._onGetEntries (/Users/admin/Desktop/homebridge-p1/node_modules/homebridge-lib/lib/ServiceDelegate/History.js:687:24)
    at CharacteristicDelegate._onGet (/Users/admin/Desktop/homebridge-p1/node_modules/homebridge-lib/lib/CharacteristicDelegate.js:353:26)
    at Characteristic.emit (node:events:513:28)
    at /usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/src/lib/Characteristic.ts:2463:14

Updating to 1.3.3-0 resolved this and allowed the Eve history to finish loading:

Screenshot 2023-02-13 at 12 26 14
ebaauw commented 1 year ago

Updating to 1.3.3-0 resolved this and allowed the Eve history to finish loading:

Yeah, I think (hope), I finally tamed the history for Total Consumption. Also, I’m now simply ignoring the invalid value (after issuing a warning message), and continue with the next entry.

ebaauw commented 1 year ago

Published v1.3.3.

wimleers commented 1 year ago

This has been reliably ever since updating 1.3.3-0! 🥳 Closing 😊