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

Support for Sony Bravia TV #2243

Merged
merged 18 commits into from
Jun 20, 2016
Merged

Support for Sony Bravia TV #2243

merged 18 commits into from
Jun 20, 2016

Conversation

antonioparraga
Copy link
Contributor

@antonioparraga antonioparraga commented Jun 5, 2016

Description:
The braviatv platform allows you to control a Sony Bravia TV.

To add a Sony Bravia TV to your installation, add the following to your configuration.yaml file:

# Example configuration.yaml entry
media_player:
  platform: braviatv
  host: 192.168.5.22
  name: Living Room TV

Configuration variables:

  • host (Required): The IP of the Sony Bravia TV, eg. 192.168.5.22
  • name (Optional): The name you would like to give to the Sony Bravia TV.

You will need to configure your TV to allow the Home Assistant for remote usage. To do that, ensure that your TV is turned on. Open the configuration popup on Home Assistant and enter whatever PIN (for example, 0000). After that, the TV will show you a PIN and the Home Assistant will allow you to re-enter a new PIN. Enter the PIN shown on your TV and your Home Assistant will be allowed for remote usage on your Sony Bravia TV.

Supported almost all Sony Bravia TV 2013 and newer at http://info.tvsideview.sony.net/en_ww/home_device.html#bravia

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

Example entry for configuration.yaml (if applicable):

# Example configuration.yaml entry
media_player:
  platform: braviatv
  host: 192.168.5.22
  name: Living Room TV

Checklist:

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

If code communicates with devices:

  • 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.

@rmkraus
Copy link
Contributor

rmkraus commented Jun 6, 2016

This platform contains a lot of logic for communicating with the TV. It would be best to split this out into a separate library and add that library as a dependency.

Nice use of the configurator component, though. 👍 That one definitely goes under-appreciated.

@antonioparraga
Copy link
Contributor Author

antonioparraga commented Jun 6, 2016

Thank you regarding the configurator usage. I think that the configurator is a great piece for this kind of use cases. You should work on improving it to support more scenarios.
Regarding your comment about moving out this guy to a library, what's your suggestion? I mean, do we need to move this piece of code to a separate library before going merged into dev?

@@ -0,0 +1,521 @@
# flake8: noqa
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nop

@balloob
Copy link
Member

balloob commented Jun 9, 2016

Yeah.

We don't want any protocol parsing etc in this repo. That way other people that do not use HA will not be able to leverage your work and we will have to maintain protocol upgrades.

@antonioparraga
Copy link
Contributor Author

Ok, the code has been updated according to your suggestions.
Thank you!

@balloob
Copy link
Member

balloob commented Jun 12, 2016

It looks good. Please rebase on the latest dev branch to resolve your merge conflicts.

@antonioparraga
Copy link
Contributor Author

Ok, done!

@balloob
Copy link
Member

balloob commented Jun 13, 2016

You didn't rebase but merged the branch. Now it shows 23 files changed and I can no longer verify which changes this PR brings. Please fix it 👍

@antonioparraga
Copy link
Contributor Author

Ops, sorry! fixed!

@antonioparraga antonioparraga force-pushed the dev branch 2 times, most recently from 7f0bf64 to ecf228f Compare June 15, 2016 04:58
@@ -1 +1 @@
Subproject commit 0e6dc25fcd09ad1150aab258f8d01491a8ee8db7
Subproject commit 77f4dd1fed3d29c7ad8960c704a748af80748a59
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove this from your PR.

@antonioparraga
Copy link
Contributor Author

Ok, done! Please review it again to check if everything looks cool now!

@balloob
Copy link
Member

balloob commented Jun 20, 2016

Yep, all cool! 🐬 ⛄ 🌴

@balloob balloob merged commit cbc0833 into home-assistant:dev Jun 20, 2016
@dennuuz
Copy link

dennuuz commented Jun 24, 2016

Hi Aparraga,

Many thanks for building this component! It's (almost) working great! I copied the code to my custom sensor folder for now.

I have a Sony Bravia KDL myself, connected to my WIFI network. When my TV is turned on, everything works great, however, when it's turned off the below error message is logged. This is obviously caused by the braviarc submitting a request while the host is not available.

I started to fiddle around a bit myself to see whether i can first ping the host before submitting the request but haven't been able to solve it so far.

You help would be appreciated.

Jun 23 19:48:09 raspberrypi hass[5165]: ERROR:braviarc.braviarc:[W] Exception: HTTPConnectionPool(host='192.168.2.107', port=80): Max retries exceeded with url: /sony/accessControl (Caused by ConnectTimeoutError(<requests.packages.urllib3.connection.HTTPConnection object at 0x76426d70>, 'Connection to 192.168.2.107 timed out. (connect timeout=10)'))

@antonioparraga
Copy link
Contributor Author

Thank you Dennuuz,

Problem with the ping is that Bravia responds to pings even if it's turned off.
So, component can't guarantee Bravia status based on ping. I think that checking the status of the TV by calling rest service is a good choice. Maybe component should catch this exception to avoid log the error.
Does it make sense?

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

Successfully merging this pull request may close these issues.

4 participants