Thanks for this!
Can you try
sudo find / -name "*ps4-wake.credentials*"
Perhaps your credentials file is not located there
I created a custom media player instead of all of the custom switches, but it still uses the ps4-waker tool.
https://github.com/hmn/home-assistant-config/blob/master/custom_components/media_player/ps4.py
Any feedback is apreciated
@hmn that sounds really cool. About to start playing with it. How do you declare it in configuration.yaml? Is it autodiscovered?
you just create a media_player like this
media_player:
- platform: ps4
host: 10.254.2.191
This looks incredible! Sorry to be such a noob, but where do I add the .py file? Do I just add it to my .homeassistant folder where my configuration.yaml is?
look at the file structure in https://github.com/hmn/home-assistant-config you just have to add the custom_components folder to your config dir
itās also described here https://home-assistant.io/developers/component_loading/
Ah brilliant, itās up and running!
Weirdly though it looks like I canāt wake/unwake the ps4 anymore. When I use
sudo ps4-waker
from ssh, it works fineā¦ but my switch and media player donāt turn the ps4 on or off respectively.
Is there a setting somewhere I need to tweak?
I use docker so it might be why I donāt need to sudo, try changing the command in the module to sudo ps4-waker
I changed the bit just after ācmd=ā to add sudo (in the python script) and it didnāt work. Although I did also change the command in the switch to sudo too, as below:
switch:
- platform: command_line
switches:
playstation_4:
command_on: āsudo ps4-wakerā
command_off: āsudo ps4-waker standbyā
command_state: 'nmap -p 9295 my_ps4_ip_address | grep -w -Eo āopenā ā
value_template: ā{{ value == āopenā }}ā
friendly_name: āPlaystation 4ā
and that didnāt work either. Itās really bizzare, it was working this morning! This leads me to believe maybe something else is going on.
Iāve updated my node-js to the latest stable release too, as others mentioned in this thread.
Thanks for your help on this, us noobs greatly appreciate it! Also Iām learning python atm so this is a great .py script to start with!
Edit: Just followed some instructions above that got me into /root/ on my pi and change visudo. Did all that and my switch now works - woo! Media player recognises the ps4 when itās on, but the on/off button doesnāt quite work. For now Iām just going to disable it and Iāll try again later.
Iām only 4 days into using Home Assistant but Iām incredibly impressed at the amazing work from all contributors!
@hmn , Iāve tried your script and it works flawlessly so far. My only issue was that my credentials
file was stored at /home/homeassistant/
and not /home/homeassitant/.homeassistant/
.
I would love to add button controls inside the PS4 media player front end so you can navigate simple applications such as YouTube and Netfilx. I will try work on it to help out.
It looks like I keep getting this error:
17-04-26 16:09:57 ERROR (Thread-9) [homeassistant.components.switch.command_line] Command failed: nmap -p 9295 PS4_IP_ADDRESS | grep -w -Eo āopenā
Not sure why this is erroring since my ps4 waker actually works from the switch. nmap is installed too.
Someone has posted the answer above:
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.
I tried all that and just double checked, and itās definitely all done. Just checked visudo and all those edits are completed, same with the cd /etc/sudoers.d folder contents.
I did all that and the switch started working, but the media player still wonāt budge.
This looks nice! What does the ps4-games.json file look like?
Would love to see an official PR.
the ps4-games.json is auto updated every time you start a game and it looks like this
{
"CUSA01116": "YouTube",
"CUSA02676": "DRTV",
"CUSA02491": "Mass Effect\u2122",
"CUSA01703": "Plex", "CUSA00127": "Netflix"
}
I can add it to the main project and create a pull request, but I was unsure if it was a good idea because of the ps4-waker requirements
Yeah, I forgot about that. Being that itās not in Python I doubt it would be allowed.
I run in Docker and use a different default port, anyway I can specify that in the configuration.yaml?
Edit: Add to schema and then adjust on line 203-ish? Is that it? testing now.
I added an option to specify the port but it doesnāt seem to register the proper state of the PS4