Playstation 4/PS4 custom component

A summary for anybody searching for a complete PS4 Component installation guide for HASS.IO on Pi, maintained/SSH’d from Windows:

Using: Home Assistant version 0.57.2 (Running HASS.IO), PS4WakerBridge 0.0.2 (HASS.IO Add-On), PS4 System Software 5.01 (PS4 Firmware), PS4 Second Screen (iPhone App) 17.11.2, Cygwin x64 2.882 (for Windows).

Note: You’ll need to SSH into HASS.IO to install custom software. You should back up your Pi’s SD card using Win32DiskImager before continuing!

  1. Install vkorn’s PS4 Waker Bridge HASS.IO Add-On (barebones instructions on vkorn’s github page) by pasting this link https://github.com/vkorn/hassio-addons into …
    Your_HASSIO_ Setup (https://your_HASS.IO_server/hassio/store)
    > Hass.io tab on the left
    > Click the shopping bag in the top-right corner
    > "Add-On Repositories" box
    > Hit “SAVE”
    > Scroll down to see "Vlad's repository" and install the PS4WakerBridge.
  • Now add the following code to your configuration.yaml:
media_player:
  - platform: ps4
    host: http://**YourHassioIP**:3031
    ps4_ip: **YourPS4's IP**
    name: PlayStation 4
    local_store: games
  1. Since the PS4 Waker Bridge HASS.IO Add-On is based on hmn’s old HASSbian component (relevant, though a bit deprecated, instructions available on hmn’s github page), you’ll need to copy a modified ps4.py file to HASSIO/config/custom_components/media_player (right click “RAW” and save-as on the github page). Eventually you’ll also need a .ps4-wake.credentials.json and ps4-games.json file in the HASSIO/config/ folder. You can create dummy files of these for now if you like.

  2. danrspencer provided more detail here on the SSH process to create credentials between the Pi and the PS4. He believes that the credential file must be created during a handshake between the PS4 and the Pi for the component to work correctly (thus necessitating SSH into the Pi to install PS4-waker).

  • SSH into the true root of your Pi running HASS.IO: Use the SSH home-assistant guide to get to the true root of your Pi from Windows. To do this, you’ll need to create a public/private RSA key pair, put the public key onto the root of the boot partition of your HASS.IO Pi’s SD card (the only partition readable by Windows – !!!DO NOT REFORMAT THE OTHER PARTITIONS AS PROMPTED BY WINDOWS!!!), then install the private key into your SSH software on your Windows machine. Put the SD card back into the Pi, boot up, then SSH into your Pi’s root (ssh [email protected] -p 22222). For some reason, I couldn’t get PuTTY to work (even though it works fine logging into my HASS.IO's command line). But Cygwin could log in as long as it got to create its own RSA keys (though I had to use a lower-case k in Cygwin for the
    ssh-add -k ~/.ssh/id_rsa
    command).

  • Once you have root access to your Pi, follow danrspencer’s instructions. Your command-line should resemble something like this:

command: docker ps

root@hassio:~# docker ps
CONTAINER ID        IMAGE                                      COMMAND                                                                                  CREATED             STATUS              PORTS       NAMES
1808b5652af8        vkorn/armhf-ps4waker                       "/usr/bin/entry.sh..."   7 minutes ago       Up 7 minutes       addon_e5829d31_ps4waker
138929e07d9d        homeassistant/raspberrypi3-homeassistant   "/usr/bin/entry.sh..."   7 minutes ago       Up 7 minutes       homeassistant
99954083a6f4        homeassistant/armhf-addon-samba            "/usr/bin/entry.sh..."   8 minutes ago       Up 7 minutes       addon_core_samba
dbaeba95d8a1        homeassistant/armhf-addon-ssh              "/usr/bin/entry.sh..."   8 minutes ago       Up 7 minutes        0.0.0.0:22->22/tcp       addon_core_ssh
8e5ea1a5ca0c        homeassistant/armhf-addon-duckdns          "/usr/bin/entry.sh..."   8 minutes ago       Up 7 minutes       addon_core_duckdns
21d9085195e1        homeassistant/armhf-addon-rpc_shutdown     "/usr/bin/entry.sh..."   8 minutes ago       Up 7 minutes       addon_core_rpc_shutdown
1b2b91e3589d        homeassistant/armhf-addon-mosquitto        "/usr/bin/entry.sh..."   12 minutes ago      Up 8 minutes        0.0.0.0:1883->1883/tcp, 0.0.0.0:       8883->8883/tcp   addon_core_mosquitto
2b568e890a3c        homeassistant/armhf-hassio-supervisor      "/usr/bin/entry.sh..."   10 days ago         Up 12 minutes       resin_supervisor

commands:
docker exec -it [id for ps4-waker container] /bin/bash
npm install -g ps4-waker

root@hassio:~# docker exec -it 1808b5652af8 /bin/bash
bash-4.3# npm install -g ps4-waker
/usr/bin/ps4-waker -> /usr/lib/node_modules/ps4-waker/bin/cmd.js
/usr/lib
└─┬ [email protected]
  ├── [email protected]
  └─┬ [email protected]
    └── [email protected]

Attempt to remove any data:

bash-4.3# rm /data/ps4
rm: can't remove '/data/ps4': No such file or directory

Run ps4-waker to authenticate Pi to PS4:

bash-4.3# ps4-waker -c /data/ps4-creds.json
WAKEUP sent to device... 192.168.1.19
Error: Device didn't wake in time
    at loop (/usr/lib/node_modules/ps4-waker/dist/waker.js:286:26)
    at /usr/lib/node_modules/ps4-waker/dist/detector.js:141:9
    at Detector.<anonymous> (/usr/lib/node_modules/ps4-waker/dist/detector.js:120:26)
    at emitTwo (events.js:106:13)
    at Detector.emit (events.js:191:7)
    at Socket.<anonymous> (/usr/lib/node_modules/ps4-waker/dist/detector.js:61:18)
    at emitTwo (events.js:106:13)
    at Socket.emit (events.js:191:7)
    at UDP.onMessage (dgram.js:549:8)

Ok, that time crashed and burned. Try again. Don’t forget that you need to install the PS4 Second Screen app on your phone, and head to your PS4’s Settings > PlayStation App Connection Settings to get a PIN code.

bash-4.3# ps4-waker -c /data/ps4-creds.json
WAKEUP sent to device... 192.168.1.19
Logging in...
Login error: PASSCODE_IS_NEEDED
bash-4.3# rm /data/ps4-creds.json
bash-4.3# ps4-waker -c /data/ps4-creds.json
No credentials; Use the PS4 Second Screen App and try to connect to PS4-Waker
Got credentials!  { 'client-type': 'i',
  'auth-type': 'C',
  'user-credential': 'x#x###x#x####x#####xxx#x##x##x#x###x##xx#########xx#x###xxx##x#' }
Go to 'Settings -> PlayStation(R) App Connection Settings -> Add Device' on your PS4 to obtain the PIN code.
Pin code> ########
Logged into device! Future uses should succeed

That worked! The credential is listed as 'user-credential': 'x#x###x#x####x#####xxx#x##x##x#x###x##xx#########xx#x###xxx##x#' Copy the long string, and save it in a text file for now.

Don’t forget to nab the ps4-creds.json file data before we exit. If you miss it now, it seems to get destroyed on system reboot. (Your key seems to always stay the same though, even if you re-do the ps4-waker installation and everything.) I don’t know how to copy the file, but we can extract its contents using a text editor:

bash-4.3# ls
bin        dev        home       media      proc       run        sbin       sys        tmp        var
data       etc        lib        mnt        root       run.sh     srv        templates  usr
bash-4.3# cd data
bash-4.3# ls
options.json    ps4-creds.json
bash-4.3# "${EDITOR:-vi}" ps4-creds.json

You should see this inside the key file:
{"client-type":"i","auth-type":"C","user-credential":"x#x###x#x####x#####xxx#x##x##x#x###x##xx#########xx#x###xxx##x#"}
Copy that and paste it into a file named .ps4-wake.credentials.json and save that file into your HASSIO\config folder.

Use :q, Enter, to quit the text editor. Then exit bash.

bash-4.3# exit

We’re almost done. This last bit is subtle and SUPER important.

  1. Set up the PS4WakerBridge Add-On:
    Copy and past this into your Options area. Note that the port should be 3031 and that you should use your credential key.
{
  "port": 3031,
  "devices": [
    {
      "client_type": "i",
      "auth_type": "C",
      "credentials": "x#x###x#x####x#####xxx#x##x##x#x###x##xx#########xx#x###xxx##x#"
    }
  ]
}
  • Hit save.

  • Make sure that you put your .ps4-wake.credentials.json inside the HASSIO\config folder. Your ps4-games.json file should be created automatically and auto-populate inside the HASSIO\config folder. Also double-check that you’re using the correct (modified) ps4.py file inside HASSIO\config\custom_components\media_player.

  • Reboot your Pi. Everything should work

Best of luck

19 Likes