Skip to main content

Python Control for PlayStation 4 consoles.

|BuildStatus| |PypiVersion| |PyPiPythonVersions|

Deprecated

**This module is now deprecated and is not longer in development. This module has been renamed to pyps4-2ndscreen. See https://pypi.org/project/pyps4-2ndscreen/ **

Description

A full Python implementation based on the Node.js package, ps4-waker. This is an unofficial API for the PS4 2nd Screen App.

Compatibility

Tested on: Python 3.5/3.6/3.7

Installation

To install run:

.. code:: bash

pip install pyps4-homeassistant

Protocol

UDP is used to get status updates and retrieve user credentials. TCP is used to send commands to the PS4 Console.

Ports

PS4 listens on ports 987 (Priveleged) to fetch user PSN credentials. Must run command on python path if no access. This is so you do not need sudo/root priveleges to run although you can run as sudo, but it is not advised.

Example:

.. code:: bash

sudo setcap 'cap_net_bind_service=+ep' /usr/bin/python3.5

Usage

API should be accessed initially like the following examples.

Most functions can be accessed from the high-level PS4 object. You will need to pass in th IP address of your PS4 and your PSN credentials.

There are several async/asyncio coroutine functions in this module. These functions should be accessed with an Asyncio loop.

There are two versions of the Ps4 object/class: Ps4() and Ps4Async(). The difference is that the Ps4() class uses synchronous sockets (socket.socket) while the Ps4Async() class uses asyncio transports and protocols. If using the Async version, a running asyncio event loop is required.

class Ps4()

.. code:: python

import pyps4_homeassistant

pyps4_homeassistant.ps4.Ps4("192.168.0.2", "YourCredentials")

class Ps4Async()

.. code:: python

import pyps4_homeassistant

pyps4_homeassistant.ps4.Ps4Async("192.168.0.2", "YourCredentials")

Getting Credentials

Your PSN Credentials can be generated by running:

.. code:: python

creds = pyps4_homeassistant.credential.Credentials()

YourCredentials = creds.start()

This will start the credential service and will return the credentials for the PSN Account. You will need to get the PS4 Second Screen app for Android or iOS to do this. Once you have logged in with your acccount in the app and started the service, refresh the devices in the app and select the device named 'Home-Assistant'.

Cover Art Issues

If you find that media art cannot be found. Please post an issue with your Region, Country, Title of game, an ID of game.

To Do List:

  • Port TCP and UDP functions to Asyncio.

Credits:

Thanks to hthiery for writing the underlying socket protocol in Python. https://github.com/hthiery/python-ps4

References:

.. _ps4-waker: https://github.com/dhleong/ps4-waker

.. |BuildStatus| image:: https://travis-ci.org/ktnrg45/pyps4-homeassistant.png?branch=master :target: https://travis-ci.org/ktnrg45/pyps4-homeassistant .. |PyPiVersion| image:: https://badge.fury.io/py/pyps4-homeassistant.svg :target: http://badge.fury.io/py/pyps4-homeassistant .. |PyPiPythonVersions| image:: https://img.shields.io/pypi/pyversions/pyps4-homeassistant.svg :alt: Python versions :target: http://badge.fury.io/py/pyps4-homeassistant

Metadata

Release files for pyps4-homeassistant 0.8.7.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pyps4-homeassistant 0.8.7.2
File Size Uploaded
pyps4_homeassistant-0.8.7.2.tar.gz 20.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pyps4-homeassistant 0.8.7.2
File Interpreter ABI Platform
pyps4_homeassistant-0.8.7.2-py3-none-any.whl Python 3 none any Details

Total release size: 56.4 kB

Release files / pyps4_homeassistant-0.8.7.2.tar.gz

Download URL pyps4_homeassistant-0.8.7.2.tar.gz
Size 20.8 kB
Tags Source
SHA-256 checksum
How to use checksums
622c5823f68de67c8a8aec9fb813eb99b8bb21c3422fc059eaa7db7b59b29e4d
BLAKE2b-256 checksum
How to use checksums
c109bcce4e0d1c48737c510f3654c508f5d25d1d54d41890493faccc010aa93f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.40.0 CPython/3.7.3

Release files / pyps4_homeassistant-0.8.7.2-py3-none-any.whl

Download URL pyps4_homeassistant-0.8.7.2-py3-none-any.whl
Size 35.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
990c02e16bb91ae559a19ab7dafe80f17e3ff87761df08aa0449d22dabcb8a89
BLAKE2b-256 checksum
How to use checksums
36ccc198ca223a24ef554ab386a2eb645b87418798fb23a7492ae7699968cab9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.40.0 CPython/3.7.3

Release history Release notifications | RSS feed

This release

0.8.7.2 This release

2 release files

0.8.7

3 release files

0.8.6

2 release files

0.8.5

2 release files

0.8.4

2 release files

0.8.3

2 release files

0.8.2

2 release files

0.8.1

2 release files

0.8.0

2 release files

0.7.3

2 release files

0.7.2

2 release files

0.7.1

2 release files

0.7.0

2 release files

0.6.1

2 release files

0.6.0

2 release files

0.5.2

2 release files

0.5.0

2 release files

0.4.8

2 release files

0.3.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page