Skip to content

feat: EV driver UI + lifecycle controls + creds visibility - #73

Merged
frahlg merged 2 commits into
masterfrom
claude/inspiring-clarke
Apr 16, 2026
Merged

frahlg merged 2 commits into
masterfrom
claude/inspiring-clarke

Conversation

@frahlg

@frahlg frahlg commented Apr 16, 2026

Copy link
Copy Markdown
Member

Summary

  • First-class EV driver rendering in the dashboard (Easee surfaces plug state, charging, session energy, reason for no current, cable lock, cloud status)
  • Per-driver Restart / Disable / Enable buttons + new /api/drivers/{name}/{restart,disable,enable} endpoints
  • Fix the silent password-reload bug: sameDriverConfig now compares the Config map, so credential changes actually restart the driver instead of being diffed away
  • "Credentials saved" visibility: badges in Settings + Devices tab, driven by ev_credentials_saved + per-driver has_password (populated by MaskSecrets)
  • Instant model panel expand — no longer waits up to 3 s for the next poll
  • Protocol knowledge moved into the Easee driver (op_mode + reason_no_current code→label tables in lua, not JS)

Test plan

  • go test ./internal/{api,drivers,config}/... passes
  • Deployed to homelab-rpi, easee driver auths after password fix, EV fields visible in API
  • Restart endpoint verified (POST /api/drivers/ferroamp/restart → {"source":"config","status":"restarted"})
  • Config-map diff confirmed in logs: driver config changed, restarting fires after password edit
  • Disable/Enable flow via UI (endpoints exercised, UI buttons not yet clicked by user)

🤖 Generated with Claude Code

frahlg and others added 2 commits April 16, 2026 19:11
Gave the Easee (and future EV) drivers a first-class spot in the dashboard
and fixed the silent password-reload bug that left stale credentials in
memory after a config change.

Backend
- drivers/easee_cloud.lua: emit op_mode, reason_no_current, is_online,
  cable_locked, max_a, phases in the structured ev payload, plus
  ev_dynamic_current_a / ev_temp_c as diagnostic metrics
- internal/telemetry (unchanged) already preserves the raw emit JSON;
  internal/api/api.go surfaces ev_w / ev_connected / ev_charging /
  ev_session_wh / ev_op_mode / ev_reason_no_current / ev_is_online /
  ev_cable_locked / ev_max_a / ev_phases per driver in /api/status
- /api/status: new top-level ev_credentials_saved bool (reads state.db
  so UI can tell "stored" from "blanked by MaskSecrets")
- /api/status: configured-but-not-running drivers now surface as
  not_running so the UI can offer Restart instead of hiding them

Driver lifecycle
- config.Driver gains Disabled (yaml) + HasPassword (json-only)
- main.go: skip Disabled drivers at startup
- drivers.Registry: new Restart(ctx, cfg) + RestartByName helpers
- drivers.Reload: filter Disabled (treats them like removed)
- drivers.sameDriverConfig now compares Config map + Lua path + Disabled
  — THE fix for "new password saved but driver still fails auth"; the
  diff was silently saying "nothing changed" so Reload never restarted
  the driver, leaving the stale creds in memory
- new endpoints: POST /api/drivers/{name}/{restart,disable,enable}
  (persist Disabled to yaml + apply via Reload)

UI
- web/app.js renderDrivers: EV branch shows State (mapped from op_mode),
  Power, Session kWh, Max current, Reason (labelled), Cable warn,
  Cloud offline warn. PV/battery/meter-rows skipped for EV drivers.
- Restart / Disable / Enable buttons on every driver card. Disabled
  driver cards render greyed out; spawn-failed (not_running) cards
  get an amber border + hint to check credentials.
- web/settings.js: per-driver cloud-credentials block now shows a
  "Saved/Not saved" badge next to the password label and a
  "•••••••• (leave empty to keep)" placeholder so the operator can
  tell at a glance whether a password is on disk
- web/settings.js: protocol label shows "http" for cloud drivers
  instead of "?"
- web/settings.js: EV Charger tab also gets the creds-saved badge,
  driven by /api/status.ev_credentials_saved
- web/models.js: expanding the inline Model panel now re-renders
  the panel in place from cached data instead of waiting up to 3 s
  for the next /api/status poll
- web/style.css: creds-badge (saved/missing), driver-card-disabled,
  driver-card-warn

Config / security
- config.MaskSecrets: sets drivers[i].HasPassword=true before blanking
  the password value so the UI can render the badge without seeing
  the real secret

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.6 <[email protected]>
Protocol-specific knowledge (chargerOpMode int → "charging"/"completed"/…
and reasonForNoCurrent int → human text) belongs next to the protocol,
not scattered across the frontend. Drivers now emit pre-rendered labels
alongside the raw codes.

- drivers/easee_cloud.lua: OP_MODE_LABELS + REASON_LABELS tables; emit
  state_label + reason_no_current_label as strings in the ev payload.
  Raw codes still emitted so consumers can filter on them.
- internal/api/api.go: surface ev_state_label + ev_reason_no_current_label
  in the per-driver status block.
- web/app.js: drop evOpModeLabel() + evReasonLabel() — the card now
  reads d.ev_state_label and d.ev_reason_no_current_label verbatim.

Net: -55 lines of Easee-specific JS, future EV drivers can plug in
without touching the UI.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.6 <[email protected]>
@frahlg
frahlg merged commit 52a482a into master Apr 16, 2026
github-actions Bot pushed a commit that referenced this pull request Apr 16, 2026
## [0.6.0](v0.5.2...v0.6.0) (2026-04-16)

### Features

* EV driver UI + lifecycle controls + creds visibility ([#73](#73)) ([52a482a](52a482a))

### Bug Fixes

* 3 P1 + 1 P2 from Codex + UI cleanup ([48e0d28](48e0d28))

### UI

* move EV credentials to Devices tab, remove EV Charger tab ([7cd2d9f](7cd2d9f))
@frahlg
frahlg deleted the claude/inspiring-clarke branch April 16, 2026 17:15

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c13238fe4f

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread go/internal/api/api.go
Comment on lines +337 to +339
if _, ok := drivers[dc.Name]; ok {
continue
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Honor disabled config even when health entry exists

handleStatus builds drivers from Tel.AllHealth() first, then skips config-derived state when a name is already present. Because disabling a driver removes it from the registry but does not remove its telemetry health record, this continue prevents disabled: true/status: "disabled" from ever being surfaced for recently disabled drivers, so the UI keeps rendering Restart/Disable instead of Enable. This breaks the new disable/enable lifecycle flow until process restart or manual API use.

Useful? React with 👍 / 👎.

Comment thread go/internal/api/api.go
Comment on lines +747 to +752
s.deps.CfgMu.Lock()
found := false
for i := range s.deps.Cfg.Drivers {
if s.deps.Cfg.Drivers[i].Name == name {
s.deps.Cfg.Drivers[i].Disabled = disabled
found = true

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Persist disable toggle before mutating live config

setDriverDisabled mutates s.deps.Cfg.Drivers[i].Disabled before attempting SaveConfig. If the save fails (disk full, permission error, etc.), the handler returns 500 but leaves the in-memory config changed, so runtime behavior and /api/status can diverge from on-disk config. This creates a split-brain state after a failed toggle and can trigger unexpected reload behavior later.

Useful? React with 👍 / 👎.

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.

1 participant