本帖最后由 chinyaolin 于 2018-6-11 17:23 编辑
請試試看, 全憑想像, 不保證可以用
依照你的文字敘述,
1.建立一個 binary_sensor,
1-off 2-on 代表「窗帘開」而 1-on 2-off 代表「窗帘關」, 其餘狀態 unknow
binary_sensor:
- platform: template
cover_state:
friendly_name: "狀態"
value_template: >
{% if is_state("switch.switch1", "off") and is_state("switch.espurna_05e119", "on") -%}
on
{%- elif is_state("switch.switch1", "on") and is_state("switch.switch2", "off") -%}
off
{%- else -%}
unknow
{%- endif %}
2.建立二個 script, 分別執行「開」與「關」的動作
script:
cover_open:
sequence:
- service: switch.turn_off
data:
entity_id: switch.switch1
- delay:
milliseconds: 300
- service: switch.turn_on
data:
entity_id: switch.switch2
cover_close:
sequence:
- service: switch.turn_on
data:
entity_id: switch.switch1
- delay:
milliseconds: 300
- service: switch.turn_off
data:
entity_id: switch.switch2
3.最後建立 template cover
cover:
- platform: template
covers:
cover1:
friendly_name: "窗帘"
value_template: "{{states.binary_sensor.cover_state.state}}"
open_cover:
service: script.cover_open
close_cover:
service: script.cover_close
|