#############
# DOOR LOCK #
#############
# 建立虚拟按键(按键默认状态为off) #
input_boolean:
lock:
initial: off
# 建立开锁脚本 #
script:
unlock:
sequence:
# 博联地址 #
- service: broadlink.send_packet_192_168_1_XXX
data:
packet:
- "射频码"
homeassistant:
customize:
input_boolean.lock:
friendly_name: 开锁
homebridge_hidden: false
homebridge_name: 开锁
script.unlock:
homebridge_hidden: true
automation:
# 此自动化名称 #
- alias: "unlock the door"
# 重启HA后本自动化状态 true开启 false关闭 #
initial_state: true
# 是否隐藏此自动化 #
hide_entity: true
# 执行此自动化的条件 #
# 虚拟按键从 off 到 on 时,执行action #
trigger:
# 状态 #
- platform: state
# 虚拟按键 #
entity_id: input_boolean.lock
# 从 off 到 on #
from: 'off'
to: 'on'
# 执行以下动作 #
action:
# 1. 执行开锁脚本 #
- service: script.unlock
# 2. 0.5秒后 #
- delay:
seconds: 0.5
# 3. 关闭虚拟按键 #
- service: input_boolean.turn_off
entity_id: input_boolean.lock
|