你可以照着改改
switch:
- platform: template
switches:
XXXXXX:
friendly_name: XXXX
value_template: "{{ is_state('switch.XXX', 'off') }}"
turn_on:
service: switch.turn_off
data:
entity_id: switch.XXX
turn_off:
service: switch.turn_on
data:
entity_id: switch.XXX
icon_template: "{% if is_state('switch.XXX', 'on') %}mdi:toggle-switch{% else %}mdi:toggle-switch-off{% endif %}"
|