简单车库门

以下是一个用于控制由两个继电器操作的车库门的可能配置文件: 一个用于打开车库门,另一个用于关闭车库门。当其中任何一个继电器短时间开启时, 关闭/打开操作开始。

switch:
  - platform: gpio
    pin: GPIOXX
    name: "车库门打开开关"
    id: open_switch
  - platform: gpio
    pin: GPIOXX
    name: "车库门关闭开关"
    id: close_switch
cover:
  - platform: template
    name: "车库门"
    open_action:
      # 取消任何之前的操作
      - switch.turn_off: close_switch
      # 短暂开启打开开关
      - switch.turn_on: open_switch
      - delay: 0.1s
      - switch.turn_off: open_switch
    close_action:
      - switch.turn_off: open_switch
      - switch.turn_on: close_switch
      - delay: 0.1s
      - switch.turn_off: close_switch
    stop_action:
      - switch.turn_off: close_switch
      - switch.turn_off: open_switch
    optimistic: true
    assumed_state: true

参见