Change icon on/off switch

Hello, I’m new.
Can I change the switch icon?

“On”: mdi: open
“Off”: mdi: closed

I created customize.yaml and typed:

switch.sonoff_1111cff59c:
  friendly_name: Door
  state_icon:
     "On": mdi: open
     "Off": mdi: closed
 

I guess it’s stupid?

Why is your door sensor a switch?

Switches are outputs to be controlled by home assistant, not inputs read by home assistant

Sonoff produces a switch for the garage door.

Customize does not support icon templates. Was the switch discovered or do you have a yaml config for it?

Switch has been discovered.Use the sonoff account in yaml

Then your only option is to change it in Lovelace using something like this:

thank you for direction
it would be easy to change the icons on the switch you created? (input_boolean) ??
created automation, I’m not in HA long

No, input booleans do not support icon templates either.

You could create a template switch that mimics your sonoff switch. They support icon templates.

switch:
  - platform: template
    switches:
      garage:
        value_template: "{{ is_state('switch.sonoff_1111cff59c', 'on') }}"
        turn_on:
          service: switch.turn_on
          data:
            entity_id: switch.sonoff_1111cff59c
        turn_off:
          service: switch.turn_off
          data:
            entity_id: switch.sonoff_1111cff59c
        icon_template: >-
          {% if is_state('switch.sonoff_1111cff59c', 'on') %}
            mdi:door-open
          {% else %}
            mdi:door-closed
          {% endif %}
6 Likes

Thank you so much, this is how it works…