PS4¶
The PS4 class is the main object for interfacing with a PS4 console. You should only call methods directly from this class.
There are two versions: pyps4_2ndscreen.ps4.Ps4Async
and pyps4_2ndscreen.ps4.Ps4Legacy
.
Base Version¶
The pyps4_2ndscreen.ps4.Ps4Base
class should not be used directly.
-
class
pyps4_2ndscreen.ps4.
Ps4Base
(host: str, credential: str, device_name: Optional[str] = 'pyps4-2ndscreen', port: Optional[int] = 0)¶ Bases:
object
The PS4 base object. Should not be initialized directly.
- Parameters
host – The host PS4 IP address
credential – The credentials of a PSN account
device_name – Name for client device
port – Local UDP Port to use
-
change_port
(port)¶ Change DDP Port.
-
get_status
() → dict¶ Return current status info.
-
async
async_get_ps_store_data
(title: str, title_id: str, region: str) → pyps4_2ndscreen.media_art.ResultItem¶ Return title data from PS Store.
-
property
port
¶ Return local port.
-
property
status_code
¶ Return status code.
-
property
is_running
¶ Return True if the PS4 is running.
-
property
is_standby
¶ Return True if the PS4 is in standby.
-
property
is_available
¶ Return True if the PS4 is available.
-
property
connected
¶ Return True if connected to PS4.
-
property
system_version
¶ Return the system version.
-
property
host_id
¶ Return the host id/MAC address.
-
property
host_name
¶ Return the host name.
-
property
running_app_titleid
¶ Return the title ID of the running application.
-
property
running_app_name
¶ Return the name of the running application.
-
property
running_app_ps_cover
¶ Return the URL for the title cover art.
-
property
running_app_ps_name
¶ Return the name fetched from PS Store.
Async Version¶
pyps4_2ndscreen.ps4.Ps4Async
is the recommended class. It is best suited for runtime applications. You should have an asyncio event loop running to call/await its coroutines.
-
class
pyps4_2ndscreen.ps4.
Ps4Async
(host: str, credential: str, device_name: Optional[str] = 'pyps4-2ndscreen', port: Optional[int] = 0)¶ Bases:
pyps4_2ndscreen.ps4.Ps4Base
Async Version of Ps4 Class.
- Parameters
host – The host PS4 IP address
credential – The credentials of a PSN account
device_name – Name for device
-
set_login_delay
(value: int)¶ Set delay for login.
-
set_protocol
(ddp_protocol: pyps4_2ndscreen.ddp.DDPProtocol)¶ Attach DDP protocol.
- Parameters
ddp_protocol –
- class
pyps4_2ndscreen.ddp.DDPProtocol
-
add_callback
(callback: callable)¶ Add status updated callback.
- Parameters
callback – Callback to call on status updated; No args
-
get_status
() → dict¶ Get current status info.
-
wakeup
(ignore_conflict=False)¶ Send Wakeup packet.
-
async
change_ddp_endpoint
(port: int, close_old: bool = False)¶ Return True if new endpoint is created.
-
async
get_ddp_endpoint
()¶ Return True if endpoint is created from socket.
-
async
login
(pin: Optional[str] = '')¶ Send Login Packet.
- Parameters
pin – Pin to send. Requred when linking.
-
async
standby
(ignore_conflict=False)¶ Send Standby Packet.
-
async
toggle
()¶ Toggle Power.
-
async
start_title
(title_id: str, running_id: Optional[str] = None)¶ Send start title packet.
Closes current title if title_id is running_id
- Parameters
title_id – Title to start; CUSA00000
running_id – Title currently running
-
async
remote_control
(button_name: str, hold_time: Optional[int] = 0)¶ Send remote control command packet. Is coroutine.
- Parameters
button_name – Button to send to PS4.
hold_time – Time to hold in millis. Only affects PS command.
-
async
close
()¶ Close Connection.
-
async
async_connect
(auto_login: Optional[bool] = True)¶ Connect.
- Parameters
auto_login – If true will login automatically if powering on.
-
property
login_delay
¶ Return login delay value.
Legacy Version¶
pyps4_2ndscreen.ps4.Ps4Legacy
is best suited for one-time commands.
-
class
pyps4_2ndscreen.ps4.
Ps4Legacy
(host: str, credential: str, device_name: Optional[str] = 'pyps4-2ndscreen', auto_close: Optional[bool] = True, port: Optional[int] = 0)¶ Bases:
pyps4_2ndscreen.ps4.Ps4Base
Legacy PS4 Class. Sync Version.
- Parameters
host – The host PS4 IP address
credential – The credentials of a PSN account
device_name – Name for device
-
close
()¶ Close the connection to the PS4.
-
wakeup
()¶ Send Wakeup Packet.
-
login
(pin: Optional[str] = '') → bool¶ Send Login Packet.
- Parameters
pin – Pin to send. Requred when linking.
-
standby
() → bool¶ Send Standby Packet.
-
start_title
(title_id, running_id: Optional[str] = None) → bool¶ Send Start title packet.
Close current title if title_id is running_id
- Parameters
title_id – Title to start; CUSA00000
running_id – Title currently running
-
remote_control
(button_name, hold_time: Optional[int] = 0) → bool¶ Send remote control command packet.
- Parameters
button_name – Button to send to PS4.
hold_time – Time to hold in millis. Only affects PS command.
-
send_status
() → bool¶ Send connection status ack to PS4.