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

Component for Sony Bravia TV with Pre-Shared Key #12464

Merged
merged 2 commits into from
Feb 22, 2018
Merged

Component for Sony Bravia TV with Pre-Shared Key #12464

merged 2 commits into from
Feb 22, 2018

Conversation

gerard33
Copy link
Contributor

@gerard33 gerard33 commented Feb 16, 2018

Description:

Sony Bravia TVs of 2014 and later can be connected using a Pre-Shared Key (PSK) instead of the PIN method which is used in the current braviatv component.

Connecting with the TV using the PSK is a bit easier and also more reliable then the PIN method.
Besides that I have added some more features to this component:

  • It's possible to turn on Android TVs (besides non-Android TVs) using HA.
  • The source list can be filtered so only the frequently used channels and/or HDMI sources are shown.
  • When starting the TV via HA, the state card will show a message that the TV has started, but didn't receive any information from the TV yet (it takes the TV about 1 minute to respond with program information after starting, at least for my model).
  • If you have an amplifier connected to the TV, there is an option which prevents showing the volume slider as this slider only works for the built-in TV speakers.
  • This component uses a library (original version here) which I have updated to work with the PSK and is hosted on PyPi.

When using the built-in TV tuner:

  • The program info is shown on second line of state card, this will also show the start and end time of the program.
  • You can send commands to pause and play the TV program. This is only when you are watching programs with the built-in TV tuner, otherwise it will just pause and play e.g. with the Netflix app.
  • You can use the next and previous buttons for channel up and down. This is also only when you are watching programs with the built-in TV tuner, otherwise it will be the normal next and previous buttons.

See this topic on the HA forum for more details.

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

Example entry for configuration.yaml (if applicable):

media_player:
  - platform: braviatv_psk
    host: 192.168.1.191
    psk: sony
    mac: AA:BB:CC:DD:EE:FF
    amp: True
    android: False
    sourcefilter:
      - ' HD'
      - HDMI

Checklist:

  • The code change is tested and works locally.

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

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

  • Local tests with tox run successfully. Your PR cannot be merged unless tests pass
  • New dependencies have been added to the REQUIREMENTS variable (example).
  • New dependencies are only imported inside functions that use them (example).
  • New dependencies have been added to requirements_all.txt by running script/gen_requirements_all.py.
  • New files were added to .coveragerc.

If the code does not interact with devices:
- [ ] Local tests with tox run successfully. Your PR cannot be merged unless tests pass
- [ ] Tests have been added to verify that the new code works.

@thijsdejong
Copy link
Contributor

Would it not be possible to implement this into the current braviatv component?

@gerard33
Copy link
Contributor Author

@bakedraccoon The connection towards the TV using PIN and PSK is quite different.
Also the PIN method uses a cookie and a bravia.conf file, which for the PSK is not necessary. So it would be quite a messy library if both connection types need to be supported.

Besides that all models after 2014 which support an external connection seem to have support for PSK.
So the PIN functionallity is only needed for older TVs between 2013 (first models which support external connection) and 2014.

And when I used the bravia component with PIN I had a lot of issues, first with making a proper connection to the TV and once that was achieved, the connection was always lost after a few days.
That makes developing and testing a component which supports both PIN and PSK also a big challenge ;)

@gerard33 gerard33 changed the title [WIP] Component for Sony Bravia TV with Pre-Shared Key Component for Sony Bravia TV with Pre-Shared Key Feb 17, 2018
@lwis lwis merged commit 1af65f8 into home-assistant:dev Feb 22, 2018
@lwis
Copy link
Member

lwis commented Feb 22, 2018

Thanks! 🐊

@balloob balloob mentioned this pull request Feb 22, 2018
@gerard33 gerard33 deleted the braviatv_psk branch February 24, 2018 12:19
@balloob balloob mentioned this pull request Feb 25, 2018
@balloob
Copy link
Member

balloob commented Feb 25, 2018

This should not have been its own platform. Instead, this should have been part of the other bravia TV integration. The API is literally the same and it seems like a lot of code has been copy pasted. I've decided to pull this integration from release 0.64.

Please submit a new PR that combines PSK support into the original Bravia integration.

@lwis
Copy link
Member

lwis commented Feb 25, 2018

Sorry for merging, should the media_player.braviatv platform contain both authentication methods? @gerard33 is this something you can take a look at?

@gerard33
Copy link
Contributor Author

Understood, I will have a look at it.
Although I will need some help from someone with a working Bravia PIN connection to test if the updated platform still works as I couldn't get my TV working properly with it.

@balloob
Copy link
Member

balloob commented Feb 26, 2018

Since it's just 2 auth methods in front of the same API, it should indeed be part of braviatv. Would be best if we can get the auth merged upstream instead of having Home Assistant rely on 2 packages.

@mm7d
Copy link

mm7d commented Feb 27, 2018

I have a Bravia which supports both pin and psk. Testing both is no issue for me. I had no issues with pin before I moved my ha from a Mac mini to a 12 core 1u Dell with two network interfaces. On the mini I had one with multiple virtual nics/vlans and no WOL issues. Searching around I suddenly remembered that i had the WOL issue in my homebridge setup before I moved to ha. I patched that too.

@home-assistant home-assistant locked and limited conversation to collaborators May 29, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants