Philips Android TV Ambilights (Light) component

I’ve tried this code but, unfortunately, it doesn’t work for me.

It actually would work if to find a way how to pull current colours from the tv ambilight (the component doesn’t do it currently).

1 Like

@Molodax , Yes. If you are using Manual method for changing colors it can pull the current colors. But if you have follow video or follow audio mode, it can’t. I think that it’s not even supported by API.

Which API do you mean? As for ‘manual’ method, it is possible to put all RGB lights including the TV ambilight in one group and have the same effect of manually changed colours without automation.

The API for changing effect and colors. If you choose Standard or any of the automatic effects, for example “Party” you can’t see the live color (anywhere) of the LED strip.

But you figured it out as I can see from your reply.

Do I understand it correctly, the api can not pull the colors from the TV if you have the TV in a mode where the video output controls the colors? That could explain why my automation did not work.

I made this automation out of your suggestion.

  • id: ‘1541594397491’
    alias: Sync RGB with Ambilight TV
    trigger:
    • entity_id: light.tv_ambilights
      platform: state
      condition:
    • condition: state
      entity_id: light.tradfri_rgb
      state: ‘on’
    • condition: state
      entity_id: input_boolean.follow_ambilight
      state: ‘on’
      action:
    • alias: ‘’
      service: light.turn_on
      entity_id: light.tradfri_rgb
      data_template:
      brightness: ‘{{ light.tv_ambilights.attributes.brightness }}’
      transition: 2
      xy_color: [’{{states.light.tv_ambilights.attributes.xy_color[0]|float}}’,’{{states.light.tv_ambilights.attributes.xy_color[1]|float}}’]

Correct. It could be possible, if you could use “ambilight+hue” option in TV. So it would be tricked to think that you have hue system. Philips said, that they don’t offer hue experience with other manufacturers, because they say that the color change is not fast enough.

1 Like

Hi,
I set uo everything as described above, but my ambilight is unavailable.

I have a 9002.

I get this error:

Update for light.ambilight 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 “/config/custom_components/light/ambilights.py”, line 221, in update
self.getState()
File “/config/custom_components/light/ambilights.py”, line 155, in getState
fullstate = self._getReq(‘ambilight/currentconfiguration’)
File “/config/custom_components/light/ambilights.py”, line 267, 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)

I’d really like to control my ambilighty. But I’m stuck with the error appearing every minute.

Hey, awesome component! Thank you, @jomwells!

I’ve seen people asking about ‘Ambilight + Hue’ switch in this thread. I’ve been trying to solve this particular problem for the past 2 years… I hope it’s okay if I share my solution here:

I’ve decided to document all API endpoints and to create a better python tool to control Philips TVs. You can find an unofficial API reference and the tool (both are ‘work-in-progress’) here: https://github.com/eslavnov/Pylips (comments are welcome!)

It’s far from being done and it’s not a home assistant component (yet), but it already supports turning ‘Ambilight + Hue’ on and off through the API:
python pylips.py --host %ip_address% --user %username% --pass %password% --command ambihue_on
python pylips.py --host %ip_address% --user %username% --pass %password% --command ambihue_off

You can use it through a script/switch entity in Home Assistant… Or perhaps @jomwells could add this particular API call to his component - I would be glad to help.

If this works for you, please share your TV model! Thank you in advance!

4 Likes

In my opinion, ambilight+hue on/off would be a really great addition for this component. I don’t have a problem to easily access this feature from the TV menu, however, I hate the fact that it keeps the lights on even if I turn off the TV. Therefore, would really like to automate it.

1 Like

Sorry for asking again, but I’d really like to enable this for my 9002 too. I copied the error in my post above.
Maybe the developer of this component can tell why it is failing.

Sorry for the inactivity, I’m currently mid exam season at university, but id be happy to try adding that to the component as soon as I’m done (end of January) it shouldn’t be too hard at all. I won’t be able to test it however as I don’t own any hue compatible bulbs, if people are still interested in a couple of weeks, I will post it here for testing before updating the component on GitHub.

Sorry to hear it’s not working for you, (and that I havent seen this for so long!) perhaps the API calls are different for other models? It seems to be failing on the api request for the ambilights current configuration, which works no problem for me (43PUS7303/12), I can have a look for you after the end of the month when my schedule clears up abit :slight_smile:

Is it the ambilight+hue on/off that you would like to automate? I have noticed the lights remaining on after I turn the tv off manually (if I have turned the ambilights on with this component), but a solution may be to use the tv (meda_player) component to detect the tv turning off, and automate the ambilights turning off whenever it does so

Awesome! If you need help adding ambilight+hue switch and testing it, I’ll be glad to help, just PM me when you get to it! Good luck with the exams, man!

1 Like

Yes, that is my idea but to implement it we need to have implemented ambilight+hue on/off/status component or switch. So far, I can turn on and off it using a customer switch component, however, I cannot find a solution to see the status. Also, I think it would be reasonable to have this feature as part of ambilight component rather than a separate one.

To check the status of ambilight + hue @jomwells has to send a post request to https://ip-address:1926/6/menuitems/settings/current with a body:
{"nodes":[{"nodeid":2131230774}]}

The response will be like this:
{"values":[{"value":{"Nodeid":2131230774,"Controllable":true,"Available":true,"string_id":"Switch on","data":{"value":false}}}],"version":0}

Where “value:false” means it’s off and “value:true” means its on.

I still need to implement clean responses in my python tool (so it can be used as a command line sensor in HA), but that will probably take some time since first I need to finish testing and documenting all endpoints in the API and I haven’t been able to use my TV for testing for the past couple of weeks…

2 Likes

Thank you, I’ve tried to use command line sensor for controlling status and using the response you provided, however, I did’t succeed for some reason. I really hope you’ll be implemented it soon.

That would be really nice, would be so cool to use the ambilights.