Fix Grizzl-E Duo port 2 current/voltage/power reporting (#23) - #33
Open
stopsign002 wants to merge 2 commits into
Open
Fix Grizzl-E Duo port 2 current/voltage/power reporting (#23)#33stopsign002 wants to merge 2 commits into
stopsign002 wants to merge 2 commits into
Conversation
The Duo does not report its second cable through curMeas2/voltMeas2 (those are per-phase fields that stay 0 on a single-phase unit). Cable 2 current comes from curMeas1C2, voltage from the shared voltMeas1, and power from powerMeas2, with state2/pilot2/sessionTime2/... for the rest. Add a port_key() mapping helper and make all per-cable sensors (power, current, voltage, session energy/time/money, total energy, state, pilot) and binary sensors (session started, pilot connected) port-aware. Port 1 keeps its original unique_ids so existing single-port history is retained; port 2+ get disambiguated ids. Enum sensors no longer carry an invalid measurement state class. Includes regression tests built from the real Duo payloads in issue mclare#23. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01KChaxBZUB3nMtU3LFERsrH
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #23.
Problem
On the Grizzl-E Duo, selecting 2 ports produced a second port with no current/voltage/power. The integration assumed cable 2 lived in
curMeas2/voltMeas2, but on the Duo those are per-phase fields that stay0on a single-phase unit. From the real/mainpayloads in #23, cable 2 is actually reported through:curMeas1C2(curMeas2is always 0)voltMeas1(both cables share one circuit, so voltage is only reported once)powerMeas2state2,pilot2,sessionTime2,sessionEnergy2,sessionMoney2,totalEnergy2,sessionStarted2Separately, only Current/Voltage were ever created per-port; Power, Session/Total Energy, State, etc. were cable-1 only, so cable 2 had no power/energy tracking at all.
Fix
port_key(field, port)helper inconst.pythat resolves each logical per-cable measurement to the correct JSON key for a given port (and generalizes thecurMeas1C{n}pattern to a hypothetical 3rd cable).unique_ids, so existing single-port installs retain their history. Port 2+ get disambiguated ids (needed because both cables sharevoltMeas1).measurementstate class.Tests
Added
tests/test_ports.pywith regression cases built from the exact Duo payloads posted in #23 (charging on cable 1 only, cable 2 only, and both at once).Verified
Confirmed working on a real Grizzl-E Duo (GRD 40A 2025, FW GRD077L-01.09.5): port 2 now reports live current, voltage, and power.
🤖 Generated with Claude Code