Template: better way to have icon color follow sensor state?

HI,

My lux sensors are colored with below template, but i was wondering if a more precise and automatic (built-in) way of coloring would be available/possible?

sensor.frontdoor_motion_sensor_lux:
   show_last_changed: true
   templates:
     icon_color: "if (state < 10) return 'rgb(0,0,0)';
                  if (state < 20) return 'rgb(51,0,0)'; 
                  if (state < 50) return 'rgb(51,25,0)'
                  if (state < 100) return 'rgb(102,51,0)';
                  if (state < 150) return 'rgb(153,153,0)';
                  if (state < 200) return 'rgb(102,204,0)';
                  if (state < 300) return 'rgb(51,255,53)';
                  if (state < 400) return 'rgb(102,255,178)';
                  if (state < 500) return 'rgb(153,255,255)';
                  else return 'rgb(204, 255, 229)';"
   icon: mdi:theme-light-dark

a bit like the Hue Light icons follow the color of the light.

Cheers,
Marius