Skip to content

Add cable lock/unlock support for socket-connector charging stations - #297

Merged
myny-git merged 1 commit into
myny-git:mainfrom
michielvancauwenberghe:feature/cable-lock
Sep 17, 2026
Merged

myny-git merged 1 commit into
myny-git:mainfrom
michielvancauwenberghe:feature/cable-lock

Conversation

@michielvancauwenberghe

@michielvancauwenberghe michielvancauwenberghe commented Sep 12, 2026 •

Copy link
Copy Markdown

Summary

  • Adds a lock entity to control the charging cable lock on stations with a socket connector, using the Dashboard v11 cableLocked property (PATCH /v11/chargingstations/{serial}), verified against a real dashboard capture.
  • Mirrors the existing availability/offline-charging switch pattern: optimistic update with revert on failure, auth-error propagation, and a scheduled dashboard refresh after a write.
  • Since this feature is documented by Smappee only for "socket version" stations (not fixed-cable models) and there's no reliable way to distinguish hardware by model name alone, the entity reports as unavailable unless the Dashboard API has actually reported a cableLocked value for that station.

Changes

  • custom_components/smappee_ev/lock.py (new): SmappeeCableLock entity.
  • custom_components/smappee_ev/api/dashboard_client.py: async_set_cable_lock.
  • custom_components/smappee_ev/api/device_handle.py: set_cable_locked / set_cable_unlocked.
  • custom_components/smappee_ev/coordinators/dashboard_merge.py: parse cableLocked from station details into StationState.cable_locked.
  • custom_components/smappee_ev/models/state.py: new cable_locked field.
  • custom_components/smappee_ev/__init__.py: register Platform.LOCK.
  • Translations (strings.json, translations/{en,nl,fr,de}.json).
  • Docs: README.md, docs/HA_integration.md.
  • Tests: tests/test_lock.py (new), plus additions to test_dashboard_client.py, test_device_handle.py, test_coordinator.py.

Test plan

  • pytest (full suite, 917 passed)
  • ruff check / ruff format --check
  • pre-commit run --all-files (ruff, codespell, mypy all pass)

🤖 Generated with Claude Code

Expose a lock entity backed by the Dashboard v11 cableLocked property
(PATCH /v11/chargingstations/{serial}), mirroring the existing
availability/offline-charging switches. The entity is only marked
available when the Dashboard API actually reports a cableLocked value,
since this feature only applies to socket-connector stations and not
fixed-cable models.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@michielvancauwenberghe
michielvancauwenberghe marked this pull request as ready for review September 12, 2026 10:44
@myny-git

Copy link
Copy Markdown
Owner

Hi, thanks for this ... can you share a few screenshots where in the Dashboard we see this? I believe I do not have this, since I have a permanent locked cable.
Before merging, could you confirm that the v10 station-details GET response returns cableLocked correctly in both states, including after reloading the integration?

@michielvancauwenberghe

michielvancauwenberghe commented Sep 15, 2026 •

Copy link
Copy Markdown
Author

Hi,
I have gathered the following screenshots from my smappee dashboard (with some redactions):

Screenshot 2026-09-15 112127

The api call:

Screenshot 2026-09-15 113452 Screenshot 2026-09-15 112536

My charger is a Smappee One, which does allow to let the cable be locked.

I have created the branch and 'vibe coded' all the code, since I don't have any experience with python or Smappee integrations, so I didn't test it locally...

@michielvancauwenberghe

Copy link
Copy Markdown
Author

I updated the code locally on my Hass instance to test and seems to work at first glance. Updating the state from Hass updates my Smappee dashboard.
Screenshot 2026-09-15 182755

When I update the state from the Smappee dashboard however, I don't see the integration in Hass. Is that a problem with my implementation or expected behaviour?

@myny-git
myny-git merged commit 309a74e into myny-git:main Sep 17, 2026
9 checks passed
@myny-git

Copy link
Copy Markdown
Owner

The reason why you do not see things, is that the refresh of the Dashboard only occurs every 30 mins. It can be faster, if this change is also visible in the mqtt response.

@myny-git

Copy link
Copy Markdown
Owner

Please test the pre-release version.

@michielvancauwenberghe

Copy link
Copy Markdown
Author

Hi,
I have installed and validated the pre-release build and everything seems to work as expected. Thanks for merging! If you do have any problems in the future, I'll happily give you a hand with debugging or validation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants