Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add component media player.ps4 #21074

Merged
merged 40 commits into from Feb 17, 2019

Conversation

Projects
None yet
7 participants
@ktnrg45
Copy link
Contributor

ktnrg45 commented Feb 14, 2019

Description:

Configures via config flow/integrations. Reopened from #20007 for bad rebase.
Add component media_player.ps4. Reopened new PR as commits were cluttered. @ #19469
This component grants control and state updates for a Sony PlayStation 4 console.
It masquerades as the official PS4 Second Screen App which is only possible after capturing the app's credential token and using a pin code from the PS4 to become an authorized device.

Pull request in home-assistant.io with documentation (if applicable): home-assistant/home-assistant.io#8146

Example entry for configuration.yaml (if applicable):

Does not support entries from configuration.yaml

Checklist:

  • The code change is tested and works locally.
  • Local tests pass with tox. Your PR cannot be merged unless tests pass
  • There is no commented out code in this PR.

If user exposed functionality or configuration variables are added/changed:

If the code communicates with devices, web services, or third-party tools:

  • New dependencies have been added to the REQUIREMENTS variable (example).
  • New dependencies are only imported inside functions that use them (example).
  • New or updated dependencies have been added to requirements_all.txt by running script/gen_requirements_all.py.
  • New files were added to .coveragerc.
  • Tests have been added to verify that the new code works.

@ktnrg45 ktnrg45 requested a review from home-assistant/core as a code owner Feb 14, 2019

@wafflebot wafflebot bot added the in progress label Feb 14, 2019

Show resolved Hide resolved homeassistant/components/ps4/config_flow.py Outdated
Show resolved Hide resolved homeassistant/components/ps4/media_player.py Outdated
Show resolved Hide resolved homeassistant/components/ps4/media_player.py Outdated
Show resolved Hide resolved homeassistant/components/ps4/media_player.py Outdated
Show resolved Hide resolved homeassistant/components/ps4/media_player.py Outdated
Show resolved Hide resolved homeassistant/components/ps4/media_player.py Outdated
Show resolved Hide resolved homeassistant/components/ps4/media_player.py
Show resolved Hide resolved homeassistant/components/ps4/media_player.py
Show resolved Hide resolved homeassistant/components/ps4/media_player.py Outdated
@Kane610
Copy link
Contributor

Kane610 left a comment

If you don't plan to add tests to all files you should explicitly add them to .coveragerc

@ktnrg45

This comment has been minimized.

Copy link
Contributor Author

ktnrg45 commented Feb 15, 2019

If you don't plan to add tests to all files you should explicitly add them to .coveragerc

OK added init.py and media_player.py to coveragerc. Config flow test finally passed Tox. Should be good now.

@ktnrg45

This comment has been minimized.

Copy link
Contributor Author

ktnrg45 commented Feb 16, 2019

@Kane610 thanks for the help!

@MartinHjelmare
Copy link
Member

MartinHjelmare left a comment

Return the correct value when patching the library methods for all tests.

Show resolved Hide resolved .coveragerc
Show resolved Hide resolved tests/components/ps4/test_config_flow.py
Show resolved Hide resolved tests/components/ps4/test_config_flow.py Outdated
Show resolved Hide resolved tests/components/ps4/test_config_flow.py Outdated
Show resolved Hide resolved tests/components/ps4/test_config_flow.py Outdated
@MartinHjelmare

This comment has been minimized.

Copy link
Member

MartinHjelmare commented Feb 16, 2019

The access mode is still changed on .coveragerc to 755.

@ktnrg45

This comment has been minimized.

Copy link
Contributor Author

ktnrg45 commented Feb 16, 2019

The access mode is still changed on .coveragerc to 755.

Where do I find this? So i just need to revert? What entries should be in there?

@MartinHjelmare

This comment has been minimized.

Copy link
Member

MartinHjelmare commented Feb 16, 2019

Go to https://github.com/home-assistant/home-assistant/pull/21074/files.

On the header bar above the text content of .coveragerc you see that it says that the access mode has changed from 644 to 755. These are Unix access modes.

How you change those depends on your OS.

@ktnrg45

This comment has been minimized.

Copy link
Contributor Author

ktnrg45 commented Feb 17, 2019

Oh ok. Yeah Ill do that sometime today.

ktnrg45 added some commits Feb 14, 2019

ktnrg45 added some commits Feb 15, 2019

Revert "remove init"
This reverts commit b68996a.
Show resolved Hide resolved homeassistant/components/ps4/config_flow.py Outdated
Show resolved Hide resolved tests/components/ps4/test_config_flow.py Outdated
Show resolved Hide resolved tests/components/ps4/test_config_flow.py Outdated
Show resolved Hide resolved tests/components/ps4/test_config_flow.py Outdated
Show resolved Hide resolved tests/components/ps4/test_config_flow.py Outdated

ktnrg45 added some commits Feb 17, 2019

@MartinHjelmare
Copy link
Member

MartinHjelmare left a comment

Nice!

@ktnrg45 ktnrg45 referenced this pull request Feb 17, 2019

Merged

Add docs for media_player.ps4 component #8146

2 of 2 tasks complete
@MartinHjelmare

This comment has been minimized.

Copy link
Member

MartinHjelmare commented Feb 17, 2019

Can be merged when build passes.

@ktnrg45

This comment has been minimized.

Copy link
Contributor Author

ktnrg45 commented Feb 17, 2019

Can be merged when build passes.

Cool! Thanks.

@simonk83

This comment has been minimized.

Copy link

simonk83 commented Feb 17, 2019

Nice work guys.

Now I, like a lot of people I imagine, am using the previous workaround get the PS4 working. Is there anything we need to do specifically to get ready for this? I assume just get rid of the ps4waker stuff we've added along with PS4.py in the custom_components folder?

@ktnrg45

This comment has been minimized.

Copy link
Contributor Author

ktnrg45 commented Feb 17, 2019

Nice work guys.

Now I, like a lot of people I imagine, am using the previous workaround get the PS4 working. Is there anything we need to do specifically to get ready for this? I assume just get rid of the ps4waker stuff we've added along with PS4.py in the custom_components folder?

Yes. Anything you have used before needs to be deleted. If you are running ps4waker it will conflict with the component.

@cgarwood cgarwood merged commit 72ef967 into home-assistant:dev Feb 17, 2019

4 checks passed

Hound No violations found. Woof!
cla-bot Everyone involved has signed the CLA
continuous-integration/travis-ci/pr The Travis CI build passed
Details
coverage/coveralls Coverage increased (+0.01%) to 92.796%
Details

@wafflebot wafflebot bot removed the in progress label Feb 17, 2019

@UnrealKazu UnrealKazu referenced this pull request Feb 18, 2019

Merged

Add Docker specific explanation for PS4 component #8629

2 of 2 tasks complete
@simonk83

This comment has been minimized.

Copy link

simonk83 commented Mar 4, 2019

Hey @ktnrg45, this appears to be working fine (I'm on 0.89.0b1), however the only thing that doesn't quite seem to be working is turning the PS4 back on from rest mode. The card in HA shows the state as Unknown, and clicking start doesn't seem to do anything. If I turn on the PS4 manually, everything else with the component works as expected.

Actually just noticed some errors in HA:

Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/homeassistant/helpers/service.py", line 289, 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 345, in turn_off
    self._ps4.standby()
  File "/usr/local/lib/python3.7/site-packages/pyps4_homeassistant/ps4.py", line 93, in standby
    self.open()
  File "/usr/local/lib/python3.7/site-packages/pyps4_homeassistant/ps4.py", line 52, in open
    if self.is_standby():
  File "/usr/local/lib/python3.7/site-packages/pyps4_homeassistant/ps4.py", line 185, in is_standby
    return True if self.get_host_status() == self.STATUS_STANDBY else False
  File "/usr/local/lib/python3.7/site-packages/pyps4_homeassistant/ps4.py", line 171, in get_host_status
    return self.get_status()['status_code']
  File "/usr/local/lib/python3.7/site-packages/pyps4_homeassistant/ps4.py", line 72, in get_status
    return get_status(self._host)
  File "/usr/local/lib/python3.7/site-packages/pyps4_homeassistant/ddp.py", line 111, in get_status
    ps_list = search(host=host)
  File "/usr/local/lib/python3.7/site-packages/pyps4_homeassistant/ddp.py", line 100, in search
    data, addr = _send_recv_msg(host, broadcast, msg)
  File "/usr/local/lib/python3.7/site-packages/pyps4_homeassistant/ddp.py", line 89, in _send_recv_msg
    return sock.recvfrom(1024)
socket.timeout: timed out
Log Details (WARNING)
Mon Mar 04 2019 13:35:56 GMT+1100 (Australian Eastern Daylight Time)
PS4 could not be reached
@MartinHjelmare

This comment has been minimized.

Copy link
Member

MartinHjelmare commented Mar 4, 2019

Please open an issue if you suspect a bug.

If you want to suggest an enhancement please open a feature request in the Feature Requests section of our community forum.

Merged PRs should not be used for enhancement discussion or bug reports. If you've found a bug it's ok to make a review with inline comments and link to an issue that reports the bug.

Thanks!

@home-assistant home-assistant locked as resolved and limited conversation to collaborators Mar 4, 2019

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
You can’t perform that action at this time.