feat: add optional login_passcode for passcode-protected profiles - #663
Conversation
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>
|
Runtime-tested this branch on real hardware (HA OS Supervisor add-on, amd64) — it resolves the intermittent Setup: built the add-on image from this branch ( Result:
The |
|
I'll review this later today hopefully. Thanks for the contribution! |
andrew-codes
left a comment
There was a problem hiding this comment.
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.
Problem
standby/wakeshell out to theplayactorCLI. When the PlayStation user profile used for pairing is passcode-protected, playactor's remote-play login requires that passcode and otherwise fails withPASSCODE_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_passcodeoption, forwarded to playactor's--pass-codeon thestandbyandwakecommands.login_passcode: str?in bothps5-mqttandps5-mqtt-edgeconfig.yamlschemas (reaches the server via the existingCONFIG_PATH/options.json).LOGIN_PASSCODEenv var (parsed inconfig.ts).AppConfig→Settings→ the turn-on/turn-off sagas.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.DOCS.md,DOCKER.md).Notes / scope
Testing
buildPassCodeArgunit tests added; verified the parsing/validation/injection-guard behavior, and the helper typechecks clean under--strict.config.test.tsstays green (login_passcodeisundefinedwhen unset, whichlodash.mergeskips).typecheck+ the suite. Happy to adjust naming (e.g.login_passcodevs per-account) or approach.