If i read your config correctly, I suspect you don’t have a theme configured.
for the theme green to work you need to configure it first:
create a themes.yaml in which you declare your themes as follows:
green:
primary-text-color: green
# paper-card-background-color: white
paper-item-icon-color: green
secondary-text-color: green
label-badge-background-color: white
label-badge-text-color: green
label-badge-red: green
label-badge-border-color: lightgrey
red:
primary-text-color: red
# paper-card-background-color: white #'#fcbba1'
paper-item-icon-color: red
secondary-text-color: red
label-badge-background-color: white #'#fcbba1'
label-badge-text-color: red
blue:
primary-text-color: blue
paper-card-background-color: white" #'#fcbba1'
paper-item-icon-color: blue
secondary-text-color: blue
label-badge-background-color: white #'#fcbba1'
label-badge-text-color: blue
label-badge-red: blue
label-badge-border-color: blue
bluewhite:
primary-text-color: bluewhite
paper-card-background-color: white
paper-item-icon-color: bluewhite
secondary-text-color: blue
label-badge-background-color: white
label-badge-text-color: blue
yes i believe that is the problem. i don’t have themes.
i’m a liitle confuse.
in frontend i use -
frontend: !include frontend.yaml
in frontend.yaml i put - themes: !include_dir_merge_named frontend_themes
an in the directory what do i put you put 2 examples of themes.yaml? i put this -
green:
primary-text-color: green
# paper-card-background-color: white
paper-item-icon-color: green
secondary-text-color: green
label-badge-background-color: white
label-badge-text-color: green
label-badge-red: green
label-badge-border-color: lightgrey
red:
primary-text-color: red
# paper-card-background-color: white #'#fcbba1'
paper-item-icon-color: red
secondary-text-color: red
label-badge-background-color: white #'#fcbba1'
label-badge-text-color: red
blue:
primary-text-color: blue
paper-card-background-color: white" #'#fcbba1'
paper-item-icon-color: blue
secondary-text-color: blue
label-badge-background-color: white #'#fcbba1'
label-badge-text-color: blue
label-badge-red: blue
label-badge-border-color: blue
bluewhite:
primary-text-color: bluewhite
paper-card-background-color: white
paper-item-icon-color: bluewhite
secondary-text-color: blue
label-badge-background-color: white
label-badge-text-color: blue
yes, thats it. check the indent on customizer. Not sure if that should be there, i use a separate customizer.yaml file and have customizer: !include customizer.yaml in the configuration.yaml, no custom_ui there either.
is there anything in your customizer.glob?
most important thing there is:
##########################################################################################
# Customize entities matching a pattern
# to override use: custom_ui_state_card: null
##########################################################################################
"*.*":
custom_ui_state_card: state-card-custom-ui
so you can use the options of the custom_ui on all cards in Hassio.
i did that and use this config
sensor.onofredual1601882_sensor_portao:
friendly_name: Estado do Portão
templates:
icon: mdi:gate
icon_color: if (state === ‘CLOSE’) return ‘rgb(255, 0, 0)’; else return ‘rgb(51, 255, 51)’;
theme: >
if (state === ‘CLOSE’) return ‘rgb(255, 0, 0)’; return ‘rgb(51, 255, 51)’;
i used to have the icon color change but now iven the icon is not correct
where do i put this ?
# Customize entities matching a pattern
# to override use: custom_ui_state_card: null
##########################################################################################
"*.*":
custom_ui_state_card: state-card-custom-ui
##########################################################################################
# Themes for templating entities
##########################################################################################
red:
primary-text-color: red
# paper-card-background-color: white #'#fcbba1'
paper-item-icon-color: red
secondary-text-color: red
label-badge-background-color: white #'#fcbba1'
label-badge-text-color: red
blue:
primary-text-color: blue
paper-card-background-color: white" #'#fcbba1'
paper-item-icon-color: blue
secondary-text-color: blue
label-badge-background-color: white #'#fcbba1'
label-badge-text-color: blue
label-badge-red: blue
label-badge-border-color: blue
bluewhite:
primary-text-color: bluewhite
paper-card-background-color: white
paper-item-icon-color: bluewhite
secondary-text-color: blue
label-badge-background-color: white
label-badge-text-color: blue
green:
primary-text-color: green
# paper-card-background-color: white
paper-item-icon-color: green
secondary-text-color: green
label-badge-background-color: white
label-badge-text-color: green
label-badge-red: green
label-badge-border-color: lightgrey
yellow:
primary-text-color: yellow
# paper-card-background-color: lightgrey
paper-item-icon-color: yellow
secondary-text-color: yellow
label-badge-background-color: lightgrey
label-badge-text-color: yellow
label-badge-red: grey
label-badge-border-color: yellow
yellow_only:
primary-text-color: yellow
paper-item-icon-color: yellow
secondary-text-color: yellow
label-badge-text-color: yellow
orange:
primary-text-color: orange
# paper-card-background-color: white
paper-item-icon-color: orange
secondary-text-color: orange
label-badge-background-color: white
label-badge-text-color: orange
label-badge-red: orange
label-badge-border-color: orange
brown:
primary-text-color: brown
# paper-card-background-color: white
paper-item-icon-color: brown
secondary-text-color: brown
label-badge-background-color: white
label-badge-text-color: brown
label-badge-red: brown
label-badge-border-color: brown
brown_only:
primary-text-color: brown
paper-item-icon-color: brown
secondary-text-color: brown
label-badge-border-color: brown
grey:
primary-text-color: grey
# paper-card-background-color: white
paper-item-icon-color: grey
secondary-text-color: grey
label-badge-red: grey
label-badge-border-color: lightgrey
label-badge-background-color: white
label-badge-text-color: grey
this is not a theme. you are declaring a color.
also, if this is not a template sensor ( cant see because you didnt provide the sensor declaration) you should not use the icon: mdi:gate here. Do that in the sensor declaration, just to be methodical. On the other hand, if this is a template sensor, it could be here, and, of course, if you want the icon to change depending in the state of the sensor.
not sure what you say here, you mean the name is in capitals? or the state. Makes a big difference, when you want the state to be the base of your template. You need to have the state, and have it exact the way it is. If it is False, don’t use ‘false’ in your template. Most of the time template errors arise by not following the exact state.
theme: >
if (state === 'home') return 'green';
return 'red';
indeed. thats what you want, after having successfully made the themes in your themes.yaml…
note that now you use ‘home’ instead of ‘CLOSE’. as long as you don’t post a screenshot of the dev-tools of this sensor, we cant be of assistance debugging this I am afraid. I am a bit puzzled how the icon can change color if you use the wrong state… If your not, than use the exact same state in the theme template here. should work than.