artem-sedykh / mini-humidifier

Minimalistic humidifier card for Home Assistant Lovelace UI
MIT License
156 stars 26 forks source link

How to apply the "color" style to values? #71

Open samoswall opened 3 years ago

samoswall commented 3 years ago

В примерах описано как можно менять цвет значка в зависимости от значения датчика: The examples describe how you can change the color of the icon depending on the sensor value:

- type: custom:mini-humidifier
  entity: fan.xiaomi_miio_device
  indicators:
    depth:
      icon:
        template: >
          (value) => {
            if (value === 0)
              return "mdi:tray";
            if (value <= 20)
              return "mdi:tray-minus";
            return "mdi:tray-full";
          }
        style: >
          (value) => {
            if (value === 0)
              return { color: "red" };
            if (value <= 20)
              return { color: "#FD451D" };
            return {};
          }

Это можно сделать для значков температуры и влажности (например: t<=20 синий цвет, 20<t<30 зеленый цвет, t>=30 красный цвет) This can be done for temperature and humidity icons (for example: t<=20 blue, 20<t<30 green, t>=30 red)

Как прописать правило для изменения цвета текста значения? (цифры) How do I write a rule for changing the color of the text value? (numbers)

Krocko commented 2 years ago

This option don’t work anymore for my too. The last working version was 2.4.1.