Just wanted to show you, how to switch your ps4 on/off with ha & ps4-waker.
For the switch itself I use the Command-Line Switch to trigger the shell commands of ps4-waker.
Thanks for sharing. Iām having a bit of difficulty controlling the ps4 through HA. Iāve installed ps4-waker on my raspberry pi and I am able to wake and sleep the ps4 from the command line. However in HA it is always showing as off? I ran the command_state code in the command line and it does return ātrueā if the ps4 is on but it takes around 15 seconds to complete, is this normal?
Hi thank you for sharing! I am trying to set it up aswell.
I have now a switch that i can use to turn it on. But it goes back to off after a few seconds.
So i canāt use it to turn off the ps4.
This command should get the state if i understand well.
When i run this command on the pi it wil return true if ps4 is on. But when i run it in the virtual environment (where i installed hass) i get a message: permission denied and it will return false.
Yep. My system is RPI 2 with Raspbian jessie and hass installed using the all in one installer. But when i do that with the sudo in the virtual enviroment is asks for a password. But there is no password for hass user in the virtual enviroment.
I got mine to work by changing the command state to use nc instead of telnet, which in my case was much quicker at responding. The value template is not needed because nc will return 0 on success, 1 on failure.
The -z parameter tells netcat to scan for the open port, -w 5 tells netcat to timeout after 5 seconds otherwise it will wait endlessly. If testing in the command line is needed add -v for a more verbose output.
I just got the command_state to execute by changing nul to /dev/nul when i saw your post.
command_state: telnet 192.168.1.12 9295 | grep "Connected" > /dev/null && (echo "true") || (echo "false")
But i was messing arround with the value template but didnāt get it to work unfortunately.
So i did what you said and it is now working perfectly! thank you!
I installed netcat by:
I used the -c parameter to specify where the credentials are stored. Because it was originally stored at a location where from it could not be accessed from the virtual environment. So i copied it to my documents folder.
Maybe this can be some help for someone who is also trying to get this to work.
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