Native PlayStation 4 Component Discussion

Did you added the second ps4 with same account as first?

If i add my sons ps4 hassio keeps returning to config screen in hassio. But he sees home assistant in his app list. Naming it with the 4-2 does not help for me.

Difference with 1st ps4 :

1st is wired, second is wifi
1st i use my account , second i use his account.
1st is second gen ps4 , second ps4 is first gen.
1st you have to connect to second screen 1st. second does not give that option it starts in config.

*** Edit ***

Maybe it is better to read other post first. There was the sollution. It was indeed the account, you need to use same account as 1st ps4 to add it.

Thanks love this component

Are you selecting the Home-Assistant “PS4” in the app?

I am not even able to reach that place.

Same thing is happening with me now. When I try to select a source, I get a time out error:

Error log:

ERROR (MainThread) [homeassistant.components.websocket_api.http.connection.1855824720] [Errno 32] Broken pipe
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/homeassistant/components/websocket_api/commands.py", line 122, in handle_call_service
    connection.context(msg))
  File "/usr/local/lib/python3.7/site-packages/homeassistant/core.py", line 1138, in async_call
    self._execute_service(handler, service_call))
  File "/usr/local/lib/python3.7/site-packages/homeassistant/core.py", line 1160, in _execute_service
    await handler.func(service_call)
  File "/usr/local/lib/python3.7/site-packages/homeassistant/helpers/entity_component.py", line 188, in handle_service
    self._platforms.values(), func, call, service_name
  File "/usr/local/lib/python3.7/site-packages/homeassistant/helpers/service.py", line 314, in entity_service_call
    future.result()  # pop exception if have
  File "/usr/local/lib/python3.7/site-packages/homeassistant/helpers/service.py", line 328, in _handle_service_platform_call
    await getattr(entity, func)(**data)
  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 385, in select_source
    title_id, running_id=self._media_content_id)
  File "/usr/local/lib/python3.7/site-packages/pyps4_homeassistant/ps4.py", line 159, in start_title
    self._connection.start_title(title_id)
  File "/usr/local/lib/python3.7/site-packages/pyps4_homeassistant/connection.py", line 87, in start_title
    self._send_boot_request(title_id)
  File "/usr/local/lib/python3.7/site-packages/pyps4_homeassistant/connection.py", line 243, in _send_boot_request
    self._send_msg(msg, encrypted=True)
  File "/usr/local/lib/python3.7/site-packages/pyps4_homeassistant/connection.py", line 138, in _send_msg
    self._socket.send(msg)
BrokenPipeError: [Errno 32] Broken pipe```

Is it possible to get state to change faster? Mine change after 40-50sec. Is this normal?

Im looking at this, possibly changing the component to use asyncio.

From what state is it taking a long time to change to?
It also may be because of your lan speed. You can try pinging your ps4. If the time is very small ie. a second or less. The problem probably is with the component.

In my case the state is from “playing” to “off”. My PS4 is connected wireless so this could be the case. But when i used the PS4 addon that was earlier… it changed much faster with the same wireless connection.

The component does not assume states so it will wait for the PS4 to say that it is off. When putting into rest mode. The light on the ps4 should be blinking white for a bit. When it turns orange that is when you should expect the state to change.

I just tested and when it turns orange it takes 30-40sec before it changes state. I cant connect my PS4 to internet with cable. So if others that have there PS4 wireless and it uses the same time to change state, its just the way it is :blush:. If you dont have a great fix for it?

The same thing has just happened to me after noticing none of my automations were firing. I have have media_player.playstation_4_2.

Did you find a fix?

Nope. Same issue all time.
I delete my integration and add another time.

hello the component works correctly but when I switch off the playstation 4 and restart the home assistant the integration disappears and I have to redo the whole procedure, how can I solve it?

Same on my side.

PR created to solve this. Pending review

1 Like

I get the following error when I run media_player.turn_off and the device is not off… When it is on, it works great. Why would you do that you say. Basically it is part of my “all_off” script that runs when my presence is away or night. It blindly locks the doors, turns everything off. etc.

2019-05-02 07:13:23 ERROR (MainThread) [homeassistant.components.websocket_api.http.connection.1643823184] 
    Traceback (most recent call last):
      File "/opt/homeassistant/lib/python3.5/site-packages/homeassistant/components/websocket_api/commands.py", line 121, in handle_call_service
        connection.context(msg))
      File "/opt/homeassistant/lib/python3.5/site-packages/homeassistant/core.py", line 1138, in async_call
        self._execute_service(handler, service_call))
      File "/usr/lib/python3.5/asyncio/futures.py", line 380, in __iter__
        yield self  # This tells Task to wait for completion.
      File "/usr/lib/python3.5/asyncio/tasks.py", line 304, in _wakeup
        future.result()
      File "/usr/lib/python3.5/asyncio/futures.py", line 293, in result
        raise self._exception
      File "/usr/lib/python3.5/asyncio/tasks.py", line 239, in _step
        result = coro.send(None)
      File "/opt/homeassistant/lib/python3.5/site-packages/homeassistant/core.py", line 1160, in _execute_service
        await handler.func(service_call)
      File "/opt/homeassistant/lib/python3.5/site-packages/homeassistant/helpers/entity_component.py", line 194, in handle_service
        required_features
      File "/opt/homeassistant/lib/python3.5/site-packages/homeassistant/helpers/service.py", line 316, in entity_service_call
        future.result()  # pop exception if have
      File "/usr/lib/python3.5/asyncio/futures.py", line 293, in result
        raise self._exception
      File "/usr/lib/python3.5/asyncio/tasks.py", line 241, in _step
        result = coro.throw(exc)
      File "/opt/homeassistant/lib/python3.5/site-packages/homeassistant/helpers/service.py", line 337, in _handle_service_platform_call
        await getattr(entity, func)(**data)
      File "/usr/lib/python3.5/asyncio/futures.py", line 380, in __iter__
        yield self  # This tells Task to wait for completion.
      File "/usr/lib/python3.5/asyncio/tasks.py", line 304, in _wakeup
        future.result()
      File "/usr/lib/python3.5/asyncio/futures.py", line 293, in result
        raise self._exception
      File "/usr/lib/python3.5/concurrent/futures/thread.py", line 55, in run
        result = self.fn(*self.args, **self.kwargs)
      File "/opt/homeassistant/lib/python3.5/site-packages/homeassistant/components/ps4/media_player.py", line 355, in turn_off
        self._ps4.standby()
      File "/opt/homeassistant/lib/python3.5/site-packages/pyps4_homeassistant/ps4.py", line 159, in standby
        self.open()
      File "/opt/homeassistant/lib/python3.5/site-packages/pyps4_homeassistant/ps4.py", line 102, in open
        raise NotReady
    pyps4_homeassistant.errors.NotReady

I’m getting the same error, however I get immediately after starting te integration. So im not even getting to the pin entering screen. Also running hassio on a raspberry pi.

    Error handling request
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/aiohttp/web_protocol.py", line 418, in start
    resp = await task
  File "/usr/local/lib/python3.7/site-packages/aiohttp/web_app.py", line 458, in _handle
    resp = await handler(request)
  File "/usr/local/lib/python3.7/site-packages/aiohttp/web_middlewares.py", line 119, in impl
    return await handler(request)
  File "/usr/local/lib/python3.7/site-packages/homeassistant/components/http/real_ip.py", line 33, in real_ip_middleware
    return await handler(request)
  File "/usr/local/lib/python3.7/site-packages/homeassistant/components/http/ban.py", line 68, in ban_middleware
    return await handler(request)
  File "/usr/local/lib/python3.7/site-packages/homeassistant/components/http/auth.py", line 216, in auth_middleware
    return await handler(request)
  File "/usr/local/lib/python3.7/site-packages/homeassistant/components/http/view.py", line 115, in handle
    result = await result
  File "/usr/local/lib/python3.7/site-packages/homeassistant/components/config/config_entries.py", line 154, in post
    return await super().post(request, flow_id)
  File "/usr/local/lib/python3.7/site-packages/homeassistant/components/http/data_validator.py", line 46, in wrapper
    result = await method(view, request, *args, **kwargs)
  File "/usr/local/lib/python3.7/site-packages/homeassistant/helpers/data_entry_flow.py", line 86, in post
    result = await self._flow_mgr.async_configure(flow_id, data)
  File "/usr/local/lib/python3.7/site-packages/homeassistant/data_entry_flow.py", line 80, in async_configure
    flow, step_id, user_input)
  File "/usr/local/lib/python3.7/site-packages/homeassistant/data_entry_flow.py", line 98, in _async_handle_step
    result = await getattr(flow, method)(user_input)  # type: Dict
  File "/usr/local/lib/python3.7/site-packages/homeassistant/components/ps4/config_flow.py", line 62, in async_step_creds
    self.helper.get_creds)
  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/pyps4_homeassistant/helpers.py", line 41, in get_creds
    return credentials.listen()
  File "/usr/local/lib/python3.7/site-packages/pyps4_homeassistant/credential.py", line 71, in listen
    data = response[0]
UnboundLocalError: local variable 'response' referenced before assignment

Does this error stop the component completely, for example, you have to restart HA to get it working again? The ps4 does not communicate at all when off btw so that is the reason for the error.

HA & the component is fine… No restart necessary. I just moved it to the end with a condition check to see if it’s on. All good.

Simply reporting experience as all the other media_player, remotes, lights, etc turn off just fine even if they are already off.

I get an “unknown error occurred” when trying to configure. The home assistant ps4 doens’t show up when refreshing the devices list in the second screen app. I’m using docker and set network_mode: host. this is what shows up in the log:

Any suggestions?

OK I think the “unknown error occurred” is just because the connection is timing out. I checked helpers.py and credentials.py and they seem fine as is, but maybe you need to move the rest of the “it works” code into the try/except block. @daanwijffels i think we have the same error.

Now why the connection is timing out is another story. On my part I have checked that ports 987/997 aren’t in use, and the container has host networking. not sure what else I can check though.