拿走不谢,下面是我根据输入源自动控制机顶盒电源的设置
automation:
- alias: power_auto_control_for_iptv
initial_state: true
trigger:
- platform: template
value_template: "{{ is_state_attr('media_player.sony_tv', 'media_content_id', 'HDMI 2') }}"
- platform: state
entity_id:
- media_player.sony_tv
from: 'on'
to: 'off'
for:
seconds: 50
action:
- service_template: >
{% if is_state('media_player.sony_tv','off') %}
switch.turn_off
{% else %}
switch.turn_on
{% endif %}
entity_id:
- switch.device4
|