jomwells / ambilights

Custom Home Assistant (Light) Component for Ambilight LED's on Philips Android TV's
48 stars 20 forks source link

Can't se brightness and color at the same time #7

Closed valexi7 closed 4 years ago

valexi7 commented 4 years ago

I'm trying to do this:

  action:
   service: light.turn_on
   entity_id: light.philips_ambilight
   data_template:
     brightness: '20'
     rgb_color: ['{{ (range(0, 255)|random) }}','{{ (range(0, 255)|random) }}','{{ (range(0, 255)|random) }}']
     transition: '{{ (range(5, 30)|random) }}'

But you can only set brightness or rgb_color in the same action.

Could you modify your code that if you are trying to set brightness and color to light component it would split them to two requests?

valexi7 commented 4 years ago

Hi,

I fixed your code. Can you upload this to GitHub? Now you can set both, brightness and color at the same time. Still working on with the transitions...

        if ATTR_HS_COLOR in kwargs:
            self._hs = kwargs[ATTR_HS_COLOR]
            convertedHue = int(self._hs[0]*(255/360))
            convertedSaturation = int(self._hs[1]*(255/100))
            if ATTR_BRIGHTNESS in kwargs:
                convertedBrightness = kwargs[ATTR_BRIGHTNESS]
            else:
                convertedBrightness = self._brightness
            self._postReq('ambilight/currentconfiguration',{"styleName":"FOLLOW_COLOR","isExpert":True,"algorithm":"MANUAL_HUE",
            "colorSettings":{"color":{"hue":convertedHue,"saturation":convertedSaturation,"brightness":convertedBrightness},
            "colorDelta":{"hue":0,"saturation":0,"brightness":0},"speed":255}} )
jomwells commented 4 years ago

Hi, sorry I haven't been very active recently, I have been very busy, but thank you! that always bugged me! - Could you please make a pull request to make sure that goes in the right place, I can merge it in straight away.