Color based on the state: How To?

Good Morning,
I need to attribute a color based on to the state below:

  • entity: sensor.wcf_thermo_automation_last_triggered
    type: “custom:secondaryinfo-entity-row”
    secondary_info: "[[ if(binary_sensor.waterleak_ID == on, ‘Wet’, ‘Dry’) ]]"

How can i add also a text color “red” or “green” to Wet or Dry ?

Thanks a lot in advance
regards
Gianluca

I had a similar usecase. I wanted to change the icon color based on state.

I used https://github.com/thomasloven/lovelace-card-mod
And this is my config:

- entity: sensor.travel_time_home_from_work_here
    style: |
      :host {
        --paper-item-icon-color:
          {% if states(config.entity) | float < state_attr(config.entity, 'duration') | float * 1.1 %}
            green;
          {% elif states(config.entity) | float < state_attr(config.entity, 'duration') | float * 1.3 %}
            orange;
          {% else %}
            red;
          {% endif %}
          }

I hope this is a start in the right direction for you