as stated above, for customizing icon_color, you need custom-ui installed. check the /developer-tools/info for that:
then, among the many possible javascript syntaxes available, I find this to be the cleanest:
device_tracker.apple_wireless_keyboard:
templates:
icon_color: >
if (state === 'home') return 'rgb(251, 210, 41)';
return 'rgb(54, 95, 140)';
any css color-coding can be used, most of the time rgb is used for fine coloring, or simply use the color names available, always between quotes.
the above code is placed in a hierarchy in your config, under
homeassistant:
customize:
depending on your settings, it could be in your configuration.yaml, or if you want in in a separate file/folder, use eg this:
homeassistant:
name: Main
latitude: !secret latitude
longitude: !secret longitude
elevation: !secret elevation
unit_system: metric
time_zone: !secret time_zone
customize: !include_dir_merge_named customize <---- this is the important line
customize_glob: !include customize_glob.yaml
and have a folder /config/customize , in which you place the file with the above customization directly.
or use the line
customize: !include customize.yaml
and add the file customize.yaml in which the same customization is written.