Philips Android TV component

For anyone interested, I have successfully set up an automation which sets the Ambilights of a 2016+ Philips Android TV to follow (copy) the colour of another light from Home Assistant, say you have RGB LED strips around the room, and want the TV ambilights, at certain times, to automatically match the colour of the target lights.
Things to note:

  • This method uses Hue and Saturation to set the colour of the ambilights, so the ‘hs_color’ attribute of the light component is used to update the parameters, this may be labelled differently for your lights
  • The scaling of the Hue and Saturation within home assistant will probably be different to the scale used within the Phillips API, and thus, a scaling factor is needed

Through experimenting with the Jointspace API, I could set all the Ambilight LED’s to one colour via the terminal command:

shell_command:
name_of_shell_command:
curl -X POST --digest --insecure -u XXXXX https://192.168.X.XXX(TVs_local_IP):1926/6/ambilight/currentconfiguration -d ‘{“styleName”:“FOLLOW_COLOR”,“isExpert”:true,“algorithm”:“MANUAL_HUE”,“colorSettings”:{“color”:{“hue”:{{ ((state_attr(‘light.[enitity_id of target light]’, ‘hs_color’)[0]) * ([Scaling Factor]) |int }},“saturation”:{{ ((state_attr(‘light.[enitity_id of target light]’, ‘hs_color’)[1]) ([Scaling Factor])) |int }},“brightness”:{{ state_attr(‘light.[enitity_id of target light]’, ‘brightness’) |int }}},“colorDelta”:{“hue”:0,“saturation”:0,“brightness”:0},“speed”:255}}’

As this is very messy, I will give an example:

  • The IP of the TV being 192.168.1.101
  • The entity_id of the light I want the tv to copy is light.bedroom_light
  • The scaling of the HS(&B) values within home assistant are:
    Hue:(0-360)
    Saturation:(0-100),
    Brightness:(0-255)
  • The scaling of the HS(&B) values for the Philips TV (yours will most likely be the same) are:
    Hue:(0-255),
    Saturation:(0-255),
    Brightness:(0-255)

The following shell_command will be added to config.yaml:

curl -X POST --digest --insecure -u XXXXXXXXXXXX https://192.168.1.101:1926/6/ambilight/currentconfiguration -d '{“styleName”:“FOLLOW_COLOR”,“isExpert”:true,“algorithm”:“MANUAL_HUE”,“colorSettings”:{“color”:{“hue”:{{ ((state_attr('light.bedroom_light, ‘hs_color’)[0]) * (255/360)) |int }},“saturation”:{{ ((state_attr('light.bedroom_light, ‘hs_color’)[1]) * (255/100)) |int }},“brightness”:{{ state_attr(‘light.bedroom_light, ‘brightness’) |int }}},“colorDelta”:{“hue”:0,“saturation”:0,“brightness”:0},“speed”:255}}’

Then, an automation can be created to run the shell command any time the state of the target light is changed, thus keeping the ambilights in sync:

– alias: Follow Room Colour
trigger:
– entity_id: light.bedroom_light
platform: state
condition:
– condition: state
entity_id: switch.ambilight
state: ‘on’
action:
– service: shell_command.set_ambilights_to_strips

This automation can be turned on and off, to allow the ambilights to continue following video or audio if this function is not needed. I did look into expanding this into a fully functional RGB light from within Home Assistant, but could not find any shell_command light component that would work (although there seems to be an MQTT light component which may be similar), if anyone knows of a more elegant solution to this I would love to hear it, otherwise, this is a very nice way of tying in your TV to your current RGB lights, controlled by Home Assistant

3 Likes

Thank you for your job! Really nice feature!
Do you know if it would be possible to do it reversed, i.e. get the current colour of the TV ambilight and match a colour of any RGB lamp via automation?

Unfortunately not at the moment, as this is automation based, and simply sends a command to match the target light when it is changed, I am starting to look at creating a light component for the ambilights separately, which would be much better, as it would work both ways as you say, and the ambilights could then be controlled by any automation or integration such as alexa, google home and siri etc, I have never written a component so I cant promise anything, but ill be sure to post it here if I get anywhere :slight_smile:

1 Like

First of all good job!
Guys python absolute newbie here but learning.
Is there a way to add the channels list to this? For the 2016 Philips tv’s the channel list is found with https://tvip:1926/6/channeldb/tv/channelLists/all

I’ve been trying to use the current component from here but cannot understand the code nor how the list can be obtained.
Tried similarly to the current channel function but with no success.

I really want to learn. Anyone please?
Thank you

Guys,

I managed to hack my way to what I wanted. Now Channel list is available e you can choose your tv channel in the source list.

Here is the file philips_2016_b.xml (8.6 KB)
Just change .xml to .py

Lots of doubts in my mind still as I cannot understand much of the how to build a component, specially from ground up.

3 Likes

Guys,

here follows the work in progress regarding this TV.

My model is 32PFS6402/12.

Here is the file philips_2016_b1.xml (10.0 KB)
Just change .xml to .py
Now the component can differentiate between watching TV and using an android APP.
When watching TV, forward and rewind buttons change the channel.
Channel title includes program number.
When using an APP, the name of the app appears in the media title.
Some warnings that appeared in the logs about volume error don’t appear anymore.
Cannot find a way to change from TV to APP. Tried several ways to POST but with no luck.
To change from APP to TV simply choose a channel in the source list.

3 Likes

Great work :smiley: Love it.
It would be great to filter channels list with favorites “channeldb/tv/favoriteLists/allter” and maybe support for ambilight, but it require at least few endpoints “ambilight/power”, “ambilight/currentconfiguration” and probably something else, unfortunately I’m don’t know. I tried to do it myself but I failed :frowning:
And i have a question, do you have list with all working endpoints or do you know how to get it?

Thanks.

Don’t know them. Found a couple by trial and error. for instance post the json load for activities/tv and the channel will change but do the same logic for applications/current and no such luck.

I think that it will be something in the lines of activites/app or apps but these no luck. Having the right one with be a charm.

I found some endpoint in https://github.com/suborb/philips_android_tv/blob/master/philips.py
It is possible to find some more by Reverse Engineering Philips app from android https://play.google.com/store/apps/details?id=com.tpvision.philipstvapp
I have never done that unfortunately :frowning:

Where to find best custom component to control Philips Android TV 55PUS7303 trough HASS?

That’s the one I used also. As for reverse engineering that sounds great but way over my head now.
As for Ipt2007, presently this seems to be the best option.

Hi @boloni

If I understand correct I must rename philips_2016_b1.xml to .py. And then put file to:

path-to-my-hass-configuration/custom_components/media_player

Is this correct?

Can you please post the configuration yaml for that component?

Example for configuration.yaml Philips Android TV component
How to receive user and password to your tv Philips Android TV component

Ipt2207,
it´s just like above said:

media_player:
  - platform: philips_2016
    name: phTV
    host: 192.x.x.x
    username: yourusername
    password: yourpassword

as for the xml renaming and folder placing it is correct and also,
the name of the file you end up with has to match the platform name.
For the settings above the file must be renamed to philips_2016.py

Where I can get username and password?

Post nr 1 in this thread.

The steps to access this API are:

  1. Get a pairing code from Philips ( https://github.com/suborb/philips_android_tv/blob/master/philips.py#L30 )
  2. After this, you will receive an username and password
  3. Use this username and password to access the jointspace API ( using /6/ instead of /1/ and HTTPS instead of HTTP )

Yes I see that, but don’t understnd?

I go to link in 1. but only see code from philips.py?

If anyone here is interested, I have created a custom light component for the Ambilights of Philips TV’s and opened a new topic for it, if you need any help with it, or have any suggestions for more features, I will be over there :slight_smile:

4 Likes

Has anyone already figured out how to use the “Wake on LAN” for post 2016 Philips Android TV’s?

I’m using the following configuration but it doesn’t work (yet):

wake_on_lan:

switch:
  - platform: wake_on_lan
    mac_address: "aa:bb:cc:dd:ee:ff"

The WoWLAN function is switched on in my TV’s settings, can’t find a WoLAN setting

Thanks for the info.

I’m only interested in getting the Philips remote control app working for basic channel changing, volume, mouse and keyboard. With everything else I’m way out of my depth here. :blush:

1 Like