custom-cards / button-card

❇️ Lovelace button-card for home assistant
MIT License
1.93k stars 233 forks source link

How to use colors in 4.0.0? #737

Closed fxxer closed 1 year ago

fxxer commented 1 year ago

Is your feature request related to a problem? Please describe. I had a simple template card, for all lights and switches. It worked like a charm. After upgrade I can't find the rigth configuration, to get to previous setup. Please help.

button_card_templates:
  switch:
    hold_action:
      action: more-info
    tap_action:
      action: toggle
    type: custom:button-card
    color: auto
    color_type: card
Screenshot 2023-07-29 at 21 44 37

After update. TV lamp is on and water is on, it's confusing.

Screenshot 2023-07-29 at 21 48 19

Describe the solution you'd like How can I replicate this behaviour in 4.0.0? I tried styles, different colours setting using var(--paper .. with no luck.

pergolafabio commented 1 year ago

Same question, all my card icons are white, not sure how need to define colors again, if you have more info, pls post

pickonedev commented 1 year ago
state:
  - value: 'on'
    styles:
      name:
        - color: '#850016'
      card:
        - background-color: '#fdd835'
  - value: 'off'
    styles:
      name:
        - color: '#44739e'
pergolafabio commented 1 year ago

and for the icons? how can i reperesent the real color of the icon based on its state?

pickonedev commented 1 year ago

This is how I done in the past, because some entities won't give the color to the addon... (which now seems that was 100% broken and this is the only way)

So... for name and icon, changing the color for on/off

state:
  - value: 'on'
    styles:
      name:
        - color: '#fdd835'
      icon:
        - color: '#fdd835'
  - value: 'off'
    styles:
      name:
        - color: '#44739e'
      icon:
        - color: '#44739e'

I don't like this, of course, because you need to add more lines, but for now, seems that this is the only idea for a workaround

pergolafabio commented 1 year ago

yes, but thats a fixed color for the ON state, i want to represent the real color, i also have leds, wheni have for example the led on "green", i also want the icon to be green

pickonedev commented 1 year ago

Maybe a helper which represent the value of the led and regarding this, will change the color as well... But yeah, this is not ok... Just a workaround, I'm not the developer of the addon :-|

Mariusthvdb commented 1 year ago

this must be a regression introduced in the later stages of the beta testing, as I had not seen it before and can comfort the light cards no linger show a color icon, or other color elements according to the color attribute of the light. IN fact, I dont see an icon at all...

otoh, I am on beta 2023.8.x now and also see the sliders on those lights are no longer coloring, so it might very well be a core issue..?

Seeing this in core tile card, and mushroom card too..

fxxer commented 1 year ago
state:
  - value: 'on'
    styles:
      name:
        - color: '#850016'
      card:
        - background-color: '#fdd835'
  - value: 'off'
    styles:
      name:
        - color: '#44739e'

This is quick solution, but I am afraid not optimal for light / dark themes.

pergolafabio commented 1 year ago

Maybe a helper which represent the value of the led and regarding this, will change the color as well... But yeah, this is not ok... Just a workaround, I'm not the developer of the addon :-|

So the icon not getting the real color maybe a bug?

Mariusthvdb commented 1 year ago

Yes seems to be. No use continuing here if it's a core bug...

Please see https://discord.com/channels/330944238910963714/427516175237382144/1135166058752376872 and add your findings if they are the same . It will help prevent this bug from being released Wednesday

pergolafabio commented 1 year ago

Hmm, for me the slider changes when I change color, it's just in this button card I don't see the icon changing colors...

Probably for me a misconfiguration? Can you post your config? Or do you use "color: auto"

Screenshot_20230730-140107

Mariusthvdb commented 1 year ago

Ive always uses auto-non-temperature for my light card.

and

      - border-top: >
          [[[ return (entity.state === 'on')
              ? '0.5rem solid var(--button-card-light-color, var(--icon-color-on))'
              : 'none'; ]]]

for my border top which doesnt work anymore either https://github.com/custom-cards/button-card/assets/33354141/ea325d16-fd00-4b38-a4f3-461226167ffe

Mariusthvdb commented 1 year ago

wait, I did some extra cache refreshing and gave it a restart, and now see the color back on the border top, and the core button card. and Tile card.

not so much the custom:button-card:

Scherm­afbeelding 2023-07-30 om 15 08 11

pure cards:

Scherm­afbeelding 2023-07-30 om 15 11 47

seems a clear issue: custom:button-card no longer sets the correct color to the icon.

pergolafabio commented 1 year ago

ok, thnx for confirming :-)

Mariusthvdb commented 1 year ago

this is a bug, and shouldnt be phrased as a config question imho, could op change that please?

minimal required code to get the issue:

type: custom:button-card
entity: light.kayon
color: auto #or auto-non-temperature
RomRider commented 1 year ago

Sorry 🙏 Fixing it right now

github-actions[bot] commented 1 year ago

:tada: This issue has been resolved in version 4.0.1 :tada:

The release is available on GitHub release

Your semantic-release bot :package::rocket:

pergolafabio commented 1 year ago

Thnx for fast fix!

fxxer commented 1 year ago

If you are using color_type: card , the colors are in my opinion reverted between dark / light theme :( Screenshot 2023-07-30 at 16 52 59 Screenshot 2023-07-30 at 16 54 34

RomRider commented 1 year ago

The off color is different than before, now it's --state-inactive-color (exactly what HA does) so for color_type: card, you might want to redefine that maybe?

states:
  - value: 'off'
    styles:
      card:
        - background-color: "whatever you want" 
RomRider commented 1 year ago

I'll try something for color_type: card... Hold on

RomRider commented 1 year ago

Is this what you expect? Or would you also expect the icon when off to be the same as the default button?

HA Button is the default button from HA and custom is custom:button-card:

fxxer commented 1 year ago

Is this what you expect? Or would you also expect the icon when off to be the same as the default button?

HA Button is the default button from HA and custom is custom:button-card:

  • OFF image
  • ON image

Pretty much, what I am going for :) is it working correctly in light theme? Small detail, in the "on" custom: + color_type: card I use white icon and text, but that I can change..

      - value: 'on'
        styles:
          icon:
            - color: white
          name:
            - color: white
github-actions[bot] commented 1 year ago

:tada: This issue has been resolved in version 4.1.0-dev.1 :tada:

The release is available on GitHub release

Your semantic-release bot :package::rocket:

Sethenor commented 1 year ago

For me it's still showing the wrong colors. Like mentioned in the documentation: Setting this to auto-no-temperature will behave like home-assistant's default, ignoring the temperature of the light. By default, if the entity state is off, the color will be var(--paper-item-icon-color), for on it will be var(--paper-item-icon-active-color)

Yet if I use auto-no-temperature it still shows the wrong color: image

But if I define the color specifically for the first button like the documentation says (var(--paper-item-icon-active-color)) it should do, it works: image

RomRider commented 1 year ago

Sorry, forgot to update the documentation. For on it will use whatever HA uses as on color for your entity's domain, this is how it's done:

  properties.push(
    `--state-${domain}-${stateKey}-color`,
    `--state-${domain}-${activeKey}-color`,
    `--state-${activeKey}-color`,
  );

If you want to replace the color, you'll have to define it in the card itself for the on state.

Mariusthvdb commented 1 year ago

sorry if I missed the obvious change in the latest couple of updates, but I can not get the icon color to work for lights anymore (dev3). No matter what I try, the icon only uses the default on/off colors:

Scherm­afbeelding 2023-08-03 om 11 26 12 Scherm­afbeelding 2023-08-03 om 11 26 30
type: custom:button-card
entity: light.kayon
name: 'custom button: Kayon'
color: auto-no-temperature

above is a Hue light (which integration seems to have an issue with the colors) so I also tested a Tradfri light:

Scherm­afbeelding 2023-08-03 om 11 32 04 Scherm­afbeelding 2023-08-03 om 11 32 17

same thing....

more sophisticated buttons show the var(--button-card-light-color) is actually correct (see the top border and other elements I use those on)

Scherm­afbeelding 2023-08-03 om 11 33 43 Scherm­afbeelding 2023-08-03 om 11 33 50

it's the icon that doesnt get colored anymore

downgrading to 4.0.1 returns those colored icons alright:

Scherm­afbeelding 2023-08-03 om 11 59 11 Scherm­afbeelding 2023-08-03 om 12 00 22 Scherm­afbeelding 2023-08-03 om 12 00 28

or the pure cards:

Scherm­afbeelding 2023-08-03 om 12 01 18 Scherm­afbeelding 2023-08-03 om 12 01 26
github-actions[bot] commented 1 year ago

:tada: This issue has been resolved in version 4.1.0 :tada:

The release is available on GitHub release

Your semantic-release bot :package::rocket:

spider7611 commented 1 year ago

Not working for me too. Have yeelight and before when changed the light color changed the button color too. But with the latest release 4.1.0 it is only show the default yellow color when the light on and set it to red color...

RomRider commented 1 year ago

Alright, let me review that again... Could you please open a separate issue for that?

RomRider commented 1 year ago

Alright, I found the issue... don't create a new issue, it's fine

Mariusthvdb commented 1 year ago

have to +1 on it not being fixed unfortunately

4.1.0:

Scherm­afbeelding 2023-08-03 om 15 21 05
github-actions[bot] commented 1 year ago

:tada: This issue has been resolved in version 4.1.1 :tada:

The release is available on GitHub release

Your semantic-release bot :package::rocket:

Mariusthvdb commented 1 year ago

4.1.1: fixed!

Scherm­afbeelding 2023-08-03 om 15 31 54

thank you very much!

spider7611 commented 1 year ago

Working, thank you!

fxxer commented 1 year ago

Well... I have one more issue, if I define color as var(--paper-item-icon-color), then the color of the card in off state is reverted. It should be as the color of covers buttons in screenshot. Same applies for color defined as rgb(0, 122, 255).

Light Mode Screenshot 2023-08-03 at 19 33 07

Dark Mode Screenshot 2023-08-03 at 19 33 50

button_card_templates:
  switch:
    hold_action:
      action: more-info
    tap_action:
      action: toggle
    type: custom:button-card
    color: var(--paper-item-icon-active-color)
    color_type: card
    state:
      - value: 'on'
        styles:
          icon:
            - color: white
          name:
            - color: white
Mariusthvdb commented 1 year ago

you shouldnt be using those paper colors anymore really, cant you follow the new state colors used in HA?

fxxer commented 1 year ago

you shouldnt be using those paper colors anymore really, cant you follow the new state colors used in HA?

Ok, but it should work with color as rgb(0, 122, 255) or this shouldn't be used anymore?

I changed it like this. My aim was to have lights buttons in auto color and buttons for switch in blue..

button_card_templates:
  switch:
    hold_action:
      action: more-info
    tap_action:
      action: toggle
    type: custom:button-card
    color: auto
    color_type: card
    state:
      - value: 'on'
        color: rgb(0, 122, 255)
        styles:
          icon:
            - color: white
          name:
            - color: white
Mariusthvdb commented 1 year ago

its a bit odd, because you have 2 color options set. (auto and the rgb)

why not create 2 different templates for switch and light. hen have the light template follow the light, so set that to auto

for the switch, use the state: option if you want, and, set a card background to the color you desire in the styles object.

fxxer commented 1 year ago

I have 2 different templates for switch and light .. I was just lazy to copy both :) what I am trying to say is when using color as rgb, the card background color is reverted as mentioned before.

For example:

button_card_templates:
  switch:
    hold_action:
      action: more-info
    tap_action:
      action: toggle
    type: custom:button-card
    color: rgb(0, 122, 255)
    color_type: card

Light Mode Screenshot 2023-08-03 at 19 33 07

Dark Mode Screenshot 2023-08-03 at 19 33 50

Mariusthvdb commented 1 year ago

o right, I am sorry. tbh I cant help you out here, I never use a fixed color on a card, so cant tell what it should be like.... if I dont want an auto colored card, I always use the styles, and define the colors there.

for best issue tracking, maybe open a new, since this one is closed and maybe no longer followed up.

RomRider commented 1 year ago

I have 2 different templates for switch and light .. I was just lazy to copy both :) what I am trying to say is when using color as rgb, the card background color is reverted as mentioned before.

For example:

button_card_templates:
  switch:
    hold_action:
      action: more-info
    tap_action:
      action: toggle
    type: custom:button-card
    color: rgb(0, 122, 255)
    color_type: card

Light Mode Screenshot 2023-08-03 at 19 33 07

Dark Mode Screenshot 2023-08-03 at 19 33 50

You might want to open a new issue for that so that I don't forget to fix it, please

fxxer commented 1 year ago

Ok, here it is https://github.com/custom-cards/button-card/issues/754

doronazl commented 1 year ago

how do i modify my card to work again ?

https://pastebin.com/cx6i71wz

it wont show the white color background when the state is on

if i turn it off and on again it will show it, but then dissappears again later, seems like a bug , inconsistent