Switch with dynamic custom icon

Hi,
I’m looking for a switch with a different custom icon for the ON and OFF state. That should look like

on
off

- platform: template
  switches:
  test1:    
      value_template: "{{ states.input_boolean.virtual1.state }}"
      turn_on:
        service: switch.turn_on
        entity_id: input_boolean.virtual1
      turn_off:
        service: switch.turn_off
        entity_id: input_boolean.virtual1
      entity_picture_template: >
        {% if (states.input_boolean.virtual1.state=='on') %}
          /local/verified-red.png
        {% else %}
          /local/verified.png
        {% endif %}

The above configuration generates a switch that reacts on an action of another input_boolean named virtual1, but I’m looking for a customized switch that changes its icon dependent on its OWN change.
I was trying the following:

- platform: template
  switches:
    testswitch:
      value_template: "{{ states.switch.testswitch.state }}"
      turn_on:
        service: switch.turn_on
        entity_id: switch.testswitch
      turn_off:
        service: switch.turn_off
        entity_id: switch.testswitch
      entity_picture_template: >
        {% if (states.switch.testswitch.state=='on') %}
          /local/verified-red.png
        {% else %}
          /local/verified.png
        {% endif %}

This configuration generates the following, but the switch doesn’t react on anything

testswitch

Can anyone help me or give me a direction?

This is complete circular logic all the way around.
The switches state is determined by the switches state.
The turn_on of the switch turns on the switch.

I would not expect this to work in any way. I’m frankly surprised it even materializes in the U.I.

You’re going to have to break out of this circular logic to move forward.
What does the switch REALLY do. If it is only intended to turn itself on and off, then input_boolean is a better choice.
If it’s intended to turn something on and off in the real world, then make it do that. Then you can set the value template to determine the state of the switch by the state of that real-world object.

Hi Treno,

Thanks for your answer.
Perhaps I was a bit unclear in my question. My goal is a customizable switch that can be accessed via a python script in appdeamon. The only function of the switch is to act as a nice GUI interface for appdeamon. I’m trying to find a switch with different icons for ON and OFF, but I can’t find a solution for that. Do you perhaps know another way to accomplish that?

Regards,
Will

The input_boolean solution from the beginning of your post seems viable to me. You can hide the input_boolean so you can’t see it. Then the switch just appears to go on and off with no function.

Perhaps the quotes on the value template is making it a string? Treno got this working