Dynamic state_filter values

Hey guys!
I was trying to create a 3d floorplan with just picture-elements card and no plugins or custom cards. Just some testing:
multiple_lights_3d_test
looking good but I’m trying now to set color and brightness to the equation.

So, I was hopping to use state_filter and hue-rotate to color and opacity to brightness to accomplish this but I need a way to set those values according to the light values, is it possible?

Something like:

  - entity: light.living_room_ff
    state_image:
      'on': /local/teste_light_on_2.png
    tap_action: none
    hold_action: none
    state_filter:
      'on': hue-rotate({{states.light.living_room_ff.attributes.hs_color[0]}}deg) opacity(1)
    type: image
    style:
      transform: none
      left: 0%
      top: 0%

with ‘on’: hue-rotate(300deg) opacity(1) I get something like
room_red_light

the code so far:

elements:
  - entity: light.living_room_ff
    state_image:
      'on': /local/teste_light_on_2.png
    tap_action: none
    hold_action: none
    state_filter:
    type: image
    style:
      transform: none
      left: 0%
      top: 0%
  - entity: light.living_room_f
    state_image:
      'on': /local/teste_light2_on_2.png
    tap_action: none
    hold_action: none
    state_filter:
    type: image
    style:
      transform: none
      left: 0%
      top: 0%
  - entity: light.living_room_ff
    style:
      left: 45%
      top: 70%
    tap_action:
      action: toggle
    type: state-icon
  - entity: light.living_room_f
    style:
      left: 53%
      top: 25%
    tap_action:
      action: toggle
    type: state-icon
image: /local/teste_light_off.png
type: picture-elements

Thank you!

I used this as an example works great: https://github.com/lukevink/hass-config-lajv

Yes, it worked great. I’d prefer to not use plugins but it seems that it’s not possible at this moment. Will use this for now. Thank you so much.

By the way, my hue-rotate ended up like:

${ "hue-rotate(" +
          (states['light.living_room_ff'].attributes.hs_color[1] !== 0 ?
          states['light.living_room_ff'].attributes.hs_color[0] - vars[0] : 0) +
          "deg)"}

var[0] is 50 since hue was not accurate enough and states[‘light.living_room_ff’].attributes.hs_color[1] tests if is in white or color mode

2 Likes