Hi Elliot,
Thanks — both of these were spot on, and both are fixed in 1.0.158. One correction on where the first one actually came from.
1. The disconnect — it wasn’t the phase parser
Reasonable inference, but the numbers point elsewhere. _parsePhase has a length guard (if (buf.length < 7) return null) and only does one bounds-checked read, at fixed offset 0. Everything after that is plain index access, which yields undefined rather than throwing.
I reproduced the exact message instead:
readUInt32BE(8) on a 10-byte buffer
→ "The value of 'offset' is out of range. It must be >= 0 and <= 6. Received 8"
Byte-for-byte identical to your log. That call is in tuyapi’s message-parser.js:148, reading the command byte out of the packet header — so what arrived was a truncated 10-byte TCP frame, not a short phase payload. Which fits your observation that it happened while the charger was idle and wasn’t tied to any DP value.
The real bug was on my side though: the app’s error handler didn’t recognise parse errors, so it treated them as fatal and tore down the connection. A single malformed frame shouldn’t do that — the socket was fine. Parse errors now join the exemptions I already had for error 904, error 900 and status timeouts: logged, connection kept. That applies to all drivers, not just chargers.
2. Session energy glitch — guard implemented as you suggested
Implemented essentially your formula:
ceiling = current_max × voltage × phases × elapsed_time × 1.25 + 0.5 kWh
The 1.25 absorbs mains above nominal, the 0.5 kWh keeps short poll intervals from producing an absurdly tight bound.
Against your case: a 38.8 kWh jump roughly 30 seconds after the previous reading, versus a ceiling of about 0.54 kWh → rejected, logged, lifetime total untouched.
I checked it doesn’t eat legitimate readings:
| Case |
Result |
| 1.8 kWh over 30 min at 3.7 kW |
accepted |
| 29 kWh after Homey was offline 8 h mid-charge |
accepted |
| 10 kWh over 30 min, 22 kW three-phase |
accepted |
| first reading after a restart |
accepted (no baseline to judge against) |
| your 38.8 kWh in 30 s |
rejected |
The ceiling scales off the configured current limit and phase count, so it adapts per device.
One thing it can’t do is repair the damage already done — your total is still carrying that bad session. The Reset energy meter flow action zeroes it, and it rebuilds cleanly from there.
While I’m at it — unrelated, but worth checking on your unit
If your cumulative total looks stuck generally: chargers paired before 1.0.147 still have Session Energy DP set to 25. On this hardware DP 25 holds the previous session and doesn’t move during a charge; the counter that actually climbs is DP 1. Homey doesn’t apply changed defaults to existing devices, so it needs changing by hand once. As of 1.0.157 the log now points this out when it spots an unmapped DP counting up.
Thanks again — the raw DP dump and the detail about the two restart blips is exactly what made both of these diagnosable.
Andi