Conversation
b67858c to
9d629b7
Compare
|
An interesting ramification of these changes is that different types of EVSEs may have different voltages -- the canonical example being a Gen2 TWC on 240V 80A and a UMC on 120V 15A. With a diversity of voltages in play, I think it may make more sense to convert all the core calculations to working in watts and convert to amps just before sending them into the calls that require amperage as the input. That's going to flow back through various other parts of the system (and probably break stuff). |
|
Feature-complete but bug-ridden. Here are the things it does and doesn't do, and the known bugs:
Overall, I think I'd like to see us drop a 1.2.7 release with any other features we'd like to ship first, then make this the base of a 1.3 or 2.0 release. This is going to need some testing in a variety of setups before it's ready for broad use. |
24a28de to
dac28d4
Compare
Establishes the interface contract for the TWC abstraction layer. EVSEInstance defines the unified charging-point interface (ID, isCharging, wantsToCharge, currentPower/Voltage, min/maxPower, setTargetPower, start/stopCharging, amps↔watts helpers). EVSEController defines the controller interface (allEVSEs, maxPower, start/stopAllCharging, stop). Architectural design ported from #483 (MikeBishop). No existing code modified — purely additive. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Gen2TWC extends both TWCSlave (RS485 protocol behaviour) and EVSEInstance (unified charging-point interface), adding: ID, isReadOnly, isLocal, isCharging/currentVIN as properties with setters (to preserve compatibility with existing assignment sites in TWCSlave), wantsToCharge, currentAmps, currentVoltage, currentPower, minPower, maxPower, controllers, and stub setTargetPower/startCharging/stopCharging (full watt-based implementation deferred to Phase 4). TWCMaster now instantiates Gen2TWC in newSlave() rather than TWCSlave directly; all existing code continues to work because Gen2TWC is a strict superset of TWCSlave. Ported from #483 (MikeBishop). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
… TWCMaster Phase 3 of the TWC abstraction (#483, MikeBishop): - EVSEController/Gen2TWCs: exposes existing TWCMaster slave registry through the EVSEController interface; maxPower derived from wiring config - EVSEController/TeslaAPIController: discovers vehicles at home via TeslaAPI and wraps each as a TeslaAPIEVSE; caches instances by VIN (fixes PR bug where allEVSEs created new objects on every access, discarding state) - EVSEInstance/TeslaAPIEVSE: EVSEInstance wrapper for a TeslaAPI vehicle; routes setTargetPower→setChargeRate, start/stop→master background tasks - EVSEInstance/MergedEVSE: deduplicating proxy for vehicles visible through multiple controllers; routes control via chargeRateControl/chargeStopMode settings; fixes PR bug where zip(*[]) produced [] instead of [0,0,0] on empty EVSE list - TWCMaster: auto-registers Gen2TWCs on init; adds getAllEVSEs() (aggregates all EVSEController instances) and getDedupedEVSEs() (merges by VIN) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Completes the TWC abstraction port from #483 (MikeBishop). TWCSlave.send_master_heartbeat: when Gen2TWC._evseTargetAmps is set by the centralized distributor, use it directly instead of recomputing the per-car fair-share (lines 700-728). All downstream logic — 6A spike workaround, dampen timer, protocol send — still applies unchanged. Gen2TWC.setTargetPower: converts watts→amps and sets _evseTargetAmps (+ lastAmpsDesired for backward compat/logging). TWCMaster.distributeEVSEPower: fair-share watt-based algorithm across all deduplicated EVSEs. Activates only when TeslaAPIController is registered (pure Gen2 deployments continue using the existing per-slave heartbeat distribution unchanged). Sorts EVSEs by maxPower (most constrained first), respects per-controller budgets, enforces per-EVSE minimums. TWCManager: auto-registers TeslaAPIController after module load when TeslaAPI is present; calls master.distributeEVSEPower() once per round-robin cycle (idxSlaveToSendNextHeartbeat == 0) before the RS485 heartbeats are sent. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Credits @MikeBishop for the EVSEController/EVSEInstance architecture from #483. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
Hi @MikeBishop, TWC abstraction has been ported into main (which is now 1.4.0 - I have moved the upcoming 1.3.4 release off to a separate release branch). I know you've spent a long time working on it, and whilst it's very much overdue for me to get to the point that we could merge it, it's also timely with the TWCv3 emulation (via Neurio emulation) context that @RichieB2B shared recently |
This is the first step toward making Gen2 TWCs just another module and supporting other charge controllers alongside them. At this point, it's pure code rearrangement -- functionality should be identical. Testing to ensure I haven't broken anything -- particularly modes I don't use, like
fakeMaster: 0-- would be appreciated.Before merging, I want to:
Long term, I'd also like to support read-only charge controllers, such as TWCs connected to a second TWCManager instance. Their data can be considered when making charge policy decisions, even if it can't be affected locally.