Skip to content

feat: add optional login_passcode for passcode-protected profiles - #663

Merged
andrew-codes merged 1 commit into
FunkeyFlo:mainfrom
bayan9:feat/login-passcode
Jul 20, 2026
Merged

andrew-codes merged 1 commit into
FunkeyFlo:mainfrom
bayan9:feat/login-passcode

Conversation

@bayan9

@bayan9 bayan9 commented Jul 18, 2026

Copy link
Copy Markdown
Contributor

Problem

standby/wake shell out to the playactor CLI. When the PlayStation user profile used for pairing is passcode-protected, playactor's remote-play login requires that passcode and otherwise fails with PASSCODE_IS_NEEDED (remoteplay/proc/login.js). In practice this is intermittent — it depends on the console's state at the moment of the command — so power control "usually works" but randomly leaves the console awake/asleep. There is currently no way to supply the profile login passcode, so passcode-protected profiles can't be reliably controlled.

Change

Add an optional login_passcode option, forwarded to playactor's --pass-code on the standby and wake commands.

  • Add-on: new login_passcode: str? in both ps5-mqtt and ps5-mqtt-edge config.yaml schemas (reaches the server via the existing CONFIG_PATH/options.json).
  • Docker: new LOGIN_PASSCODE env var (parsed in config.ts).
  • Plumbed through AppConfigSettings → the turn-on/turn-off sagas.
  • A small buildPassCodeArg() helper builds the --pass-code '<value>' fragment. It accepts playactor's documented formats (a numeric passcode, or a space-separated string of key names), validates against ^[A-Za-z0-9 ]+$, and single-quotes the value — so a malformed/hostile value can't inject into the shell command. Unset ⇒ no change in behavior.
  • Unit tests for the helper (incl. injection guards); docs updated (DOCS.md, DOCKER.md).

Notes / scope

  • A single passcode applies to all managed devices. Multiple consoles with different profile passcodes aren't covered (documented). Happy to extend to per-device if you'd prefer that shape.
  • Alternative for users: disabling the profile passcode on the console avoids the error entirely; this option is for those who want to keep it.

Testing

  • buildPassCodeArg unit tests added; verified the parsing/validation/injection-guard behavior, and the helper typechecks clean under --strict.
  • Existing config.test.ts stays green (login_passcode is undefined when unset, which lodash.merge skips).
  • Disclosure: I couldn't run the full yarn workspace build in my environment; please let CI exercise typecheck + the suite. Happy to adjust naming (e.g. login_passcode vs per-account) or approach.

Standby/wake shell out to `playactor`, which fails with PASSCODE_IS_NEEDED
when the console profile is passcode-protected — often intermittently,
depending on the console's state — leaving the PS5 unable to turn on/off.
There was no way to supply the profile login passcode.

Add an optional `login_passcode` config option (add-on schema + `LOGIN_PASSCODE`
env var for Docker) that is forwarded to playactor's `--pass-code` on the
standby and wake commands. A small `buildPassCodeArg` helper validates the
value (numeric passcode or space-separated key names) against a strict
character set and single-quotes it, guarding against shell injection; unset =
no change in behavior. Adds unit tests and docs.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@github-actions github-actions Bot added the minor label Jul 18, 2026
@bayan9

bayan9 commented Jul 19, 2026

Copy link
Copy Markdown
Contributor Author

Runtime-tested this branch on real hardware (HA OS Supervisor add-on, amd64) — it resolves the intermittent PASSCODE_IS_NEEDED for a passcode-protected PS5 profile.

Setup: built the add-on image from this branch (add-ons/common/Dockerfile + yarn build/yarn workspace @ps5-mqtt/server package), supplied the profile passcode via the LOGIN_PASSCODE env, restarted the add-on (existing pairing/credentials preserved).

Result:

  • wake → console reached AWAKE cleanly.
  • standby → console reached STANDBY cleanly (this is the command that previously failed intermittently with Error[1] PASSCODE_IS_NEEDED).
  • PASSCODE_IS_NEEDED occurrences after the change: 0, no registration/auth errors.

The buildPassCodeArg() fragment is correctly appended to both the playactor wake and playactor standby invocations, and the numeric passcode is accepted. LGTM from a functional standpoint — thanks for the util + tests.

@andrew-codes

Copy link
Copy Markdown
Collaborator

I'll review this later today hopefully. Thanks for the contribution!

@andrew-codes
andrew-codes self-requested a review July 20, 2026 11:43

@andrew-codes andrew-codes left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This looks good. Thank you for the contribution! I'll follow up with some of the tests to the sagas. I don't think it is a blocker to the benefit of having the feature enabled for users.

@andrew-codes
andrew-codes merged commit a16fceb into FunkeyFlo:main Jul 20, 2026
17 of 18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants