Skip to content

fix(modes): only the admin PIN chooses a display's mode helper - #384

Merged
jherforth merged 1 commit into
mainfrom
fix/mode-helper-pin
Nov 6, 2026
Merged

jherforth merged 1 commit into
mainfrom
fix/mode-helper-pin

Conversation

@jherforth

Copy link
Copy Markdown
Owner

Follow-up to #378: closes the open item from the review there. Any browser on the network could point a display's mode helper at any input_select in Home Assistant (house mode, alarm mode), then rewrite its options or set it, with no PIN.

Changes

  • POST /api/devices/:name/modes/ha/helper needs the admin PIN (pin in the body) when one is set. It's asked for even on a display that remembers the PIN, as backups are, because adminPinRemembered is a device setting any client can write. In Admin → Displays → Modes → Home Assistant, Create helper, picking an existing helper and Disconnect now ask for the PIN first (useAdminPinPrompt).
  • 404 for an unknown display on that route, instead of creating a device row.
  • The settings PUT/PATCH keeps the stored helper link (displayModes.ha.helper, helperId, title) whatever the save says (keepHelperLink in services/displayModesHa.js). report and wake save as before. This also stops a stale Admin save from undoing a helper that was just chosen.
  • Copying settings from another display keeps this display's own helper.
  • docs/reference/backend-api.md lists the display-mode routes, which weren't documented yet.

/sync, /select and /report are unchanged. They write only the helper the display already has (now chosen only with the PIN) and its own sensor.homeglow_*_showing.

Testing

  • Server 769/769, including four new tests in displayModesHaRoutes.test.js: a save can't set or change the helper, a copy keeps the target's own helper, an unknown display gets 404 with no device made, and the PIN is needed even with adminPinRemembered: true. All four fail on main.
  • Client 1035/1035, check:i18n and the build pass.
  • Edge, against a fake Home Assistant with a PIN set:
    • Create helper asks for the PIN, and nothing is sent before it;
    • a wrong PIN keeps the dialog open and sends nothing;
    • the right PIN makes input_select.homeglow_display_mode with Automatic/Normal/Night, and the display uses it;
    • a later settings save naming another helper keeps this one and saves wake;
    • no page errors.

Not in this PR

displayRemembersPin in routes/haPanels.js (unlock/disarm/open from plugin frames) trusts adminPinRemembered, which PATCH /settings accepts from any client. Making that flag server-owned is a separate change.

🤖 Generated with Claude Code

The mode helper is the input_select that /modes/ha/sync and /modes/ha/select
write to, and choosing one with { entity_id } replaces its options. Before,
any browser on the network could point a display at any input_select (house
mode, alarm mode) and rewrite or set it:

- POST /modes/ha/helper now needs the admin PIN when one is set, even on a
  display that remembers it (as backups do: that flag is a device setting
  any client can write). Admin asks for it before making, choosing or
  disconnecting the helper.
- /modes/ha/helper answers 404 for a display that doesn't exist, instead of
  creating one.
- The settings PUT/PATCH keeps the stored displayModes.ha.helper, helperId
  and title, whatever the save says; the rest of displayModes.ha (report,
  wake) saves as before. This also stops a stale Admin save from undoing a
  helper just chosen.
- Copying another display's settings keeps this display's own helper.

The API reference lists the display-mode routes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@jherforth
jherforth merged commit 2fda255 into main Nov 6, 2026
6 checks passed
@github-project-automation github-project-automation Bot moved this from Backlog to Done in HomeGlow Kanban Nov 6, 2026
@jherforth jherforth self-assigned this Nov 6, 2026
@jherforth jherforth added the bug Something isn't working label Nov 6, 2026
@jherforth jherforth added this to the 2.0 milestone Nov 6, 2026
adamecker pushed a commit to adamecker/HomeGlow that referenced this pull request Nov 7, 2026
…rforth#382, jherforth#384) and origin/test/all-combined into test/all-combined

Upstream: Stacks/display Modes/takeovers (jherforth#378), routine complete-all
(jherforth#380), mirror re-measure (jherforth#381), shared New Chore dialog (jherforth#382), admin
PIN chooses the mode helper (jherforth#384). Fork side: Open-Meteo provider,
precipitation probability, bonus-chore return to pool, Google Tasks
no-due-date fix, dock-hide-on-dialog, HA panel test seed.

Conflicts (fork's jherforth#380/jherforth#382 branches vs upstream's merged versions):
took upstream's refinements (scheduleOnly, tickRemainingStepsOrThrow);
app.jsx combines both (dock stays hidden while dragging is false and a
dialog is open).

Auto-seed now strips the HA mode-helper link from seeded settings, so a
new display never inherits another display's helper (jherforth#384: only the
admin PIN chooses it). The Stacks tests pre-create their devices in
before(), while no device has widgets yet, so auto-seed leaves them
empty.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant