#Access current light color

1 messages · Page 1 of 1 (latest)

steel quail
#

Hi there, I'm trying to retrieve the current color of my light.

This is my yaml style code:

type: picture-elements
elements:
  - type: state-icon
    entity: light.***
    icon: ***
    title: ***
    tap_action:
      action: toggle
    style:
      left: 50%
      top: 50%
      width: 6vw
      height: 6vw
      filter: drop-shadow(0 0 2vw red)

I tried replacing red with currentColor but it does not seem to be working. Any idea ?

proper panther
#

you can't do this without card-mod or some other kind of third party plugin

steel quail
#

How sad. Do you have an idea of what it would look like using card-mod ?

proper panther
#

I do not. someone else might.

steel quail
#

Alrighty, thanks anyway !

sullen condor
#

I don't know how to get what you want to work specifically with the picture-elements card, but, hopefully, this example for a stock button card will help. (Note: this example handles color, color_temp, and off states.) ```yaml
type: button
show_name: true
show_icon: true
tap_action:
action: toggle
entity: light.living_room_lights
card_mod:
style: |
ha-card {
background: none;
{% if state_attr(config.entity, "color_mode") == "xy" %}
{% set r = state_attr(config.entity, 'rgb_color')[0] %}
{% set g = state_attr(config.entity, 'rgb_color')[1] %}
{% set b = state_attr(config.entity, 'rgb_color')[2] %}
background: rgba( {{r}}, {{g}}, {{b}}, 0.1 );
--card-mod-icon-color: rgba( {{r}}, {{g}}, {{b}}, 1 );
//--primary-text-color: rgba( {{r}}, {{g}}, {{b}}, 0.99 );
//--secondary-text-color: rgba( {{r}}, {{g}}, {{b}}, 0.50 );
{% elif state_attr(config.entity, "color_mode") == "color_temp" %}
--card-mod-icon-color: yellow;
--primary-text-color: white;
{% elif is_state(config.entity, 'off') %}
background: none;
--card-mod-icon-color: rgb(28, 28, 28);
--primary-text-color: rgb(128, 128, 128);
{%- endif %}
}

steel quail
#

Manage to do it this way:

card_mod:
  style:
    state-badge:
      $:
        ha-state-icon:
          $:
            ha-icon:
              $: | 
                ha-svg-icon {
                  filter: drop-shadow(0 0 10px currentcolor);
                }