# Example configuration.yaml entry switch: - platform: template switches: mailbox: turn_on: service: switch.turn_on target: entity_id: switch.mailbox turn_off: service: switch.turn_off target: entity_id: switch.mailbox icon_template: > {% if is_state('switch.mailbox', 'on') %} mdi:mailbox {% else %} mdi:mailbox-outline {% endif %}