Jérôme Benoit [Wed, 18 Mar 2026 15:03:31 +0000 (16:03 +0100)]
refactor(ocpp): use buildStatusNotificationRequest helper in TriggerMessage handlers
Replace inline StatusNotification payload construction in both OCPP 1.6
and 2.0 TriggerMessage handlers with the centralized
buildStatusNotificationRequest helper. Export the helper from
OCPPServiceUtils to make it available.
This eliminates 5 inline duplications of the same payload structure
that risked diverging from the single source of truth.
Jérôme Benoit [Wed, 18 Mar 2026 14:49:05 +0000 (15:49 +0100)]
refactor(ocpp): harmonize buildRequestPayload switch structure across versions
Group passthrough cases into fall-through blocks in both OCPP 1.6 and
2.0 buildRequestPayload, giving both files a symmetric structure:
grouped passthroughs, heartbeat empty object, enrichment cases, default
error.
Jérôme Benoit [Wed, 18 Mar 2026 14:35:41 +0000 (15:35 +0100)]
fix(ocpp2): revert UI transaction handlers to simple passthrough
Remove handleUIStartTransaction and handleUIStopTransaction which
duplicated connector state management with incomplete initialization
(missing energy register, groupIdToken, StatusNotification, error
rollback) and bypassed authorization checks.
Restore handleTransactionEvent as a simple requestHandler passthrough,
consistent with all other broadcast channel command handlers.
Call OCPP20ServiceUtils.getTxUpdatedInterval() directly from
OCPP20IncomingRequestService instead of through a trivial private
wrapper that was left over from the centralization in PR #1734.
Jérôme Benoit [Wed, 18 Mar 2026 14:16:54 +0000 (15:16 +0100)]
refactor(ocpp2): consolidate dual-path request architecture into single path
Remove 8 unused dedicated request methods (requestFirmwareStatusNotification,
requestGet15118EVCertificate, requestGetCertificateStatus, etc.) that bypassed
buildRequestPayload via direct sendMessage calls. All production callers
already used requestHandler exclusively, making these methods dead code.
Move SignCertificate CSR generation logic into buildRequestPayload, making
it the authoritative payload construction layer — symmetric with OCPP 1.6.
This also adds isRequestCommandSupported check and AJV schema validation
to the SignCertificate flow that the dedicated method bypassed.
Refactor 6 test files to test through requestHandler (production path)
instead of the removed dedicated methods.
Jérôme Benoit [Wed, 18 Mar 2026 13:44:59 +0000 (14:44 +0100)]
refactor(ocpp2): centralize payload construction and eliminate duplication
Remove redundant timestamp injection from buildRequestPayload() for
StatusNotification and TransactionEvent — centralized builders already
provide timestamps and AJV schema validation catches any omission.
Extract buildStationInfoReportData() helper to deduplicate station info
report data construction between FullInventory and SummaryInventory in
buildReportData().
Normalize TriggerMessage Heartbeat to use OCPP20Constants.OCPP_RESPONSE_EMPTY
for consistency with buildRequestPayload().
- Update ConnectorStatus.transactionId to support both number (OCPP 1.6)
and string/UUID (OCPP 2.0.x)
Wave 1 complete.
* feat(ui): add UIClient transaction methods with OCPP version support
- Add transactionEvent() method for OCPP 2.0.x TransactionEvent requests
- Add isOCPP20x() static helper for version detection
- Add startTransactionForVersion() helper that routes to appropriate
method based on OCPP version (1.6 vs 2.0.x)
- Add stopTransactionForVersion() helper for version-aware stop
- Add comprehensive unit tests (16 tests passing)
Wave 2 complete.
* feat(ui): add version-aware StartTransaction form with OCPP 2.0.x support
- Modify StartTransaction.vue to detect OCPP version from station info
- Show connector ID for OCPP 1.6, EVSE ID input for OCPP 2.0.x
- Hide Authorize checkbox for OCPP 2.0.x stations (v-if)
- Use startTransactionForVersion() helper for version-aware API calls
- Add loading state while fetching station info
- Show appropriate form fields based on OCPP version
- All 16 tests passing
Wave 3 complete.
* fix(webui): use enums instead of string literals for OCPP 2.0.x types
- Replace 'ISO14443' string with OCPP20IdTokenEnumType.ISO14443
- Fix test mocks to use Protocol.UI and ResponseStatus.SUCCESS enums
- Export OCPP20IdTokenEnumType from types index
* style(webui): fix import ordering in UIClient.ts
* [autofix.ci] apply automated fixes
* chore: remove tsbuildinfo and add to gitignore
* fix(webui): address PR review comments
- Add ResponseStatus import and use enum instead of string
- Use UIClient.isOCPP20x() helper instead of manual comparison
- Remove redundant showAuthorize computed, use !isOCPP20x directly
- Separate error handling for authorize vs startTransaction
- Add validation for transactionId type in stopTransactionForVersion
* [autofix.ci] apply automated fixes
* chore: move tsbuildinfo gitignore to ui/web subdirectory
- Remove *.tsbuildinfo from root .gitignore
- Add *.tsbuildinfo to ui/web/.gitignore with proper comment
* ci(webui): add TypeScript type checking to CI
- Add vue-tsc dev dependency to ui/web
- Add typecheck script to package.json
- Add typecheck step to build-dashboard job in CI
* fix(webui): fix vue-tsc typecheck and improve Vue.js best practices
- Break recursive JsonObject/JsonType chain causing TS2589 in vue-tsc
- Fix CSConnector to use stopTransactionForVersion with ocppVersion prop
- Replace getCurrentInstance() anti-pattern with useToast()/useRouter()
- Make isOCPP20x a computed instead of manually-synced ref
- Deduplicate handleStartTransaction (remove ~30 lines of duplication)
- Add null guards for watch() on potentially undefined global refs
* [autofix.ci] apply automated fixes
* refactor(webui): align namespace with simulator and improve API design
- Merge startTransactionForVersion/stopTransactionForVersion into
startTransaction/stopTransaction with optional ocppVersion param
- Make transactionEvent private (implementation detail, not public API)
- Revert UITransactionEventPayload to OCPP20TransactionEventRequest
to match backend naming convention
- Pass ocppVersion via route param instead of re-fetching all stations
- Remove convertToBoolean no-op and loading state
- Flip negated v-if condition for SonarCloud compliance
- Factor test setup, remove duplicate coverage, add missing test case
- Net result: -90 lines, cleaner API surface
* [autofix.ci] apply automated fixes
* refactor(webui): move tests from __tests__ to tests/unit for consistency
Align test file location with existing project convention (tests/unit/)
instead of Jest-style __tests__ directory.
* feat(webui): integrate OCPP 2.0 EVSE 3-tier model across web UI
- Add OCPP20EVSEType matching spec EVSEType {id, connectorId?}
- Replace flat evseId with proper evse object in TransactionEventRequest
- CSData: preserve EVSE→Connector mapping instead of flattening
- CSConnector: display 'evseId/connectorId' for OCPP 2.0 stations
- Route: pass evseId and ocppVersion as query params (not sentinels)
- StartTransaction: read EVSE context from query, display EVSE/Connector
- UIClient.startTransaction: accept evseId, build spec-compliant evse object
- Tests: exhaustive decision tree coverage (18 tests, all branches)
* [autofix.ci] apply automated fixes
* refactor(webui): improve API elegance and fix cross-version concerns
- Refactor startTransaction/stopTransaction to use named options object
instead of positional params for better readability and grouping
- Fix ToggleButton ID collision: include evseId for multi-EVSE uniqueness
- Normalize idTag validation as cross-version concern (empty→undefined)
- Rename getConnectorStatuses→getConnectorEntries to match semantics
- Extract toggleButtonId as computed to avoid string duplication
* feat: entry-based serialization for EVSE/Connector/ATG data
Introduce ConnectorEntry, EvseEntry, and ATGStatusEntry types at the
UI serialization boundary to preserve Map keys (evseId, connectorId)
that were previously lost during Map-to-Array conversion.
Backend:
- Add buildConnectorEntries/buildEvseEntries using .entries()
- Keep buildConnectorsStatus/buildEvsesStatus unchanged for config persistence
- Remove EvseStatusWorkerType and OutputFormat enum
- ATG statuses serialized with connectorId at the UI boundary only
- ConnectorStatus and EvseStatus types remain pure (no identity fields)
Frontend:
- CSData uses explicit IDs from Entry types (no more index-based mapping)
- ATG status lookup by connectorId instead of array index
- Filter connector 0 in both OCPP 1.6 and 2.0 paths
- Both connectors and evses optional in ChargingStationData
* [autofix.ci] apply automated fixes
* fix(webui): use data presence instead of protocol version for EVSE display
EVSE/Connector display depends on whether the station has EVSEs (data),
not on the OCPP version (protocol). A station could use EVSEs regardless
of OCPP version.
* refactor: extract buildATGStatusEntries for consistent Entry builder pattern
Align ATG status serialization with ConnectorEntry/EvseEntry pattern:
dedicated builder function instead of inline transformation.
* refactor: harmonize Entry naming pattern across codebase
Rename ATGStatusEntry/buildATGStatusEntries to ATGEntry/buildATGEntries
to match ConnectorEntry/EvseEntry naming convention.
* refactor: define ATGConfiguration type and harmonize across workspaces
Extract inline ATG type into named ATGConfiguration interface, matching
the ATG*/Connector*/Evse* Entry pattern in both backend and frontend.
* test: add missing Entry builder tests and non-sequential ID coverage
- Add buildATGEntries tests (entries with IDs, non-sequential, no ATG, no status)
- Add non-sequential connector ID test for buildConnectorEntries (keys 0,3,7)
- Add non-sequential evseId/connectorId test for buildEvseEntries (3/2,5)
- These tests verify the core invariant of the Entry pattern: Map keys are
preserved regardless of their sequence
* refactor: organize tests by concern and replace throw with graceful failure
- Group backend tests: config persistence builders then UI Entry builders
- Replace throw Error in stopTransaction with ResponsePayload FAILURE
to avoid unhandled rejections in UI components
* docs: harmonize quality gate ordering (typecheck before lint) across codebase
Align CI workflows, READMEs, and copilot-instructions to consistently
run typecheck before lint in all three sub-projects.
* refactor(ocpp2): centralize TransactionEvent payload building
- requestStopTransaction delegates to sendTransactionEvent instead of
building the OCPP payload inline, eliminating duplication
- All TransactionEvent paths now converge through sendTransactionEvent
→ buildTransactionEvent as the single payload construction point
- handleTransactionEvent (UI) dispatches Started/Ended to proper flows
with connector state initialization and lifecycle management
- Remove unused imports (secondsToMilliseconds, Constants)
Jérôme Benoit [Tue, 17 Mar 2026 12:21:30 +0000 (13:21 +0100)]
fix(ocpp2): use convertToDate() for all incoming date fields in handlers
Replace raw new Date(string) and direct string comparisons with
convertToDate() for date fields in incoming OCPP 2.0 payloads:
- validateChargingProfile: validFrom/validTo comparisons
- validateChargingSchedule: startSchedule comparisons
- simulateFirmwareUpdateLifecycle: retrieveDateTime/installDateTime
- handleResponseHeartbeat: currentTime display
- OCPP20CertificateManager: cert.validFrom/validTo validation
Jérôme Benoit [Mon, 16 Mar 2026 23:02:44 +0000 (00:02 +0100)]
ci: move coverage/lint/typecheck/sonar pipeline from Node 22.x to 24.x
Node 22 --experimental-test-coverage has known bugs (nodejs/node#55510)
that cause false CI failures. Move all gated steps (coverage, lint,
typecheck, SonarCloud, dependency review) to Node 24.x. Node 22 remains
in the test matrix for regular pnpm test runs.
Jérôme Benoit [Mon, 16 Mar 2026 21:56:52 +0000 (22:56 +0100)]
fix(tests): add second flushMicrotasks for RequestStopTransaction listener
The async chain in requestStopTransaction traverses a dynamic import()
in checkConnectorStatusTransition (OCPPServiceUtils), which may resolve
after the first setImmediate on macOS + Node 22. A second flush ensures
the StatusNotification call completes before the assertion.
Jérôme Benoit [Mon, 16 Mar 2026 21:56:52 +0000 (22:56 +0100)]
fix(tests): add second flushMicrotasks for RequestStopTransaction listener
The async chain in requestStopTransaction traverses a dynamic import()
in checkConnectorStatusTransition (OCPPServiceUtils), which may resolve
after the first setImmediate on macOS + Node 22. A second flush ensures
the StatusNotification call completes before the assertion.
Jérôme Benoit [Mon, 16 Mar 2026 21:36:24 +0000 (22:36 +0100)]
test: harmonize event listener test pattern across OCPP command test files (#1730)
* test: harmonize event listener test pattern across OCPP command test files
Add event listener test sections to 7 OCPP incoming request command test
files (4 OCPP 1.6, 3 OCPP 2.0) following the reference pattern from
RequestStopTransaction, TriggerMessage, UpdateFirmware, and GetLog tests.
Each listener section contains: registration test, accepted-fires test,
rejected-not-fires test, and error-graceful test.
Also restructures CustomerInformation to wrap existing listener tests in a
properly named describe block, and adds createOCPP16ListenerStation helper
to OCPP16TestUtils.ts.
- Extract createOCPP20ListenerStation to OCPP20TestUtils.ts, removing
duplication between RequestStart and RequestStop test files
- Replace inline import('node:test').mock.fn with top-level mock import
in RemoteStartTransaction tests
- Remove redundant mock.reset() from 3 listener afterEach blocks —
standardCleanup() already calls mock.restoreAll()
- Replace all await Promise.resolve() with flushMicrotasks() across 5
OCPP 2.0 test files for more robust async side-effect flushing
* fix(tests): replace remaining await Promise.resolve() with flushMicrotasks()
8 occurrences in 5 files (3 OCPP16, 2 OCPP20) missed in the initial
review fix. Now all listener tests use flushMicrotasks() consistently.
- Fix import paths in 7 OCPP 2.0 test files: ../../../../tests/helpers/
→ ../../../helpers/ (correct relative path, consistent with 35 sibling
files in the same directory)
- Add eventType assertion in RequestStartTransaction listener test to
verify TransactionEvent(Started) per E02.FR.01
- Add flushMicrotasks() to RequestStopTransaction listener test for
consistent emit→flush→assert pattern
* refactor(tests): move mock.method to beforeEach and parameterize trigger tests
- Move duplicated mock.method calls into listener beforeEach blocks
in 5 files (UpdateFirmware, GetLog, GetBaseReport, CustomerInfo,
Firmware). Rejection tests override inline. Net -147 lines.
- Parameterize OCPP16 + OCPP20 TriggerMessage trigger-fires tests
using data-driven triggerCases arrays (already done in prior commit,
this commit includes the Firmware mock cleanup).
* style(tests): remove inconsistent separator comment in RemoteStopUnlock
The listener section had a '// ───' separator not used in any of
the other 10 test files. The await describe block is sufficient.
* docs(tests): add summary line to startTransaction JSDoc
* docs(tests): add event listener testing section to TEST_STYLE_GUIDE
Add §11 documenting the established listener test pattern: emit()
direct, flushMicrotasks(), listenerCount first, accepted/rejected/error
triad, mock.method in beforeEach. Add listener station factories to
§9 mock factories table and flushMicrotasks to §10 utility table.
* docs(tests): fix incorrect mock API in §11 code example
Replace Jest-style mockImplementation() with Node.js test runner
mock.method() override pattern matching actual test code.
* fix(tests): align all 112 test files with TEST_STYLE_GUIDE
- Move @file JSDoc headers above first import in 3 files (GetVariables,
MessageChannelUtils, Utils)
- Replace await Promise.resolve() with flushMicrotasks() in
AutomaticTransactionGenerator
- Replace 6 setTimeout(resolve, 50) hacks with flushMicrotasks() in
ChargingStationWorkerBroadcastChannel
- Document spec traceability prefix exception (G03.FR.xx, G04.INT.xx)
in TEST_STYLE_GUIDE §1 naming conventions
* docs(tests): align TEST_STYLE_GUIDE with actual test infrastructure
- Fix createMockChargingStation location (ChargingStationTestUtils →
helpers/StationHelpers)
- Add 7 widely-used factories to §9 table (10+ usages each)
- Remove unused expectAcceptedAuthorization from §9 auth table
- All locations verified against actual exports
- Core Principles: clarify assert.ok is for boolean/existence only
- §5: add missing quotes around glob in test script (matches package.json)
- §10: restore setupConnectorWithTransaction/clearConnectorTransaction
(27 usages across test suite — should not have been removed)
Jérôme Benoit [Mon, 16 Mar 2026 17:58:26 +0000 (18:58 +0100)]
refactor(tests): separate handler/listener tests and remove setTimeout hacks
Align TriggerMessage, UpdateFirmware, and GetLog test files with the
RequestStopTransaction reference pattern:
- Split into 'Handler validation' + 'event listener' describe groups
- Replace raw setTimeout delays with withMockTimers where needed
- Use emit() directly for listener tests (no wrapper helpers)
- Follows TEST_STYLE_GUIDE.md conventions
Jérôme Benoit [Mon, 16 Mar 2026 16:54:02 +0000 (17:54 +0100)]
refactor(ocpp): harmonize post-response event listener pattern across stacks
Move post-response logic from inline handler to event listeners:
- OCPP16 UpdateFirmware: fire-and-forget in handler → event listener
matching OCPP20 UpdateFirmware pattern
- OCPP20 RequestStopTransaction: await in handler → event listener
matching OCPP16 RemoteStopTransaction pattern
All commands with post-response behavior now use the same pattern:
handler validates and returns response, event listener performs
the async action after the response is sent to the CSMS.
Jérôme Benoit [Mon, 16 Mar 2026 16:28:14 +0000 (17:28 +0100)]
refactor(ocpp20): move TransactionEvent(Started) to event listener pattern
Move sendTransactionEvent(Started) and startTxUpdatedInterval from
inside handleRequestStartTransaction to a post-response event
listener in the constructor, matching the OCPP 1.6
RemoteStartTransaction pattern where the handler validates and
returns Accepted, then an event triggers the actual StartTransaction
message send.
Jérôme Benoit [Mon, 16 Mar 2026 15:54:52 +0000 (16:54 +0100)]
fix(ocpp): graceful OCPPError fallback instead of throw in buildMessageToSend
Replace defensive throw with OCPPError construction when messagePayload
is not an OCPPError instance. Uses InternalError code per OCPP-J §4.2.3.
Harmonizes with the ternary instanceof pattern used at L452/503 in the
same file for errorDetails extraction.
Jérôme Benoit [Mon, 16 Mar 2026 15:20:23 +0000 (16:20 +0100)]
fix(ocpp20): send actual MeterValues on trigger and block sessions during firmware update
- F06.FR.06: TriggerMessage for MeterValues now sends TransactionEvent(Updated)
with actual meter readings for each EVSE with active transactions instead
of hardcoded value: 0
- L01.FR.07: UpdateFirmware sets idle EVSE connectors to Unavailable when
AllowNewSessionsPendingFirmwareUpdate is absent or false, preventing new
sessions while waiting for active transactions to end before installing
Jérôme Benoit [Mon, 16 Mar 2026 14:58:06 +0000 (15:58 +0100)]
fix(ocpp20): send TransactionEvent(Started) on RequestStartTransaction (E02.FR.01)
The handler accepted remote start transactions without notifying the
CSMS via TransactionEvent. Per E02.FR.01, the CS SHALL send
TransactionEvent with eventType=Started when a transaction begins.
Also starts meter values interval for the new transaction.
Jérôme Benoit [Mon, 16 Mar 2026 13:09:55 +0000 (14:09 +0100)]
refactor(ocpp20): remove redundant lastFirmwareStatus from per-station state
lastFirmwareStatus in the WeakMap was a duplicate of
stationInfo.firmwareStatus (now written by sendFirmwareStatusNotification).
TriggerMessage now uses hasFirmwareUpdateInProgress() to determine
whether to send Idle or the current intermediate state, which also
fixes a bug where failure end states (DownloadFailed, InstallationFailed,
etc.) were returned instead of Idle.
Jérôme Benoit [Mon, 16 Mar 2026 12:36:04 +0000 (13:36 +0100)]
refactor: use union types consistently in common code and tests
- OCPPServiceUtils: use SampledValue union in generics, use
StatusNotificationRequest union in satisfies, remove unused
OCPP20StatusNotificationRequest import
- BroadcastChannel: use MeterValuesRequest/Response unions
- OCPPServiceUtils-validation.test: OCPP16MessageTrigger → MessageTrigger,
remove redundant casts
Jérôme Benoit [Mon, 16 Mar 2026 12:27:33 +0000 (13:27 +0100)]
refactor(ocpp): use union types in common code where possible
- OCPPServiceUtils: use SampledValue union in generic constraints
instead of inline OCPP16SampledValue | OCPP20SampledValue union;
use StatusNotificationRequest union in satisfies check
- BroadcastChannel: use MeterValuesRequest/Response unions instead
of OCPP20-specific types in version-dispatched handleMeterValues
Stack-specific types remain in version-switch branches where
TypeScript requires narrowed types for array push operations.
Jérôme Benoit [Mon, 16 Mar 2026 12:20:30 +0000 (13:20 +0100)]
refactor(tests): use union types instead of stack-specific types in common tests
Replace OCPP16RequestCommand → RequestCommand,
OCPP16IncomingRequestCommand → IncomingRequestCommand, and
OCPP20RequestCommand → RequestCommand in test files outside
stack-specific directories. Remove redundant 'as Type' casts
that were bridging the gap.
Jérôme Benoit [Mon, 16 Mar 2026 12:11:41 +0000 (13:11 +0100)]
refactor(ocpp20): prefix OperationalStatusEnumType with OCPP20
Last unprefixed OCPP 2.0 type participating in a common union.
OperationalStatusEnumType → OCPP20OperationalStatusEnumType
matching the OCPP16AvailabilityType counterpart in the
AvailabilityType union.
Jérôme Benoit [Mon, 16 Mar 2026 12:00:33 +0000 (13:00 +0100)]
refactor(ocpp20): prefix FirmwareStatusEnumType, extend FirmwareStatus union
- Rename FirmwareStatusEnumType → OCPP20FirmwareStatusEnumType per
existing OCPP16FirmwareStatus naming convention
- Extend FirmwareStatus union to include all OCPP 2.0.1 firmware states
- Extend FirmwareStatusNotificationRequest to union both versions
- Write firmwareStatus to stationInfo in sendFirmwareStatusNotification
fixing hasFirmwareUpdateInProgress which was always returning false
- Stack-specific code uses OCPP20FirmwareStatusEnumType, common code
uses generic FirmwareStatus union
Jérôme Benoit [Mon, 16 Mar 2026 00:20:36 +0000 (01:20 +0100)]
fix(ocpp16): reject float values for integer configuration keys per spec §5.3
Replace convertToInt (parseInt — silently truncates 3.7 to 3) with
Number.isInteger check. The spec §9.1 defines these keys as Type:
integer, and §5.3 requires Rejected for values that do not conform
to the expected format.
Jérôme Benoit [Sun, 15 Mar 2026 23:59:05 +0000 (00:59 +0100)]
fix(ocpp16): return Idle in TriggerMessage when not actively uploading/updating
Per spec §4.4/§7.24 and §4.5/§7.25, Idle SHALL only be sent via
TriggerMessage when not busy. The code was returning stale terminal
statuses (Uploaded, UploadFailed, Installed, etc.) instead of Idle.
- DiagnosticsStatusNotification: return Uploading only when actively
uploading, Idle otherwise (fixes stale Uploaded/UploadFailed)
- FirmwareStatusNotification: return Downloading/Downloaded/Installing
only when in progress, Idle otherwise (fixes stale Installed/Failed)
- UpdateFirmware guard: allow retry after DownloadFailed or
InstallationFailed instead of blocking all non-Installed statuses
Jérôme Benoit [Sun, 15 Mar 2026 23:13:20 +0000 (00:13 +0100)]
refactor: replace 54 unsafe error casts with instanceof guards
All 'error as Error', 'error as OCPPError', and 'error as
NodeJS.ErrnoException' casts replaced with proper instanceof
type narrowing across 16 files. Uses the pattern already
established in the auth strategies module:
error instanceof Error ? error.message : String(error)
For call sites that pass error objects to functions, wraps
non-Error values: error instanceof Error ? error : new Error(String(error))
Jérôme Benoit [Sun, 15 Mar 2026 22:57:20 +0000 (23:57 +0100)]
refactor(ocpp): extract responseHandler and incomingRequestHandler into base classes
Both methods were 95% identical across OCPP 1.6 and 2.0 subclasses
(~160 lines of pure duplication). Move the shared logic into the base
classes, parameterized by 3 abstract properties each subclass provides:
- bootNotificationRequestCommand / pendingStateBlockedCommands
- csmsName ('central system' vs 'CSMS')
- isRequestCommandSupported / isIncomingRequestCommandSupported
Zero behavior change — pure refactoring validated by 1853 passing tests.
Jérôme Benoit [Sun, 15 Mar 2026 22:37:22 +0000 (23:37 +0100)]
fix(ocpp): use per-subclass singleton map to prevent version collision
The singleton instance was stored as a single static field on the base
class. In mixed OCPP 1.6/2.0 workers, the first getInstance() call
wins — subsequent calls for a different version silently return the
wrong instance cast via 'as T'.
Replace with Map<Constructor, Instance> keyed by the concrete subclass
constructor. Each version now gets its own singleton entry. Zero
changes needed in subclasses or calling code.
Jérôme Benoit [Sun, 15 Mar 2026 22:24:20 +0000 (23:24 +0100)]
fix(charging-station): add try/finally guards to lifecycle methods
Prevent zombie state flags when exceptions occur:
- start(): wrap in try/finally to always reset starting=false
- stop(): wrap in try/finally to always reset stopping=false
- reset(): catch stop() failure and abort instead of proceeding
with sleep+start on a half-stopped station
- delete(): catch stop() failure so cleanup always proceeds
Jérôme Benoit [Sun, 15 Mar 2026 20:43:50 +0000 (21:43 +0100)]
chore(ocpp-server): migrate pyproject.toml to PEP 621 project metadata
Move name, version, description, authors, readme from deprecated
[tool.poetry.*] to [project.*] per PEP 621. Move dependencies from
[tool.poetry.dependencies] to [project.dependencies] with PEP 508
specifiers. Set requires-python to >=3.12,<4.0 to match ocpp package
constraint. Regenerate poetry.lock.
Jérôme Benoit [Sun, 15 Mar 2026 20:29:21 +0000 (21:29 +0100)]
fix(tests): remove stale optional chaining on now-required variableAttribute
ReportDataType.variableAttribute was made required in 429cdbe3 but
test files still used ?. and ?? [] on the field. The stale eslint
cache masked these errors locally; CI (no cache) correctly rejected.
Jérôme Benoit [Sun, 15 Mar 2026 20:16:10 +0000 (21:16 +0100)]
fix(ocpp20): implement proper M04.FR.06 guard via isChargingStationCertificateHash
The previous M04.FR.06 guard was ineffective: it called
getInstalledCertificates() which scans root cert directories and
maps types via mapInstallTypeToGetType(), which has no case for
ChargingStationCertificate (stored via CertificateSigned, not
InstallCertificate). The V2GCertificateChain filter never matched.
Add isChargingStationCertificateHash() to OCPP20CertificateManager
that directly scans the ChargingStationCertificate directory and
compares certificate hashes. Use it in handleRequestDeleteCertificate
for a reliable M04.FR.06 guard.
Jérôme Benoit [Sun, 15 Mar 2026 20:04:35 +0000 (21:04 +0100)]
fix(ocpp20): remediate 4 conformance findings from cross-audit
- M04.FR.06: Narrow DeleteCertificate guard to V2GCertificateChain type
only, allowing legitimate deletion of root certificates (CSMSRoot,
ManufacturerRoot, MORootCert, V2GRoot)
- B09.FR.05: Use InvalidConfSlot reasonCode per errata 2025-09 when
configurationSlot is not in NetworkConfigurationPriority list
- B09.FR.04/FR.31: Check AllowSecurityProfileDowngrade variable before
rejecting downgrades — allow 3→2 when true, never allow to profile 1
(errata 2025-09 §2.12)
- L01.FR.06: Wait for active transactions to end before commencing
firmware installation via polling loop in lifecycle simulation
Jérôme Benoit [Sun, 15 Mar 2026 19:22:37 +0000 (20:22 +0100)]
refactor(ocpp16): track diagnosticsStatus and extract composite schedule helper
- Add diagnosticsStatus to ChargingStationInfo, set at each
DiagnosticsStatusNotification send point (Uploading, Uploaded,
UploadFailed). TriggerMessage now reports actual diagnostics status
instead of hardcoded Idle, mirroring the firmwareStatus pattern.
- Extract composeCompositeSchedule() private method, eliminating
~120 lines of duplicated profile preparation logic between the
connectorId=0 and connectorId>0 branches of GetCompositeSchedule.
Jérôme Benoit [Sun, 15 Mar 2026 18:53:54 +0000 (19:53 +0100)]
fix(ocpp16): fix StopTransaction unit schema and ChargingSchedule field name
- Add missing 'Celsius' to StopTransaction.json unit enum (M-2/SP-1)
The runtime schema had only 'Celcius' (legacy typo) while the OCA
official schema has both. TS enum produces 'Celsius' which was
rejected by AJV when ocppStrictCompliance was enabled.
- Rename minChargeRate to minChargingRate in OCPP16ChargingSchedule (RST-01)
Field name typo caused JSON serialization mismatch with spec §7.13
and schema 'minChargingRate', breaking SetChargingProfile and
GetCompositeSchedule payloads.
Jérôme Benoit [Sun, 15 Mar 2026 18:23:00 +0000 (19:23 +0100)]
fix(ocpp20): clean up VariableManager mappings cache on station stop
invalidateMappingsCache was never called on station stop, leaking
invalidVariables and validatedStations entries for each stopped station.
Call it alongside resetRuntimeOverrides in stop() for complete cleanup.
Jérôme Benoit [Sun, 15 Mar 2026 18:19:07 +0000 (19:19 +0100)]
fix(ocpp20): isolate VariableManager overrides per station
runtimeOverrides, minSetOverrides, and maxSetOverrides were stored as flat
Maps on the singleton OCPP20VariableManager, causing SetVariables on one
station to affect all others sharing the same service instance.
Apply the same Map<stationId, Map<key, value>> pattern already used by
invalidVariables in the same class. resetRuntimeOverrides now accepts
optional stationId, matching the invalidateMappingsCache API.
Jérôme Benoit [Sun, 15 Mar 2026 18:04:39 +0000 (19:04 +0100)]
refactor(ocpp20): isolate per-station state with WeakMap instead of singleton properties
Per-station state (firmware update tracking, report cache, connector status
backup) was incorrectly stored as flat properties on the singleton
OCPP20IncomingRequestService, causing cross-station pollution when multiple
stations share the same service instance.
Introduce OCPP20PerStationState interface and a WeakMap<ChargingStation, ...>
to properly isolate state per station, matching the stateless service pattern
used by OCPP16IncomingRequestService. State is lazily initialized and
automatically garbage collected when the station is released.
Jérôme Benoit [Sat, 14 Mar 2026 22:46:56 +0000 (23:46 +0100)]
fix(renovate): enable Poetry dependency detection for OCPP2 mock server
Override :ignoreModulesAndTests preset to remove **/tests/** from
ignorePaths, allowing Renovate to discover tests/ocpp-server/pyproject.toml
and manage its Python/Poetry dependencies.
Jérôme Benoit [Sat, 14 Mar 2026 00:15:41 +0000 (01:15 +0100)]
docs: fix root README coherence with codebase
- Add missing NotifyCustomerInformation to OCPP 2.0.x section
- Add undocumented station template fields (iccid, imsi,
meterSerialNumberPrefix, meterType)
- List all available OCPP command procedure names in UI Protocol section
with separate OCPP 1.6 and 2.0.x lists
- Update copyright year to 2026 in README and LICENSE
Jérôme Benoit [Fri, 13 Mar 2026 21:08:30 +0000 (22:08 +0100)]
fix(ocpp-server): share charge_points set across connections and harden test quality
- Fix charge_points set created per-connection instead of shared across
all connections via ServerConfig
- Remove AuthConfig.__getitem__ dict-compat hack and isinstance(dict)
coercion branch from ChargePoint.__init__
- Migrate all test fixtures from raw dicts to AuthConfig instances
- Replace 11 weak 'assert X is not None' with typed assertions
(isinstance, enum equality)
- Hoist Action import to module level in test_server.py