Light Entity RGB Value - Custom Button Javascript Template

EDIT: Figured it out. I had left {{ ‘\x00’ }} in the template from another attempt at the template. I noticed after posting my message. I’ll leave this here as a warning to others…lol.

I feel like I should have been able to figure this out but after several attempts I’m stuck.

I have a custom button and want the icon rgb color to be that of a light entity rgb_color value (similar to a light icon). I have this working as desired for a single light with the following template.

styles:
  icon:
    - color: >
        [[[
          if (states['switch.light_flux'].state == 'on')
            return "rgb(" + states['light.dining_room_rgb_light'].attributes.rgb_color[0]
              + ", " + states['light.dining_room_rgb_light'].attributes.rgb_color[1]
              + ", " + states['light.dining_room_rgb_light'].attributes.rgb_color[2] + ")";
          else
            return "var(--state-icon-color)";
        ]]]

But what I really want to use is the value of a template sensor which is this same value (I have a bunch of rgb lights controlled by flux and I’d want to be able to check them all to find one that is on to get this value. I could do this all in the custom button template for each rgb light but I’d rather do it with a sensor value.

styles:
  icon:
    - color: >
        [[[
          return states['sensor.flux_color'].state;
        ]]]

I’ve tried a bunch of variations of the sensor template. This is the one I think should work, but it doesn’t. What am I not seeing here? Why doesn’t this work?

      flux_color:
        unique_id: flux_color
        value_template: >
          {% if is_state('switch.light_flux','on') and is_state('light.dining_room_rgb_light','on') %}
            rgb{{ state_attr('light.dining_room_rgb_light','rgb_color') }}
          {% else %} rgb(255, 255, 255)
          {% endif %}
          {{ '\x00' }}


image