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.
change:
icon_color: if (state === 'CLOSE') return 'rgb(255, 0, 0)'; else return 'rgb(51, 255, 51)';
into
icon_color: <
if (state === 'CLOSE') return 'rgb(255, 0, 0)';
return 'rgb(51, 255, 51)';
the else
is not necessary, this makes it cleaner and easier to read.
btw, are you sure the state is in capitals? never seen that before. could you post a screenshot of the sensor in the dev tools <> ?