Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Icon auto-coloring doesn't work when using xy_color mode #37

Closed
BrainDamage opened this issue Jan 11, 2021 · 6 comments · Fixed by #52
Closed

Icon auto-coloring doesn't work when using xy_color mode #37

BrainDamage opened this issue Jan 11, 2021 · 6 comments · Fixed by #52

Comments

@BrainDamage
Copy link

Icon auto-coloring doesn't work when using xy_color mode, it always displays a grey icon no matter the colour or the brightness

type: entities
entities:
    - type: 'custom:rgb-light-card'
      entity: light.example_light
      colors:
          # this works
          - rgb_color:
                - 255
                - 127
                - 255
          # this too
          - hs_color:
                - 60
                - 30
          # this results in a gray icon, instead of white
          - xy_color:
              - 0.33
              - 0.33
            brightness: 255
          # this too results in a gray icon, instead of purple
          - xy_color:
              - 0.217
              - 0.077
@bokub bokub pinned this issue Apr 21, 2021
@bokub
Copy link
Owner

bokub commented Apr 26, 2021

This is normal, because the auto coloring haven't been implemented yet.

If someone wants to work on this, all we need is a function to convert x,y to r,g,b.

FYI, here is the function used in Home Assistant, but it looks really complex...

@wspeth
Copy link

wspeth commented Jul 21, 2021

I face that problem too and here I read, others suffer also :(
in my project it is essential to send the particular xy_color values to the devices because they will always report their state as xy_color and some code inbetween has to check/compare. So calculation results from conversion of rgb to xy will not help.

here they offer xy_color as an option
https://www.home-assistant.io/integrations/light#service-lightturn_on

and this is, what I tried
- xy_color:
(spaces) - 0.5621
(spaces) - 0.4166

  - xy_color: (0.5621, 0.4166)

  - xy_color: [0.5621, 0.4166]

all shown as HEX (#): 7F848E in the card

@bokub
Copy link
Owner

bokub commented Jul 21, 2021

Hi Walter, the 2 following syntaxes should work:

- xy_color: [0.5621, 0.4166]
- xy_color:
  - 0.5621
  - 0.4166  

The issue is that the icons will be grey by default, but the icons are supposed to work if you click on them.

You can set the icon color by using the icon_color option.

@wspeth
Copy link

wspeth commented Jul 21, 2021

thank you so much. This way it works. Set xy_color for the light and icon_color for the ball:

      - xy_color:
          - 0.7006
          - 0.2993
        icon_color: rgb(255, 0, 24)
        brightness: 100

@alexmerm
Copy link

Hey,
So I was just taking a look at this because I have my HA set up with light_profiles and I was trying to set up this card. I came across this js-CIE-1931-rgb-color-converter repo which converts from x,y, brightness values to RGB in JS. It might be a bit too much code to include in this card for a minimal result but so far( in my tests at least) its given accurate colors :)

@bokub
Copy link
Owner

bokub commented Oct 6, 2021

This feature is now available is version 1.10.0 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants