Lovelace badge color and icon change

Hello,
I want to toggle an automation in my Lovelace dashboard using a badge. This already works, but instead of “on” and “off” I would like to implement a changing icon with changing color. I have already tried it in different ways, however I still have “on/off”. Maybe someone knows a solution?
Here is my YAML code (here, for example, only the color is tried to adjust):

badges:
      - entity: automation.bewegungsmelder_einfach
        name: Bewegung Hof
        templates:
          icon_color: >
            if (state == 'on') return 'rgb(200, 100, 30)';  return 'rgb(10, 20,
            30)';
        tap_action:
          action: toggle