andrey-git / home-assistant-custom-ui

Custom UI elements for https://home-assistant.io
https://home-assistant.io
MIT License
526 stars 97 forks source link

rgb_color in templates #126

Closed jncanches closed 6 years ago

jncanches commented 6 years ago

Hi,

don' know if it's a custom-ui in 2018-03-30 version or HA in 0.66, but since those updates rgb_color in templates does not work anymore.

for example : templates: icon: if (state === 'on') return 'mdi:fire'; else return 'mdi:snowflake'; rgb_color: if (state === 'on') return [223, 76, 30]; else return [3, 169, 244];

does not apply a red color on mdi:fire icon or a blue one on mdi:snowflake icon.

Sorry in advance if this an HA regression.

Thank you

alegiovannelli commented 6 years ago

I have the same issue after update to the latest version of Home Assistant. No templates seems to work, rgb_color, icon. Thank you in advance!

huexpub commented 6 years ago

yeah ,the same problem! 0.66.1 rgb_color

lordgoata commented 6 years ago

Confirm I am seeing the same as well.

vlad36N commented 6 years ago

yeah ,the same problem! 0.66.1 rgb_color

andrey-git commented 6 years ago

This is unrelated to CustomUI.

Starting from HA 0.66 icon color is controlled by a 2-member hs_color array attribute (hue, saturation) instead of 3-member rgb_color array attribute (red, green, blue)

alegiovannelli commented 6 years ago
templates:
        #_stateDisplay: if (state === 'on') return 'Detected'; else return 'None';
        icon: if (state === 'on') return 'mdi:fan'; else return 'mdi:fan-off';
        hs_color: >
          if (state === 'on') {
            return [60, 100];
          } else {
            return [0, 0];
          }
        brightness_pct: >
          if (state === 'on') {
            return 49;
          } else {
            return 76.50;
          }

Thank you, this is a sample code that works with Home Assistant > 0.66 version.