Philips Android TV component

so… after a week of testing with this component… it look like it is working great.
Maybe you can give it to the HA team… and implement it in the original code ?

3 Likes

Is it possible to use this addon with Hassio?

Everything you need to know is inside this thread.

Because I am nice:
This is currently a custom component you need to manually copy into config/custom_components/media_player.
You also need to pair your TV, get a username/password and put that into your config.

Thanks for replying. I have read this thread from the beginning and I have issues with python script. I have installed libraries from requirements file, however, whenever I try to run philips.py script I receive following error:

 Traceback (most recent call last):
  File "philips.py", line 6, in <module>
    import requests
ModuleNotFoundError: No module named 'requests'

Try the Custom deps deployment Hassio add-on. And pip install requests

Thanks for help! I found what was wrong - for some reason with Python 3.7 I was not able to execute the script. However, I got it working with Python 2.7.
Short tutorial for not so techy persons (like me) Windows users :slight_smile:

  1. Download and install Python 2.7 (Google it)
  2. Download and install Microsoft Visual C++ Build Tools
  3. During the installation hit Advanced button and mark:
    Compile .py files to byte code after installation.
  4. Extract the component.
  5. Open the folder and on the file explorer’s top right select File > Open Windows PowerShell > Open Windows PowerShell as Administrator
  6. In the command line type:
    python -m pip install -r requirements.txt
  7. If the pip installation was executed with no errors in the same command line type:
    python philips.py --host 192.168.xx.xx pair
  8. The script should be executed
1 Like

I have a new philips TV without android.

It exposes the API on TCP/1925 and does NOT require pairing and HTTP authentication.

I’ve taken the nice philips_2016.py and ambilights.py and removed the HTTP auth in the POST and GET reqs. Seems to half work - I still have work to do on this API but the TCP port 1925 STOPs responding after a while.

I see in the philips_2016.py there is a fix for this by using the same HTTP connection as there is a bug after 100 SSL connections.
This doesnt seem to help with my setup though, like i say its http not ssl.
Need to deplete the TV’s capacitors and refil to get the port open again.

Any advise would be great

After pairing TV and adding credentials to my configuration.yaml file I receive such error. Did I do something wrong?

INFO:homeassistant.util.package:Attempting install of colorlog==3.1.4
Testing configuration at /config
ERROR:homeassistant.scripts.check_config:BURB
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/homeassistant/scripts/check_config.py", line 207, in check
    res['components'] = check_ha_config_file(hass)
  File "/usr/local/lib/python3.6/site-packages/homeassistant/scripts/check_config.py", line 372, in check_ha_config_file
    platform = loader.get_platform(hass, domain, p_name)
  File "/usr/local/lib/python3.6/site-packages/homeassistant/loader.py", line 60, in get_platform
    return get_component(hass, PLATFORM_FORMAT.format(domain, platform))
  File "/usr/local/lib/python3.6/site-packages/homeassistant/loader.py", line 92, in get_component
    module = importlib.import_module(path)
  File "/usr/local/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 674, in exec_module
  File "<frozen importlib._bootstrap_external>", line 781, in get_code
  File "<frozen importlib._bootstrap_external>", line 741, in source_to_code
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/config/custom_components/media_player/philips_2016.py", line 7
    <!DOCTYPE html>
    ^
SyntaxError: invalid syntax
Fatal error while loading config: invalid syntax (philips_2016.py, line 7)
Failed config
  General Errors: 
    - invalid syntax (philips_2016.py, line 7)
Successful config (partial)

Well like it says:

“<!DOCTYPE html>” Should not be there, this comes from download http sites instead of the .py file

Did you try the original Phtilips TV component? There is an official component, maybe that works better for you.

Also I had some problems with http requests using Postman. It just stopped working after a while.

This and your problem could be related to HTTP long polling which the API is using: https://www.pubnub.com/blog/2014-12-01-http-long-polling/

Strange. I have uploaded file philips_2016.py which was downloaded from your Github page. I will try original component tonight. Thanks!

@nstrelow The script is working fine! Thanks a lot… you are a genius, the only part that won’t work is the turn on tv button. Do you have any idea how to fix this?

I have the same problem. Suspect the TV reacts to WakeOnLan packets, and is only then controllable.

Thanks for the great work! :smiley:
I got it working with my 55POS9002. I don’t have cable/flow tv, only use Apps and HDMI. I got a Intel NUC connected to my Denon X1000 receiver and I would like to detect when it’s active on HDMI. The receiver is connected to HDMI 2 and HA can’t detect that source.

image

Current activities shows

curl -X GET --digest --insecure -u user:pwd https://172.16.0.30:1926/6/activities/current

{“component”:{“packageName”:“org.droidtv.playtv”,“className”:“org.droidtv.playtv.PlayTvActivity”}}

I tried lots of variants of sources, current sources. Any ideas?
I’m running lasted version of https://github.com/nstrelow/ha_philips_2016 and a Raspberry Pi3 Hassbian image, HA version 0.82.1.

/Lars

It is working for me. Takes a while until it starts.
Make sure to have Wake on WLAN WoWLAN, enabled, it’s in the network settings of the TV

I do not think I found a possibility to switch between hdmi devices.
Sources are only channels and apps. TV is one app and you can start it, but that will just display the last hdmi channel used I think.

Try HDMI-CEC - Home Assistant
I use it to switch between hdmi devices. You have to have your HA devices (e.g. RPI) attached to the tv via hdmi

1 Like

I got it working. Instead of downloading component directly from GitHub, I have downloaded raw version. And it worked like a charm. Thanks!

1 Like

Look on a media_player.philips_js component and a patched ha-philipsjs. It should work with allcab/allsat as well.

Hi,

i tried to set up the philips_2016 and ambilights component. Both devices (mediaplayer and light) are unknown or not availbale.

I have a 9002.

For the mediaplayer component I get this error (it looks very similar to the one I get from the ambilight component):

Update for media_player.tv fails
Traceback (most recent call last):
File “/usr/local/lib/python3.6/site-packages/homeassistant/helpers/entity.py”, line 221, in async_update_ha_state
await self.async_device_update()
File “/usr/local/lib/python3.6/site-packages/homeassistant/helpers/entity.py”, line 349, in async_device_update
await self.hass.async_add_executor_job(self.update)
File “/usr/local/lib/python3.6/concurrent/futures/thread.py”, line 56, in run
result = self.fn(*self.args, **self.kwargs)
File “/usr/local/lib/python3.6/site-packages/homeassistant/util/init.py”, line 324, in wrapper
result = method(*args, **kwargs)
File “/config/custom_components/media_player/philips_2016.py”, line 235, in update
self._tv.update()
File “/config/custom_components/media_player/philips_2016.py”, line 314, in update
self.getState()
File “/config/custom_components/media_player/philips_2016.py”, line 381, in getState
r = self._getReq(‘powerstate’)
File “/config/custom_components/media_player/philips_2016.py”, line 291, in _getReq
return json.loads(resp.text)
File “/usr/local/lib/python3.6/json/init.py”, line 354, in loads
return _default_decoder.decode(s)
File “/usr/local/lib/python3.6/json/decoder.py”, line 339, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File “/usr/local/lib/python3.6/json/decoder.py”, line 357, in raw_decode
raise JSONDecodeError(“Expecting value”, s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

Hei

I have an 55PUS7272/12 and are new to this and want to connect it to HAIO.

Have tried different ways but not seems to get it to work.

Could anyone tell me step by step how to connect my PH TV to HAIO?

Thanks very much for helps :slight_smile: