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…

Many sensors will provide their own icons already, I wish there were less examples of this over complicated if-then-else for icon_template

icon_template: "{{ state_attr('binary_sensor.your_device', 'icon') }}"

You’ll need to provide more information. You have revived a SOLVED post from 2020 and it’s not clear what you are asking.

Sorry, updated my post thanks

What specific card are you referring too? You can template icons, some cards allow templating for the icon field and others may require modding. Trying to get a feel for your situation.

I’m trying to control my companion app’s functions, e.g. bluetooth, mute/unmute and it seems incredibly tedious given that they are all developed by HA, see Combining Bluetooth sensor and command into a toggle switch

I’ll let others chime in. You want to control your phones BT settings via a message command. From my understanding, Notify doesn’t control phone setting beyond the app.