Skip to content

Instantly share code, notes, and snippets.

@xangin
Last active July 18, 2021 06:42
Show Gist options
  • Save xangin/451cfd0eb3df6aca26ff446764c389e9 to your computer and use it in GitHub Desktop.
Save xangin/451cfd0eb3df6aca26ff446764c389e9 to your computer and use it in GitHub Desktop.
Home Assistant Blueprint - Door Open Notify - Traditional Chinese describe
blueprint:
name: 門開時發通知
description: 當門持續開啟與間隔多久及門關上時,發送通知提醒
domain: automation
input:
door_entity:
name: 門的實體
selector:
entity:
domain: binary_sensor
device_class: door
open_time_interval:
name: 時間間隔
description: 當門開啟與間隔多久時,要發送通知(單位:秒)
default: 30
selector:
number:
min: 0.0
max: 3600.0
unit_of_measurement: seconds
step: 1.0
mode: slider
notify_service_open:
name: 當門開啟時,發送的通知內容
description: 請用「執行服務」並選擇notify或tts服務,並輸入通知內容。可同時使用2個以上的服務。使用{{ door_name }}變數會帶入門的friendly_name
selector:
action: {}
notify_service_close:
name: 當門關上時,發送的通知內容
description: 請用「執行服務」並選擇notify或tts服務,並輸入通知內容。可同時使用2個以上的服務。使用{{ door_name }}變數會帶入門的friendly_name
selector:
action: {}
mode: single
max_exceeded: silent
trigger:
platform: state
entity_id: !input 'door_entity'
to: 'on'
for:
seconds: !input 'open_time_interval'
variables:
door_entity: !input 'door_entity'
door_name: '{{ states[door_entity].name }}'
action:
- repeat:
while:
- condition: state
entity_id: !input 'door_entity'
state: 'on'
sequence:
- choose: []
default: !input 'notify_service_open'
- wait_template: '{{ is_state(door_entity, ''off'') }}'
timeout: !input 'open_time_interval'
- condition: state
entity_id: !input 'door_entity'
state: 'off'
- choose: []
default: !input 'notify_service_close'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment