@shivan Thank you! I also hope this will be a component some day. then it would be much easier to set up.
But if you want to use it now. the hardest part is to get a good version of nodejs and npm installed. With this i was struggling the most.
To Install npm and nodejs
I checked what commands i used for it so maybe it is not all needed but this is what i tried:
sudo npm install -g n
sudo n stable
sudo npm stable
sudo install npm stable
sudo install nodejs stable
curl -sL https://deb.nodesource.com/setup_7.x | sudo -E bash -
sudo apt-get install -y nodejs
After installing it you can check which version you have
by running these commands:
node -v
nodejs -v
npm -v
The version i have are:
node -v
v5.7.0
nodejs -v
v7.5.0
npm -v
3.6.0
Installing netcat (this is to determine if your PS4 is on or off)
sudo apt-get install netcat
So if you have this you should be good to go to install ps4-waker.
Installing ps4-waker
npm install ps4-waker -g
Then you can start it with the command: (make sure your ps4 is turned on)
sudo ps4-waker
The first time it start it will ask you to find a pin code on your ps4 and enter it. this is to make your credentials file.
just follow the steps it asks you to do.
When finished. i did go to the folder /root/ and copied the credentials.json to a location on /home/pi/documents/
Playstation 4 settings
Now there is one more step you need to do.
On your playstation go to settings --> Power Save Settings --> Set features available in Rest Mode --> turn on Enable Turning On PS4 from Network.
recommended: Set your PS4 to an static ip address
Testing it
So from this point you should be able to turn off your ps4 with the command:
ps4-waker standby -c /home/pi/Documents/.ps4-wake.credentials.json -d 192.168.1.21
-c is followed by the path where your credentials.json is.
-d is the ip address of your PS4
and you can turn it on by running:
ps4-waker -c /home/pi/Documents/.ps4-wake.credentials.json -d 192.168.1.21
Making it work in HA
Great change that this command will not be working yet if you try to run it as a shell command in Home Assistant.
So what i did is:
Login to putty and then:
sudo su
visudo
then find this line:
# User privilege specification
root ALL=(ALL:ALL) ALL
copy and past the root line. So now you have two the same lines under each other. Then change root to the username where Home Assistant is running. ( you can find that name in the path to you configuration.yaml.) I think for an all in one install it will be âhassâ and for a hassbian install like i have it is âhomeassistantâ
So the result will be:
# User privilege specification
root ALL=(ALL:ALL) ALL
homeassistant ALL=(ALL:ALL) ALL
press ctrl + x and then Y and then Enter.
After this go to the sudoers.d folder:
cd /etc/sudoers.d
And create a new file like this:
sudo nano 010_homeassistant-nopasswd
In this file copy the following line
homeassistant ALL=(ALL) NOPASSWD: ALL
and close it with ctrl + X, then Y then press Enter.
Now shell commands should be working.
@robbiet480 I donât really have any real coding skills. But if there is nobody else looking into this. I want to try if i can achieve something. But let say if i have ps4-waker working in Python you can make a platform from it?
@jones ofcourse i want to tell you. But it is nothing fancy
1. Create a folder ps4cam
ok what is did is create a folder called ps4cam in
/home/homeassistant/.homeassistant/www/ps4cam/
and i filled it with images of games i play. The name is important. I saved them with a â1â followed by the current id of the game.
So i have files like this:
1CUSA01433.jpg
1CUSA02387.jpg
2.Create a folder ps4current
Create a folder ps4current with a currentgame.jpg file in it.
/home/homeassistant/.homeassistant/www/ps4current/
so the only thing in this folder is:
currentgame.jpg
(this can be any jpg file it doesnât matter.)
3. Add a sensor for current id of the game
You also need this sensor (with your ps4 ip address) it will show you the id of the game your playing like this CUSA01433.
platform: command_line
name: current id
command: ps4-waker search -d 192.168.1.21 | grep -w "running-app-titleid" | cut -c 27- | rev | cut -c 3- | rev | sed 's/^// '
4. Add a Shell Command
I added this command:
ps4_currentapp_update: "cp /home/homeassistant/.homeassistant/www/ps4cam/1{{ states.sensor.current_id.state }}.jpg /home/homeassistant/.homeassistant/www/ps4current/currentgame.jpg"
So what this does is it copies a file from the ps4cam folder with 1 + the game id as the name to the ps4current folder and renames it to currentgame.jpg.
5. Create an automation that changes the images when the current id sensor changes
Create this automation:
alias: PS4 - State change
trigger:
platform: state
entity_id: sensor.current_id
action:
- service: shell_command.ps4_currentapp_update
6. Last step; Add the camera
Now add an camera to your configuration like this:
platform: local_file
name: currently playing
file_path: /home/homeassistant/.homeassistant/www/ps4current/currentgame.jpg
Note: also add an image called 1.jpg to your ps4cam folder. This is the image that will be displayed when the PS4 is turned off.
As you can see this is not an very automated process. For every game you want to display you need to find an image and rename and save it yourself. It would be nice if there was some online database with images named after the app idâs Sony gives to their games. So the images could be pulled automatically