Native PlayStation 4 Component Discussion

You should run the command on /usr/bin/pythong3.6 then but be careful with the type of quotes. You have “curly” quotes there and you need straight ones. Having curly quotes will lead to the error you see.

sudo setcap 'cap_net_bind_service=+ep' /usr/bin/python3.6

I’m not that familiar with doing things like that sorry.

Something like this would be fine. Just something to show that the PS4 is actually turned on. I use mini-media-player, and it looks the same when idle as it does when off.

1 Like

Yeah, about that. Could you please be more specific? What dimensions or aspect ratio the image should be to fit the media player “window”?

Hi @Ktnrg45
I’ve looked into the code quickly without being too familiar with the setup of HA.

During testing I figured out that the default media_player select_source-service worked fine.

Just needed to add some short stuff in ps4/media_player.py to get what I want:

Thanks for the tip!
Will look into it.
But I have no python3.6 in my usr/bin, only a python3.4
I use a virtual environment in which a python3.6 is active.
Should I use the python3.4? Or the one in my virt env.
Still a bit puzzled about how this works with the virt env :slight_smile:

Thanks!!!
Br
Raymond

I use a venv too. What I found though that my python in the venv was just a link to the system one

   > readlink -f /srv/homeassistant/bin/python
   /usr/bin/python3.6

try running that in your venv to see where Python is. If it’s a real binary in your venv and not a symlink then, yes, use setcap on that. Otherwise, use it on wherever python is actually installed.

ConanScott, thank you very much!

readlink -f /srv/homeassistant/bin/python

Got me:

/usr/local/bin/python3.6

So i entered the command:

sudo setcap ‘cap_net_bind_service=+ep’ /usr/local/bin/python3.6

Which worked!

I hope this will help others too.

@Ktnrg45, maybe you can expand the documentation to include this?

thanks all,
br,
Raymond

2 Likes

Id just leave that to an automation.

I have no idea. This will have to be approved by the devs btw. Id ask one of them. Maybe you can use lovelace to do this.

Cool! Glad you got that working. Ill update the docs with that.

Yup. Got some good feedback on using scripts and wait_template(state) so I’ve closed the PR. Will post the full solution here when I got the time to finish up the script and automation.

Is it possible to create something like a switch in order to play a specific game by google home?
For example: “Hey Google let’s play to FIFA19”

Switch template component then ifttt is probably easiest.

I use Echo for my voice control but the principal should be the same; create a script to launch a game then create a scene that launches the script.

From scripts.yaml;

fifa18:
  alias: 'FIFA 18'
  sequence:
  - service: switch.turn_on
    entity_id: switch.media_centre
  - service: remote.send_command
    data:
      entity_id: remote.lounge
      device: '49359464'
      command: 'InputHdmi2'
      num_repeats: 3
      delay_secs: 3
  - service: media_player.turn_on
    entity_id: media_player.playstation_4
  - wait_template: "{{ is_state('media_player.playstation_4', 'idle') }}"
  - service: ps4.send_command
    data:
      entity_id: media_player.playstation_4
      command: ps
  - service: media_player.select_source
    data:
      entity_id: media_player.playstation_4
      source: 'FIFA 18'

The switch turns on my media centre plug (tv, speakers, backlights), and the remote command sets the source for the PS4. You may not want/need these. I found the PS4 can take some time to wake up so the 12 second delay wait template gives it enough time from being turned on to getting to the “press ps button” screen. I habitually quit games after playing them as I played Elite Dangerous a lot which had a habit of crashing if you didn’t quit it before putting the PS4 into rest mode. You may want a further delay and then a ps4.send_command: enter if you don’t do this.

From scenes.yaml;

- name: Football
  entities:
    script.fifa18:
      state: on

Then I just say “echo, turn on football”.

Hmm, I’m getting mixed results for the ps command. I’m sure this will work itself out.

4 Likes

exactly what I was looking for, thanks!

Sometimes the PS command doesn’t work.
What about add the template delay on the status but also a delay of 5 seconds, just to be sure?

What you mean with: ps4.send_command: ok
What is the purpose of this command?

Yeah as I mentioned I was having mixed results last night. However this morning it worked perfectly for RDR2. The ps command should actually be “enter”; this is only needed if you are starting a different game to the one you had running before you went into rest mode.

First, thanks for this awesome component! Does anyone know how to disable the endless stream of Companion App connected/disconnected notifications on the PS4 side? Is this a configuration issue on my end?

2 Likes

Tip for anyone creating switches or commands to run a game, if the game title has a : in it change the game name in the file .ps4-games.json in config folder as HA does not like the colon! i.e. Call of duty: Modern Warfare change to Call of duty Modern Warfare

New intregation is working for me on 1st ps4. But how can i add my second PS4? It is not possible it says it is all ready configured…