Playstation 4/PS4 custom component

Does anyone know if there is a way to automatically login with a defined user ? With this custom component, my PS4 turns on but waits on the user selection on the login screen. Is there a way to bypass that ? I don’t need to do that when I manually turn on my PS4 or use the PS4 second screen app.

Google search is your friend:

Thanks for your answer, but my PS4 is already configured to automatically sign me in (only user) when the system is switched on. As said in my previous post, it does sign me in when I manually power on the PS4, or use the PS4 second screen app to turn it on.
However, when I use the HomeAssistant component, the system turns on but it asks me to press the “PS” button of the remote, and then choose the user.

Woo!

https://github.com/home-assistant/home-assistant/pull/21074

Awesome work @Ktnrg45

This custom_component is broken in 0.88.

1 Like

Think you can patch the ps4.py script like that :

Replace this (around line 10 or 11)

from homeassistant.components.media_player import (
ENTITY_IMAGE_URL, MEDIA_TYPE_CHANNEL, MediaPlayerDevice, PLATFORM_SCHEMA,
SUPPORT_SELECT_SOURCE, SUPPORT_STOP, SUPPORT_TURN_OFF, SUPPORT_TURN_ON,
)

with that

from homeassistant.components.media_player import ( DOMAIN,
MediaPlayerDevice, PLATFORM_SCHEMA, ENTITY_IMAGE_URL)
from homeassistant.components.media_player.const import (
MEDIA_TYPE_CHANNEL, SUPPORT_SELECT_SOURCE, SUPPORT_STOP, SUPPORT_TURN_OFF, SUPPORT_TURN_ON
)

Thanks I’ll try and report^

I Changed to:

"""Playstation 4 media_player using ps4-waker."""
import json
import logging
import socket
from datetime import timedelta

import voluptuous as vol

import homeassistant.util as util
from homeassistant.components.media_player 
import ( DOMAIN, MediaPlayerDevice, PLATFORM_SCHEMA, ENTITY_IMAGE_URL)
from homeassistant.components.media_player.const import ( 
    MEDIA_TYPE_CHANNEL, SUPPORT_SELECT_SOURCE, SUPPORT_STOP, SUPPORT_TURN_OFF, SUPPORT_TURN_ON )
from homeassistant.const import (
    CONF_FILENAME, CONF_HOST, CONF_NAME, STATE_IDLE, STATE_OFF, STATE_PLAYING,
    STATE_UNKNOWN,
)
from homeassistant.helpers import config_validation as cv
from homeassistant.util.json import load_json, save_json

That did it!

thanks!

1 Like

I updated the custom component with the latest ps4.py file but now I get the following error when I do a config check. Any idea where this is coming from?

WARNING:homeassistant.helpers.config_validation:Your configuration contains extra keys that the platform does not support.
Please remove [cmd].

My config looks like:

  • platform: ps4
    name: ‘Playstation 4’
    host: 192.168.1.114
    cmd: ‘sudo ps4-waker’
    filename: ‘ps4-wake.credentials.json’
    games_filename: ‘ps4-games.json’

I’m getting the same warning.

- platform: ps4
host: 192.168.1.11
name: “PS4”
cmd: ‘ps4-waker’
filename: ‘/config/.ps4-wake.credentials.json’
games_filename: ‘/config/ps4-games.json’

thank you for this, the edit in your post solved it for me as well!

2 Likes

Will this component come with 0.89?

It should!! I’m going on the podcast after experimenting with the beta that comes out this week, to discuss it so I hope so!

2 Likes

Will this remove the need to have node and ps4waker installed?

If “yes”, my excitement for this will double! :slight_smile:

Yes, as far as I understand from following the pull request.

This is awesome. I love the Home Assistant community. I search to see if a component is available for PS4 and I find out that it will probably be in the next release of Home Assistant!

I deleted the “cmd” line and it works again

I’m having an error (running hass.io and beta) and not sure where to best put it. Should I open an issue in Github?
Error handling message: {‘type’: ‘call_service’, ‘domain’: ‘ps4’, ‘service’: ‘send_command’, ‘service_data’: {‘entity_id’: ‘media_player.george’, ‘command’: ‘enter’}, ‘id’: 32}
Traceback (most recent call last):
File “/usr/local/lib/python3.7/site-packages/homeassistant/components/websocket_api/decorators.py”, line 17, in _handle_async_response
await func(hass, connection, msg)
File “/usr/local/lib/python3.7/site-packages/homeassistant/components/websocket_api/commands.py”, line 147, in handle_call_service
connection.context(msg))
File “/usr/local/lib/python3.7/site-packages/homeassistant/core.py”, line 1133, in async_call
self._execute_service(handler, service_call))
File “/usr/local/lib/python3.7/site-packages/homeassistant/core.py”, line 1157, in _execute_service
await self._hass.async_add_executor_job(handler.func, service_call)
File “/usr/local/lib/python3.7/concurrent/futures/thread.py”, line 57, in run
result = self.fn(*self.args, **self.kwargs)
File “/usr/local/lib/python3.7/site-packages/homeassistant/components/ps4/media_player.py”, line 82, in service_command
device.send_command(command)
File “/usr/local/lib/python3.7/site-packages/homeassistant/components/ps4/media_player.py”, line 372, in send_command
self._ps4.remote_control(command)
File “/usr/local/lib/python3.7/site-packages/pyps4_homeassistant/ps4.py”, line 136, in remote_control
self._connection.login()
File “/usr/local/lib/python3.7/site-packages/pyps4_homeassistant/connection.py”, line 66, in login
self._send_login_request()
File “/usr/local/lib/python3.7/site-packages/pyps4_homeassistant/connection.py”, line 194, in _send_login_request
self._send_msg(msg, encrypted=True)
File “/usr/local/lib/python3.7/site-packages/pyps4_homeassistant/connection.py”, line 109, in _send_msg
self._socket.send(msg)
BrokenPipeError: [Errno 32] Broken pipe

Could you please share your entire ps4.py code ?
I think I used a older version and the changes you propose for hassio 0.88 do not work in my case.
Thanks !

Which original version of the ps4.py component did you use ?

Anyone else having problem with PS4 changing state from “playing” to “off” every 2-3 minute when playing games?

1 Like