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
Added support for Philips TVs with jointSPACE API #4157
Conversation
@Throttle(MIN_TIME_BETWEEN_UPDATES) | ||
def update(self): | ||
"""Get the latest date and update device state.""" | ||
try: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Home Assistant should not contain any protocol specific code. Could you extract this into a 3rd party lib and add that as a requirement to this platform.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm aware of that. I did it like this for two reasons: 1. Creating an extra lib for a handful of requests seems like a little overkill. And even more important: 2. The jointSPACE API seems to be a dead project, so I won't expect any changes which would have to be taken care of in this platform. But if you insist, I'll do it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done with creating the library. Will do the implementation soon. :)
@property | ||
def state(self): | ||
"""Get the device state. An exception means OFF state.""" | ||
try: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should never do any I/O inside a property. It should only return cached values.
DEFAULT_DEVICE = 'default' | ||
DEFAULT_HOST = '127.0.0.1' | ||
DEFAULT_NAME = 'Philips TV' | ||
DEVICE_BASE_URL = 'http://{0}:1925/1/{1}' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This lead to the assumption that the port can not be changed by the user on the TV, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That is correct. The API always runs on port 1925.
add_devices([PhilipsJS(host, name)]) | ||
|
||
|
||
# pylint: disable=too-many-instance-attributes,abstract-method |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
too-many-instance-attributes
is now globally disabled.
Awesome, thanks ! 🐬 |
Description:
This PR adds support for TVs that expose the jointSPACE API. As far as I can tell, this almost exlusively applies to TVs produced by Philips, which is why the platform is called
philips_js
.A list of supported models (and how to enable the API) can be found at the jointSPACE site linked above. As a rule of thumb I would guess most TVs produced after 2010 could have the API baked into the firmware. Although I don't know if the recent models with Android TV have it too. I kind of doubt that.
To see if your TV has the API enabled, browse to it's IP at port 1925. If the API is enabled you'll see the documentation. There's even more possible with the API than I have implemented, but I'll leave that to someone else. Currently it's possible to turn off the TV, switch the input source, increase, decrease or mute the volume.
If you wonder what's the deal with the self._connfail: the webserver inside those TVs seems to be unstable at some times. If it for some reason is (too many requests?), the next few attempts to make requests are skipped to give it some time to get back on track.
Pull request in home-assistant.github.io with documentation (if applicable): home-assistant/home-assistant.io#1384
Example entry for
configuration.yaml
(if applicable):Checklist:
If user exposed functionality or configuration variables are added/changed:
If the code communicates with devices, web services, or third-party tools:
tox
run successfully. Your PR cannot be merged unless tests pass.coveragerc
.