Philips Android TV component


#21

Hello,
In configuration.yaml you have to put:

media_player:

  • platform: philips_2016
    name: Philips TV
    host: 192.168.xxx.xx (your TV Ip address)
    username: username (to get this, pair your TV with HomeAssistant using the python script mentioned above)
    password: password (to get this, pair your TV with HomeAssistant using the python script mentioned above)

After that, you have to copy the philips_2016.py file to:

/home/homeassistant/.homeassistant/custom_components/media_player

(if you don’t have media_player folder, create it, make sure that you are on homeassistant user if you are running Hassbian)

For my 55PUS6561/12 i have modified the philips_2016.py script to retrieve the TV state and to show the turn on button when TV is OFF, but i cannot upload because i am a new user and i am not allowed to do it. If someone is interested, please reply and i will find a way.

Thanks :slight_smile:


#22

How to get the username/password from the python script??


#23

Running the linked script from above will create / display username and password (as mentioned in the first posting, step #2).


#24

Copy philips.py from here on your Raspberrry Pi in a folder (i did it while i was logged with homeassistant user)
Run the script
A code will appear on the TV, write it in the console
After that, username and password will be displayed in the console


#25

I’ll do that tonight…
Do I need first to make the script executable?


#26

No, .py extension is from a python script. Just copy the file to the raspberry pi and run the following command (make sure that before running the command you are in the same location where you put the file):

python philips.py --host 192.168.xx.xx pair

(change your ip address with your TV IP address)

You will see a 4digit code on your TV, insert it in the console and after that you should see the username and password


#27

Awesome that people are working on it. I started on a component, but got frustrated the with the API.
It’s such a bummer that it apparently has less functionality and no documentation at all.

Starting apps is possible judging from the Android TV remote app.
GET activities/current
returns
{‘component’: {‘className’: ‘com.google.android.apps.youtube.tv.cobalt.activity.ShellActivity’, ‘packageName’: ‘com.google.android.youtube.tv’}}

POST activities/launch
That payload needs to be send to the TV.
The TV should then execute the following code:
intent.setComponent(new ComponentName(pkgName, classPathToActivity)
So exactly the same thing the get is returning.

But I get a Bad Request 400, when posting it like this.
Source: https://github.com/suborb/philips_android_tv/issues/5


#28

Thanks @an20dei. It’s working now, but it this all it provides out of the box?

grafik

Can it be enhanced / customized somehow?


#29

yeah its pretty limit what you can pull out with the current knowlegde of the API.
lets hope someone are skilled enough to find fix a proper working component :wink:


#30

Hi guys,

Is there anyone who managed to make any progress here?
I manage to pair 55POS9002 and set up the component. It can change the volume and mute/unmute the tv.
However, my biggest disappointment is that it’s not even possible to get correct on/off state of the tv. Does anyone know if it’s possible to at least fix the state?
I read in the manual that it’s possible to request API from the manufacturer. Would someone here be able to implement it?


#31

I will put tonight my file (i have modified it a little even i don t know python at all). What is improved:

  • state is retrieved correctly
  • turn off / turn on (because in the initial script if the tv was off there was no button to turn it on)
    Thanks.

#32

Such good news! Where will be possible to find your fIle? Will you post here?


#33

Very good news, so i am also interested in the update Python file … Because the current Philips support in HA isn’t working well with my TV.


#34

Seconding the @Molodax with the same question… Would you be so kind as to share the location you’re going to post / you’e posted your version? Thanks in advance!


#35

Sorry guys,

I was busy and i didn t have time to upload it till now. You can find the file attached, please modify the extension of the file from .xml to .py (i am not able to upload directly .py files here).

This is how it looks for me:

image

image

philips_2016.xml (7.8 KB)


#36

thanks, Andrei!


#37

you are welcome, hope it works for all (i have 55PUS6561 model). I don t have python knowledge, but i think that it can be improved by someone who knows, there are more APIs available in the Philips TV that can be used, i think …


#38

Hi to all! I’ve good news…no very good news, but good news :slight_smile:

After try and retry to pair my android tv (philips 49pus7100/12) with the tools of suborb without success. I’download the iOS app “PhilipsTVRemote” and in the help section, said the uses: JSON: 5.

I’ve modified the suborb python:

r = requests.post(“https://” + config[‘address’] + “:1926/6/pair/request”, json=data, verify=False)

to

r = requests.post(“https://” + config[‘address’] + “:1926/5/pair/request”, json=data, verify=False)

and when I try to pair, the code appear in the TV!!! :slight_smile:

But when I type the code, the pair process ended with the error:

air:philips_android_tv-master kulo4$ python3 philips.py --host 192.168.66.110 pair
Starting pairing request
Enter onscreen passcode: 5611
Attempting to pair
Traceback (most recent call last):
File “philips.py”, line 123, in
main()
File “philips.py”, line 90, in main
pair(config)
File “philips.py”, line 60, in pair
print(r.json())
File “/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/requests/models.py”, line 885, in json
return complexjson.loads(self.text, **kwargs)
File “/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/json/init.py”, line 319, in loads
return _default_decoder.decode(s)
File “/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/json/decoder.py”, line 339, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File “/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/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)

Any help? Thanks!!!


#39

I’ve change too:

r = requests.post(“https://” + config[‘address’] +":1926/6/pair/grant", json=grant_request, verify=False,auth=HTTPDigestAuth(config[‘device_id’], config[‘auth_key’]))

to

r = requests.post(“https://” + config[‘address’] +":1926/5/pair/grant", json=grant_request, verify=False,auth=HTTPDigestAuth(config[‘device_id’], config[‘auth_key’]))

and now it’s works!!! I can pair the TV!!! :slight_smile:

I’ve my usr and pass to use it with hass/plugin!!


#40

I needed to change int philips_2016.py:

BASE_URL = ‘https://{0}:1926/6/{1}’

to

BASE_URL = ‘https://{0}:1926/5/{1}’

and it’s working in hass!! I can power on and power off the tv and volume up and down.47

Any possibility to add BASE_URL as a configurarle variable in philips_2016.py? thanks!