Even though I was the OP, can I suggest that this issue is moved to CustomUI - discussion thread . That way you can be more sure hat @andrey is aware.
Ok Got the Custon_ui badges colour to work.
Had to use customize_glob.yaml
"*":
custom_ui_state_card: state-card-custom-ui
"sensor.window_*":
state_card_mode: badges
templates:
theme: >
if (state === 'Open') return 'red_badge'; else return 'green_badge';
"sensor.door_*":
state_card_mode: badges
templates:
theme: >
if (state === 'Open') return 'red_badge'; else return 'green_badge';
"*_temperature":
state_card_mode: badges
templates:
theme: >
if (state > 21) return 'hot'; else if (state >= 19 ) return 'comfortable'; else return 'cold';
"*_humidity":
state_card_mode: badges
templates:
theme: >
if (state > 65) return 'hot'; else if (state >= 55 ) return 'comfortable'; else return 'cold';
Hi
can you please explain what you did (step by step)?
Good evening. The customize for icon color change used to work but now doesn’t. My custom ui version is CustomUI: 20180330
Please kindly advice.
customize:
binary_sensor.door_back_sensor:
templates:
rgb_color: "if (state === 'on') return [200, 100, 30]; else return [10, 20, 30];"
Thank you very much.
Regards Norick, could you share the “script” of this group, to learn how it is done for my system? Thank you.
Greetings @Norik_Krasniqi, I am very new to Hass’ world and I would like you to share how you made this group of icons and their data. Thank you very much!
Here is my current config (the coloring now working right now)
sensor.yaml
- platform: systemmonitor
resources:
- type: disk_use_percent
arg: /home
- type: processor_use
- type: memory_use_percent
- type: last_boot
- type: since_last_boot
- platform: sql
db_url: mysql://XXXXX:XXXXX@localhost/homeassistant
queries:
- name: DB Size
query: 'SELECT table_schema "homeassistant", Round(Sum(data_length + index_length) / 1024 / 1024, 1) "value" FROM information_schema.tables WHERE table_schema="homeassistant" GROUP BY table_schema'
column: 'value'
unit_of_measurement: MB
- platform: speedtest
minute:
- 0
- 15
monitored_conditions:
- download
- upload
- ping
- platform: template
sensors:
since_last_boot_templated:
value_template: >-
{%- set slb = states.sensor.since_last_boot.state.split(' ') -%}
{%- set count = slb | length -%}
{%- set hms = slb[count - 1] -%}
{%- set hms_trimmed = hms.split('.')[0] -%}
{%- set hms_split = hms_trimmed.split(':') -%}
{%- set hours = hms_split[0] | int -%}
{%- if count == 3 -%}
{{ slb[0] ~ ' ' ~ slb[1] ~ ' ' }}
{%- endif -%}
{%- if hours > 0 -%}
{%- if hours == 1 -%}
1 hour
{%- else -%}
{{ hours }} hours
{%- endif -%}
{%- endif -%}
- platform: version
name: Installed Version
- platform: scrape
resource: https://www.home-assistant.io
name: Latest Release
select: ".current-version h1"
value_template: '{{ value.split(":")[1] }}'
Can you help me with a link on how to get the sql stuff set up?
i try this solution in my customize.yaml and it not working to change color of badge for my tempo… Still is RED color.
sensor.eurochron_0001_temp:
state_card_mode: badges
templates:
theme: >
if (state > 29) return 'hot'; else if (state >= 27 ) return 'comfortable'; else return 'cold';
I try change icon color for switch, but when switch is ON all is ok and color is GREEN, but when is off should be RED but it is light blue. Why ?
templates:
hs_color: "if (state === 'on') return [98,158,81]; else if (state === 'off') return [191,27,0];"
My sensor has an attribute “color”, and the values comes like “#6ee86e”.
I cant get this to work:
sensor.nilu_xxx_yyy_pm25:
friendly_name: PM 2.5
templates:
icon_color: >
return attributes.color
Should it work. Is it possible to use the attributes directly?
try:
templates:
theme: >
if (state > 29) return 'hot';
if (state >= 27 ) return 'comfortable';
return 'cold';
try:
templates:
icon_color: >
if (state === 'on') return 'hs[98,158,81]';
return 'hs[191,27,0]';
It works like this with hex colors and rgb colors.
disclaimer: not really sure about the hs color format like hs[98,158,81]
, I don’t use these. Only hs colors in my setup are with 2 numbers, not 3.
see: home-assistant-custom-ui/docs/features.md at master · andrey-git/home-assistant-custom-ui · GitHub
not sure, never tried it, what happens if you do
Only comparable sensor I use is where the state of the sensor itself is used in the value_template for its icon. feared endless recursive issue’s but it works just fine.
lets give it a go and report back!
Actually, it works : D
I had a line underneath commented out. When removing this line, it did work.
return attributes.color
# bla bla bla