Philips Android TV component

I’ve got some problem trying to make my PHILIPS Ambilight TV working with HomeAssistant.
I’ve got a PHILIPS 7300 SERIES (2019) tv MODEL 50PUS7304/12 and I’ve installed the Philips Android TV Integration (via HACS) on my Home Assistant v. 0.114.4 running on a Rasp.
I’ve succeeded in extracting my user and password from the TV by sniffing them during the pairing process (using the philips.py script).

I’ve also configured the tv in the configuration.yaml file as follow

media_player:
  - platform: philips_android_tv
    name: TV
    host: 192.168.x.x
    mac: aa:aa:aa:aa:aa:aa
    username: xxxxx
    password: xxxxx

and then restart HomeAssistant.

Even if I found the entity in the “Entities” menù I cannot control the TV.
In the Home Assistant log file I found the fllowing errors

......
2020-09-27 18:42:12 WARNING (SyncWorker_27) [custom_components.philips_android_tv.media_player] TV is not returning JSON. Either the authentification failed or your TV does not support calling powerstate. 
2020-09-27 18:42:12 WARNING (SyncWorker_27) [custom_components.philips_android_tv.media_player] TV is not returning JSON. Either the authentification failed or your TV does not support calling applications.
2020-09-27 18:42:12 WARNING (SyncWorker_27) [custom_components.philips_android_tv.media_player] TV is not returning JSON. Either the authentification failed or your TV does not support calling channeldb/tv/channelLists/all. 
2020-09-27 18:42:12 WARNING (SyncWorker_27) [custom_components.philips_android_tv.media_player] TV is not returning JSON. Either the authentification failed or your TV does not support calling audio/volume. 
2020-09-27 18:42:22 WARNING (SyncWorker_49) [custom_components.philips_android_tv.media_player] TV is not returning JSON. Either the authentification failed or your TV does not support calling powerstate.
2020-09-27 18:42:22 WARNING (SyncWorker_49) [custom_components.philips_android_tv.media_player] TV is not returning JSON. Either the authentification failed or your TV does not support calling applications
......
......

I’ve also tried to grab the user and password again (I’ve noticed that the user and the password always changes…Is it correct??), reconfigure it in the configuration.yaml file but with no success. I’ve got always the same error and Home Assistant cannot control the TV.

Any clues? What should be the problem?

Your TV is not supported.

Could be that the newer models use /5/ api again.
Nothing you can do for now.
You can try to make it work by changing the code.

Ok Nils, thanks from your prompt reply.
I’ll give it a try.

Did you made it? Got the same Problem…

what is your solution please, i am going mad trying to figure it out

solution for what?

sorry i should have quoted, your solution for switching HDMI Channels

i’m using the AndroidTV ADB component using the adb_command service on my tv (ADB entity of my TV, not the Philips Android component).

“command”:“input keyevent KEYCODE_F1”

i’ve tried for ages to do that, but my TV wont change :frowning: it does the other actions (up, down, back etc)… did you have to do anything special to get that working? which model of TV do you have please?

I’ve got the 55POS9002 and this is all I have:

  - platform: androidtv
    name: Android TV ADB
    host: 192.168.178.25
    adb_server_ip: 127.0.0.1
    adb_server_port: 5037

Thanks, that’s all i have. but i have the POS9005/12

Hi
I have a Phillips 55pus7394/12 from 2019. I paired my tv with ha_philips_android_tv.
When the TV is off, it apperas as “unklnow” in home assistant so I can’t swith it on from HA.
What can I do ?
Thanks

Hallo nels
I need some help, I don’t know what I muss do to have the username and the password? I have pairing my philips tv to my iPhone and it’s works.
My HA configuration is on an raspberry pi3b+ with the hassio image.
How can I run the python script?
Please help me ^^ thx you a lot

This thread is getting big, so it’s not so easy to find what you are looking for.
But this worked for me regarding running the python script:

Link to post

1 Like

hello i have this error message:

c:\Python27>python philips.py --host 192.168.2.11 pair
Starting pairing request
Traceback (most recent call last):
  File "philips.py", line 140, in <module>
    main()
  File "philips.py", line 90, in main
    pair(config)
  File "philips.py", line 41, in pair
    r = requests.post("https://" + config['address'] + ":1926/6/pair/request", json=data, verify=False)
  File "c:\Python27\lib\site-packages\requests\api.py", line 110, in post
    return request('post', url, data=data, json=json, **kwargs)
  File "c:\Python27\lib\site-packages\requests\api.py", line 56, in request
    return session.request(method=method, url=url, **kwargs)
  File "c:\Python27\lib\site-packages\requests\sessions.py", line 488, in request
    resp = self.send(prep, **send_kwargs)
  File "c:\Python27\lib\site-packages\requests\sessions.py", line 609, in send
    r = adapter.send(request, **kwargs)
  File "c:\Python27\lib\site-packages\requests\adapters.py", line 487, in send
    raise ConnectionError(e, request=request)
requests.exceptions.ConnectionError: HTTPSConnectionPool(host='192.168.2.11', port=1926): Max retries exceeded with url: /6/pair/request (Caused by NewConnectionError('<requests.packages.urllib3.connection.VerifiedHTTPSConnection object at 0x00000000033ABC18>: Failed to establish a new connection: [Errno 10061] Aucune connexion n\x92a pu \xeatre \xe9tablie car l\x92ordinateur cible l\x92a express\xe9ment refus\xe9e',))

Hi guys,

I’m trying to get the username and password from my 55PUK6400 using the following method:

Pairing seems to work, but i don’t see any username or password. What am i doing wrong?

C:\Python27>python philips.py --host 192.168.2.104 pair
Starting pairing request
Enter onscreen passcode: 2859
Attempting to pair
Traceback (most recent call last):
  File "philips.py", line 140, in <module>
    main()
  File "philips.py", line 90, in main
    pair(config)
  File "philips.py", line 59, in pair
    r = requests.post("https://" + config['address'] +":1926/6/pair/grant", json=grant_request, verify=False,auth=HTTPDigestAuth(config['device_id'], config['auth_key']))
  File "C:\Python27\lib\site-packages\requests\api.py", line 110, in post
    return request('post', url, data=data, json=json, **kwargs)
  File "C:\Python27\lib\site-packages\requests\api.py", line 56, in request
    return session.request(method=method, url=url, **kwargs)
  File "C:\Python27\lib\site-packages\requests\sessions.py", line 488, in request
    resp = self.send(prep, **send_kwargs)
  File "C:\Python27\lib\site-packages\requests\sessions.py", line 615, in send
    r = dispatch_hook('response', hooks, r, **kwargs)
  File "C:\Python27\lib\site-packages\requests\hooks.py", line 31, in dispatch_hook
    _hook_data = hook(hook_data, **kwargs)
  File "C:\Python27\lib\site-packages\requests\auth.py", line 252, in handle_401
    _r = r.connection.send(prep, **kwargs)
  File "C:\Python27\lib\site-packages\requests\adapters.py", line 473, in send
    raise ConnectionError(err, request=request)
requests.exceptions.ConnectionError: ('Connection aborted.', BadStatusLine('No status line received - the server has closed the connection',))

EDIT:
I have used the following python script to get the username and password. Worked!

So i have got the username and password from the pairing python script. But Home Assistant is throwing me some errors about not returning a JSON:

Logger: custom_components.philips_android_tv.media_player
Source: custom_components/philips_android_tv/media_player.py:328
Integration: philips_android_tv (documentation)
First occurred: 11:59:46 (16 occurrences)
Last logged: 12:00:20

TV is not returning JSON. Either the authentification failed or your TV does not support calling powerstate.
TV is not returning JSON. Either the authentification failed or your TV does not support calling applications.
TV is not returning JSON. Either the authentification failed or your TV does not support calling channeldb/tv/channelLists/all.
TV is not returning JSON. Either the authentification failed or your TV does not support calling audio/volume.

When i try to manually connect to the API (https://192.168.2.104:1926/6/powerstate) it asks for username and password. When i enter the username/password i get a forbidden error:

Forbidden
The server understood the request, but is refusing to fulfill it

@nstrelow do you have an idea?

I installed the integration through hacs
Cloned the repo
I tried to run the pip install requirements
i get an error

In the beginning he said CATT was using version 2.23 or smth and the requirements here lower…
Also for other integration he said this too
not sure if the tv will fit

Tv= philips UHD TV 43PUS7805/12

There are a couple of ways to switch HDMI inputs on Android TVs:

  1. Using adb. In the example below the last digit in HdmiService%2FHW9 indicates an input source (for me HdmiService%2FHW9 is HDMI 2 and HdmiService%2FHW10 is HDMI 1):
adb shell am start -a android.intent.action.VIEW -d content://android.media.tv/passthrough/org.droidtv.hdmiService%2F.HdmiService%2FHW9 -n org.droidtv.zapster/.playtv.activity.PlayTvActivity -f 0x10000000
  1. I’ve tried using the activities/launch endpoint in the Philips API to run the command above, but unfortunately the API strips out “data” and “flag” parameters ("-d" and “-f” in the example above), so I could not make it work. It could be that I am just passing them wrong, so if somebody figures out how to use them with the API - please share! What I was able to do is to call Google Assistant and pass a query - apparently, passing input name as a query (“HDMI 1”, “HDMI 2”, “SCART”, etc.) will result in Google Assistant switching the TV to that input. Just post the following to activities/launch:
{ "intent": {"extras":{"query":"HDMI 1"}, "action": "Intent {  act=android.intent.action.ASSIST cmp=com.google.android.katniss/com.google.android.apps.tvsearch.app.launch.trampoline.SearchActivityTrampoline flg=0x10200000 }", "component":{"packageName":"com.google.android.katniss","className":"com.google.android.apps.tvsearch.app.launch.trampoline.SearchActivityTrampoline"} } }
1 Like

How did you turn the TV to debug mode over network? The only I can do is turn debug mode over USB. The same TV, latest Android (8.0.0).