Playstation 4/PS4 custom component

Nope. Hass.io blocks ssh so you won’t even be able to install it.

Isn’t that if you were to manually install, what if it was through an ‘official’ add on? Add ons like the homebridge one for HASS install additional packages.

For Hass.io search for PS4 Waker Bridge

1 Like

Does the Hassio add-on work? I haven’t yet tried. I just moved and reset my whole system with hassio. Haven’t yet gotten around to adding the PS4.

What’s the story with the github image list and it being updated? I have a lot of games and apps that are not in the list.

As for hosting the images locally, do I just add a new directory in m /www called PS4 for example and drop images in there? Say for Destiny 2, CUSA06172.jpg?

Then in my config, just add local_store: PS4 to the playstation component and reboot?

UPDATE: All good, I sorted it out. This is exactly how it works.Just a tedious effort to find decent images that look good on the HA panel.

1 Like

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

nice, thanks for the clear guide. I struggled getting this setup before you have inspired me to try again!

2 Likes

Much appreciated for the detailed walkthrough for those not familiar with HA yet. I was also trying to follow all the different advice listed here but was currently stuck using PuTTY to accept the key. I’ll try your advice using Cygwin!

1 Like

That’s a nice guide that will help a bunch of people. Thanks! :slight_smile:

1 Like

New to home assistant, i’ve mostly set up the component according to Wheezy’s guide but have hit one snag. The log reads as follows:

2017-12-12 16:44:40 ERROR (SyncWorker_3) [custom_components.media_player.ps4] Failed to call on: HTTPConnectionPool(host=‘172.30.33.0’, port=3031): Max retries exceeded with url: /ps4/192.168.0.110/on (Caused by NewConnectionError(’<urllib3.connection.HTTPConnection object at 0x71f5a790>: Failed to establish a new connection: [Errno 111] Connection refused’,))

2017-12-12 16:44:44 ERROR (SyncWorker_13) [custom_components.media_player.ps4] Failed to call info: HTTPConnectionPool(host=‘172.30.33.0’, port=3031): Max retries exceeded with url: /ps4/192.168.0.110/info (Caused by NewConnectionError(’<urllib3.connection.HTTPConnection object at 0x71b51bd0>: Failed to establish a new connection: [Errno 111] Connection refused’,))

it appears like a network issue but not sure how to go about solving it.

never mind I was able to get it to work, although I’m not sure exactly how.

1 Like

Also want to say thank you for this - I’m sure you’ve saved me hours of hassle! I finally got it running and can select ‘source’ (aka launch a game), and turn off the PS4. Oddly, I can’t turn it on though.

For anyone stuck with the SSH key not letting you login for root access on port 22222, I had the same problem until I copied the public key text from the HA config screen for normal SSH access. That was one long text string without the comments before and after versus the PUTTY file which had comments. Once I switched for the single long line of text in authorized_keys it was fine.

1 Like

I get this message when the PS4 is unplugged sometimes. Not sure if that was part of the problem or not. But I’m glad it resolved itself

Happy New Year 2018. Got it works. Thank you very much ^^

1 Like

Hi
when my PS4 is off i get this error.
Failed to call info: {“status”:“Could not detect any matching PS4 device”}
13:04 custom_components/media_player/ps4.py (ERROR)

Anyone can help me ?

Has to be in ‘Rest Mode’ for it to detect and turn it on.

1 Like

Start MediaPlayer and change Source with delay/loop

has anyone tried an automation to turn on the PS4 and start a Game?
It needs to be turned on and notice when its on/idle and then select the source. I’m not sure how the checking/noticing would work. It needs to be some kind of loop.

I use a command link switch:
sudo ps4-waker start cusaxxxx

  • where x is the number of the game located on the spine of the game case

Fantastic guide. Total noob like me got it working.

Couple things I want to mention in case anyone else runs into this issue using your guide.

It took me a while to get the PS4-Waker to show up in the second screen companion app. I had to restart the pi after having the mofified ps4.py file in place, and the configuration.yaml set up with the ps4 as a media device. I was afraid to do this at first because i was getting config errors with the config file checker. Once i copied the mofied ps4 file, the errors went away, rebooted, and the Ps4 waker showed up in the companion app (after a minute or two).

1 Like

Brilliant explanation, just followed all your steps and it works, thank you so much.

1 Like