Preview: Native PlayStation 4 Component

media_player
Tags: #<Tag:0x00007f20584d37d8>

#1

PS4 Component is available now on dev branch. Should be included in the 0.89 release.

This is based off of the node.js package PS4-Waker and the Python module pyps4. The dependency for this component is a modified fork of pyps4.

This component is structured very differently than the custom components posted on here. No dealing with ps4-waker, more reliable art-work fetching, no configuration.yaml, no constant exceptions (hopefully).

Features:

  • Integration configuration for fetching credentials and initial setup
  • Turn off and on
  • Shows states
  • Select app/game
  • Service to emulate button presses
  • Auto-management and fetching of games and cover art

Instructions:
Please read the docs linked below before starting.

For more info see docs.


Playstation 4/PS4 custom component
#2

I’ll have a look tonight!


#3

This looks great! I hope it will be in a stable release soon.
I wish I could test it, but I’m running HassOS. :frowning:


#4

I woul like to try it, but i cant find this file

I’m on hass.io on ubuntu 18.04


#5

yea, I can’t find it either. Im not sure we can using a docker.


#6

Hi. Have you managed to make it work?


#7

No, I’ve only reviewed the code


#8

@Ktnrg45 i have added all files and change the config_entries.py, the PlayStation 4 integration is available in dashboard but when i click it, only what i see is “color” circle spinning.
I have HA in docker (Synology NAS).
Any suggestion?
OK, i have error log:
2019-02-12 19:33:26 ERROR (MainThread) [aiohttp.server] Error handling request
Traceback (most recent call last):
File “/config/deps/lib/python3.6/site-packages/pyps4_homeassistant/helpers.py”, line 51, in port_bind
sock.bind((‘0.0.0.0’, port))
OSError: [Errno 98] Address already in use

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/aiohttp/web_protocol.py", line 418, in start
    resp = await task
  File "/usr/local/lib/python3.6/site-packages/aiohttp/web_app.py", line 458, in _handle
    resp = await handler(request)
  File "/usr/local/lib/python3.6/site-packages/aiohttp/web_middlewares.py", line 119, in impl
    return await handler(request)
  File "/usr/src/app/homeassistant/components/http/real_ip.py", line 34, in real_ip_middleware
    return await handler(request)
  File "/usr/src/app/homeassistant/components/http/ban.py", line 67, in ban_middleware
    return await handler(request)
  File "/usr/src/app/homeassistant/components/http/auth.py", line 99, in auth_middleware
    return await handler(request)
  File "/usr/src/app/homeassistant/components/http/view.py", line 118, in handle
    result = await result
  File "/usr/src/app/homeassistant/components/config/config_entries.py", line 111, in post
    return await super().post(request)
  File "/usr/src/app/homeassistant/components/http/data_validator.py", line 47, in wrapper
    result = await method(view, request, *args, **kwargs)
  File "/usr/src/app/homeassistant/helpers/data_entry_flow.py", line 57, in post
    handler, context={'source': config_entries.SOURCE_USER})
  File "/usr/src/app/homeassistant/data_entry_flow.py", line 64, in async_init
    return await self._async_handle_step(flow, flow.init_step, data)
  File "/usr/src/app/homeassistant/data_entry_flow.py", line 98, in _async_handle_step
    result = await getattr(flow, method)(user_input)  # type: Dict
  File "/usr/src/app/homeassistant/components/ps4/config_flow.py", line 41, in async_step_user
    failed = await self.hass.async_add_executor_job(helper.port_bind)
  File "/usr/local/lib/python3.6/concurrent/futures/thread.py", line 56, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/config/deps/lib/python3.6/site-packages/pyps4_homeassistant/helpers.py", line 54, in port_bind
    raise pyps4.errors.PortBindError
pyps4_homeassistant.errors.PortBindError

#9

I tried this component on HA 0.88b0 and it works great (I didn’t change the media_player.py file name to ps4.py).
image


#11

I just get the grey box with spinning circle when clicking configure.

Traceback (most recent call last):
  File "/srv/homeassistant/lib/python3.6/site-packages/aiohttp/web_protocol.py", line 418, in start
    resp = await task
  File "/srv/homeassistant/lib/python3.6/site-packages/aiohttp/web_app.py", line 458, in _handle
    resp = await handler(request)
  File "/srv/homeassistant/lib/python3.6/site-packages/aiohttp/web_middlewares.py", line 119, in impl
    return await handler(request)
  File "/srv/homeassistant/lib/python3.6/site-packages/homeassistant/components/http/real_ip.py", line 34, in real_ip_middleware
    return await handler(request)
  File "/srv/homeassistant/lib/python3.6/site-packages/homeassistant/components/http/ban.py", line 67, in ban_middleware
    return await handler(request)
  File "/srv/homeassistant/lib/python3.6/site-packages/homeassistant/components/http/auth.py", line 99, in auth_middleware
    return await handler(request)
  File "/srv/homeassistant/lib/python3.6/site-packages/homeassistant/components/http/view.py", line 118, in handle
    result = await result
  File "/srv/homeassistant/lib/python3.6/site-packages/homeassistant/components/config/config_entries.py", line 111, in post
    return await super().post(request)
  File "/srv/homeassistant/lib/python3.6/site-packages/homeassistant/components/http/data_validator.py", line 47, in wrapper
    result = await method(view, request, *args, **kwargs)
  File "/srv/homeassistant/lib/python3.6/site-packages/homeassistant/helpers/data_entry_flow.py", line 57, in post
    handler, context={'source': config_entries.SOURCE_USER})
  File "/srv/homeassistant/lib/python3.6/site-packages/homeassistant/data_entry_flow.py", line 64, in async_init
    return await self._async_handle_step(flow, flow.init_step, data)
  File "/srv/homeassistant/lib/python3.6/site-packages/homeassistant/data_entry_flow.py", line 98, in _async_handle_step
    result = await getattr(flow, method)(user_input)  # type: Dict
  File "/srv/homeassistant/lib/python3.6/site-packages/homeassistant/components/ps4/config_flow.py", line 47, in async_step_user
    helper.port_bind, ports)
  File "/usr/lib/python3.6/concurrent/futures/thread.py", line 56, in run
    result = self.fn(*self.args, **self.kwargs)
TypeError: port_bind() takes 1 positional argument but 2 were given

#12

@Bartem this is sth similar to my error.


#13

Sorry about the wait. The PR is approved. So should be releasing soon. For those who were experiencing errors it was because there was changes requested to the library.


#14

Your NAS may be using ports 987 and/or 997. The component requires these 2 ports. You can try rebooting your NAS and check again.


#15

I tried updating with your changes… maybe I messed something else… but I was able to connect a pair second screen… but now get this.

019-02-15 21:19:06 ERROR (MainThread) [homeassistant.loader] Error loading homeassistant.components.media_player.ps4. Make sure all dependencies are installed
Traceback (most recent call last):
  File "/srv/homeassistant/lib/python3.6/site-packages/homeassistant/loader.py", line 117, in _load_file
    module = importlib.import_module(path)
  File "/usr/lib/python3.6/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 994, in _gcd_import
  File "<frozen importlib._bootstrap>", line 971, in _find_and_load
  File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 678, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/srv/homeassistant/lib/python3.6/site-packages/homeassistant/components/media_player/ps4.py", line 17, in <module>
    from homeassistant.components.media_player.const import (
ModuleNotFoundError: No module named 'homeassistant.components.media_player.const'
2019-02-15 21:19:06 ERROR (MainThread) [homeassistant.loader] Unable to find platform ps4
2019-02-15 21:19:06 ERROR (MainThread) [homeassistant.setup] Unable to prepare setup for platform media_player.ps4: Platform not found.