Async Python library for PS4/PS5 second-screen control (wake, standby, button input)
Project description
playdirector
An async Python library for controlling PS4 and PS5 consoles over your local network — wake from standby, send button inputs, navigate home, and more.
Features
- Discover PS4/PS5 consoles on your local network via UDP broadcast
- Wake a console from standby without a full session
- Connect and send button inputs (PS4), navigate to home (PS5)
- Pair with a PS5 using your PSN credentials (NPSSO token)
- Credential storage — JSON files persisted to
~/.config/playdirector/ - Fully
async/await— built onasyncioandaiohttp
Requirements
- Python 3.11+
- PS4 (firmware ≥ 8.0) or PS5
- Console and computer on the same local network
Installation
pip install playdirector
Quick Start
import asyncio
from playdirector import discover, connect, RemoteOperation
from playdirector.credentials import JsonCredentialStorage
async def main():
storage = JsonCredentialStorage()
# Find the console (pass ip= to target a specific address)
device = await discover(ip="192.168.1.50")
if device is None:
print("Console not found")
return
# Load previously paired credentials
cred = storage.load(device.device_id)
if cred is None:
print("No credentials — run pairing first")
return
# Connect and send the PS button
async with connect(device, cred) as session:
await session.send_keys([RemoteOperation.PS])
asyncio.run(main())
Pairing
Before connecting you need to pair with the console once to obtain credentials.
PS5
You'll need your NPSSO token from the PSN website and the 8-digit PIN shown on the console under Settings → System → Remote Play → Link Device.
import asyncio
from playdirector import pair
from playdirector.credentials import JsonCredentialStorage
async def main():
cred = await pair(
ip="192.168.1.50",
pin="12345678", # 8-digit PIN from console
npsso="your-npsso", # from https://ca.account.sony.com/api/v1/ssocookie
)
JsonCredentialStorage().save(cred)
print("Paired:", cred.device_id)
asyncio.run(main())
PS4
import asyncio
from playdirector.pairing import pair_ps4_remoteplay
from playdirector.credentials import JsonCredentialStorage
async def main():
cred = await pair_ps4_remoteplay(
ip="192.168.1.100",
pin="12345678",
npsso="your-npsso",
)
JsonCredentialStorage().save(cred)
asyncio.run(main())
API
Discovery
from playdirector import discover
from playdirector.discovery import DeviceStatus
# Discover all devices on the network
async for device in discover(timeout=5):
print(device.device_type, device.host, device.status)
# Target a specific IP
device = await discover(ip="192.168.1.50")
DiscoveredDevice fields:
| Field | Type | Description |
|---|---|---|
host |
str |
IP address |
device_type |
DeviceType |
PS4 or PS5 |
status |
DeviceStatus |
AWAKE or STANDBY |
device_id |
str |
Unique device identifier |
running_app_name |
str | None |
Currently running app (if awake) |
running_app_titleid |
str | None |
Title ID of running app |
Control
from playdirector import connect, wake
from playdirector.packets import RemoteOperation
# Wake from standby (no full session needed)
await wake(device, cred)
# Full session — send button inputs (PS4)
async with connect(device, cred) as session:
await session.send_keys([RemoteOperation.PS])
await session.send_keys([RemoteOperation.UP, RemoteOperation.ENTER])
await session.standby()
# Navigate PS5 to home screen
from playdirector import go_home
await go_home(device, cred)
Available Buttons (RemoteOperation)
UP · DOWN · LEFT · RIGHT · ENTER · BACK · OPTION · PS · CANCEL
Multiple buttons can be combined: RemoteOperation.UP | RemoteOperation.LEFT
Credential Storage
from playdirector.credentials import JsonCredentialStorage
storage = JsonCredentialStorage() # defaults to ~/.config/playdirector/
storage = JsonCredentialStorage("/my/dir") # custom path
storage.save(cred) # saves to <dir>/<device_id>.json
cred = storage.load(device_id) # returns None if not found
storage.delete(device_id)
ids = storage.list_device_ids()
Error Handling
from playdirector import PlayActorError, LoginError, UnsupportedDeviceError
try:
async with connect(device, cred) as session:
...
except LoginError:
print("Bad credentials")
except UnsupportedDeviceError:
print("Operation not supported on this console")
except PlayActorError as e:
print("Protocol error:", e)
License
MIT — see LICENSE.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file playdirector-0.1.0.tar.gz.
File metadata
- Download URL: playdirector-0.1.0.tar.gz
- Upload date:
- Size: 75.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fd0f9c45861d5dc25e79a4ffad7a0fd5c60744af9b6c5821e55ce0b2083578c9
|
|
| MD5 |
e62a47a7fc2a4f7eea38e6bce51c1dde
|
|
| BLAKE2b-256 |
6d3dd80048af7a58b3e2a8b945ab8a3ace1c31b116e0abe46ea024df18c791a5
|
Provenance
The following attestation bundles were made for playdirector-0.1.0.tar.gz:
Publisher:
publish.yml on JackJPowell/playdirector
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
playdirector-0.1.0.tar.gz -
Subject digest:
fd0f9c45861d5dc25e79a4ffad7a0fd5c60744af9b6c5821e55ce0b2083578c9 - Sigstore transparency entry: 1363361103
- Sigstore integration time:
-
Permalink:
JackJPowell/playdirector@66f548e9883a7b2f79bfcd9ab186f394d8d5f304 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/JackJPowell
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@66f548e9883a7b2f79bfcd9ab186f394d8d5f304 -
Trigger Event:
push
-
Statement type:
File details
Details for the file playdirector-0.1.0-py3-none-any.whl.
File metadata
- Download URL: playdirector-0.1.0-py3-none-any.whl
- Upload date:
- Size: 72.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4dd9fc386998232c0223c5461b505a7843ebef4ba8ea0bead1097655b0e57ea5
|
|
| MD5 |
43aa50f022bcbb14a20b5730ebc72b94
|
|
| BLAKE2b-256 |
7465d326073ce044ed80b9766760f55caffdd9990c61dd956341a456587eebca
|
Provenance
The following attestation bundles were made for playdirector-0.1.0-py3-none-any.whl:
Publisher:
publish.yml on JackJPowell/playdirector
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
playdirector-0.1.0-py3-none-any.whl -
Subject digest:
4dd9fc386998232c0223c5461b505a7843ebef4ba8ea0bead1097655b0e57ea5 - Sigstore transparency entry: 1363361868
- Sigstore integration time:
-
Permalink:
JackJPowell/playdirector@66f548e9883a7b2f79bfcd9ab186f394d8d5f304 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/JackJPowell
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@66f548e9883a7b2f79bfcd9ab186f394d8d5f304 -
Trigger Event:
push
-
Statement type: