Dynamic Glance Card

Hi,

I am looking for a way of having a glance card that display a different icon color based on another entity state. Currently I accomplish this with the following:

          - type: 'custom:state-switch'
            entity: sensor.count_lights_percent
            default: default
            states:
              "100.0":
                type: glance
                entities:
                  - entity: sensor.count_lights_status
                    name: Lights
                    card_mod:
                      style: |
                        :host {
                          --card-mod-icon-color: {{ _global.colors.green }};
                        }
              "default":
                type: glance
                entities:
                  - entity: sensor.count_lights_status
                    name: Lights
                    card_mod:
                      style: |
                        :host {
                          --card-mod-icon-color: {{ _global.colors.red }};
                        }

However, it feels wrong, and I was looking for a simpler way of doing it. My attempt was something like:

          - type: 'custom:config-template-card'
            variables:
              STATUS: states['sensor.count_lights_percent'].state
            entities:
              - sensor.count_lights_percent
            card:
              type: glance
              entities:
                - entity: sensor.count_lights_status
                  name: Lights
                  card_mod:
                    style: |
                      :host {
                        --card-mod-icon-color: ${STATUS === '100.0' ? green : red};
                      }

However, that does not work, I believe I can’t use the template card conditions inside card-mod somehow.

Any suggestions? Btw, I am using lovelace_gen, so that kind of limits the usage of default templating.

Thanks,