Switch for Playstation 4

Do we still need the PS app, or does this method skip it?

You need the ps app one time to get your credentials file.

That’s awesome! I’m gonna try this out myself!

Awesome. I’ve got it all up and running. :slight_smile:

Hi,
I tried to install ps4-waker but i receive a strange error when I try to execute:

pi@raspberrypi:$ ps4-waker
                                                                                                                          
/usr/local/lib/node_modules/ps4-waker/bin/cmd.js:107                                                                      
    var keyNames = argv._.slice(remote).map((key) => key.toUpperCase());                                                  
                                                   ^
SyntaxError: Unexpected token >                                                                                           
    at Module._compile (module.js:439:25)                                                                                 
    at Object.Module._extensions..js (module.js:474:10)                                                                   
    at Module.load (module.js:356:32)                                                                                     
    at Function.Module._load (module.js:312:12)                                                                           
    at Function.Module.runMain (module.js:497:10)                                                                         
    at startup (node.js:119:16)                                                                                           
    at node.js:906:3   

What’s the problem?

Thanks

Hi,

I work throw this thread a couple of Days ago and had a similar Problem.
I had to update nodejs to Version 7.

Run these Commands to update nodejs to latest stable Version:

sudo npm cache clean -f
sudo npm install -g n
sudo n stable

BR

Lukas

3 Likes

Yeah man!! It works!! Thanks so much!! :slight_smile:

I like the netcat method but I’m not getting a 1 or 0 return - I get nothing unless I use the -v flag. Any ideas why?

Found that to get the output, the command looks like this:
> nc -z -w 5 192.168.1.66 997; echo $?

I don’t think that is the output. If you do only echo $? the result will be zero. But when i run the command i don’t get output also.
But it works in HA. Did you test by just adding it to your config like i did?

Yeah, that seems to work. Was surprised when I didn’t get output from the command line but oh well.

For those interested, I expanded on this idea a bit and added an input_select to launch to specific apps.

input_select:

  playstation4app:
    name: App Selection
    options:
     - "-- Select --"
     - "Playstation Vue"
     - "Plex"
    initial: "-- Select --"
    icon: mdi:apps

Automation

  - alias: PS4 - Open Vue
    trigger:
       platform: state
       entity_id: 'input_select.playstation4app' 
       to: "Playstation Vue"  
    action:
      - service: shell_command.playstationvue_start 
      - service: input_select.select_option
        data:
          entity_id: input_select.playstation4app
          option: "-- Select --"
      - service: notify.notifyall
        data:
          message: "Playstation starting Vue"
          
  - alias: PS4 - Open Plex
    trigger:
       platform: state
       entity_id: 'input_select.playstation4app' 
       to: "Plex"  
    action:
      - service: shell_command.playstationplex_start 
      - service: input_select.select_option
        data:
          entity_id: input_select.playstation4app
          option: "-- Select --"
      - service: notify.notifyall
        data:
          message: "Playstation starting Plex"

shell_command

  playstationvue_start: "sudo ps4-waker -c /config/ps4-waker/.ps4-wake.credentials.json -b 192.168.1.188 -d 192.168.1.66; sudo ps4-waker -c /config/ps4-waker/.ps4-wake.credentials.json -b 192.168.1.188 -d 192.168.1.66 start CUSA00960"

Important bit is the AppID at the end which is found following the instructions here: https://github.com/dhleong/ps4-waker/wiki

4 Likes

Thank you! examples are always welcome. Your post solved this question i posted on the forums. I had never thought of changing an input select with another one. Thank you!

Did you get the PS3 to turn on at all? I haven’t been able to… :frowning:

I don’t have a PS3 hooked up to test but it works great with my PS4

Hmmm, so from RPi, when logged in as “pi” user it works.

When I would like to wake up my PS4, I can try this (PS4 is already registered)

$ ps4-waker
Device must be awake for initial registration

Hmm, and when I sue it with sudo, it works:

$ sudo ps4-waker
WAKEUP sent to device… 10.1.2.105
Logging in…
Done!

So I enter my venv (I have RPi installed inside venv):

sudo su -s /bin/bash homeassistant
source /srv/homeassistant/homeassistant_venv/bin/activate

but when I want to launch a script from inside venv (as a homeassistant user), it doesnt work:

$ ps4-waker
No credentials; Use Playstation App and try to connect to PS4-Waker

And when i stry to run it via sudo:

$ sudo ps4-waker
We trust you have received the usual lecture from the local System
Administrator. It usually boils down to these three things:
#1) Respect the privacy of others.
#2) Think before you type.
#3) With great power comes great responsibility.
[sudo] password for homeassistant:

It needs user’s pssword for sudo-ing but I guess that homeassistant user (when installed via original doc into venv), it’s without password…

Any clue how to solve this? (rpi / HA via venv / ps4 wakeup)?

so, solved by copying creditentils from /rott folder into homeassistant folder:

sudo cp /root/.ps4-wake.credentials.json /home/homeassistant/
cd /home/homeassistant/
sudo chown homeassistant:homeassistant .ps4-wake.credentials.json

And one more question… Now it works just great. Except for one thing: I switch my PS4 for example from OFF to ON. SO I click on HS switch (toggle button). After clicking on the button, it will toggle from OFF to ON (of course). But after a little while, it will flip back to OFF. And after another while (few seconds) it will flip back to ON. This is probably caused by delay, coz PS4 needs some time to wake-up and in-between “OFF” value is returned… Is there some solution/workaround for this?

I am running into an issue where it seems to start, login, and launch netflix (as desired) for the first 1 or 2 times and then it starts booting the ps4 up the screen that says “welcome back, press the PS button on your controller…” Anyone know what is going on here? I am suspecting permission issues between sudo/homeassistant?

I also got that behaviour sometimes, but not all the time.

Nice tip Kylerw! I set my system like that. One problem though. I keep getting those annoying pop ups saying that “My companion app has turned on/off” I tried disabling all notifications from ps4 setup, but it doesn’t seem to care. Still getting the pop ups. Do you have the same situation?