我自己是用電視的聯網狀態來確認電視是否有開啟
switch:
- platform: template
switches:
sharp_tv:
friendly_name: "電視"
value_template: '{{ is_state("device_tracker.sharp_tv", "home") }}'
turn_on:
- condition: state
entity_id: device_tracker.sharp_tv
state: 'not_home'
- service: switch.turn_on
data:
entity_id: switch.sharp_tv_power
turn_off:
- condition: state
entity_id: device_tracker.sharp_tv
state: 'home'
- service: switch.turn_off
data:
entity_id: switch.sharp_tv_power
icon_template: >-
{% if is_state('device_tracker.sharp_tv', 'home') %}
mdi:television
{% else %}
mdi:television-off
{% endif %}
|