-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathguest-entry-notifier.yaml
114 lines (107 loc) · 3.06 KB
/
guest-entry-notifier.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
---
# SPDX-License-Identifier: MIT
blueprint:
name: Guest Entry Notifier (v0.2)
description: |
Basic thread starter for use with Rental Control and Zulip
domain: automation
input:
notify_service:
name: Zulip Notify
description: |
Notify service name to send to. Should be a Zulip (or compatible)
notify service
default: "zulip"
guest_calendar:
name: Guest Calendar
description: The Calendar used for tracking guest
selector:
entity:
domain: calendar
guest_entry:
name: Guest Entry Helper
description: |
Helper boolean for tracking if the guest thread has been starter
selector:
entity:
domain: input_boolean
default: "input_boolean.guest_entry"
slot_min:
name: Minimum slot number
description: |
The slot number minimum for guests
selector:
number:
min: 1
max: 30
default: 6
slot_max:
name: Max slot number
description: |
The slot number maximum for guests
selector:
number:
min: 1
max: 30
default: 10
mode: single
trigger:
- platform: event
event_type: keymaster_lock_state_changed
event_data:
state: unlocked
id: unlock
variables:
slot_name: |-
{%- if trigger.event.data.code_slot_name == "" -%}
Manual
{%- else -%}
{{ trigger.event.data.code_slot_name }}
{%- endif -%}
slot_num: "{{ trigger.event.data.code_slot }}"
- platform: calendar
event: end
offset: "0:0:0"
entity_id: !input guest_calendar
id: guest_checkout
variables:
input_notify_service: !input notify_service
input_slot_min: !input slot_min
input_slot_max: !input slot_max
# yamllint disable-line rule:line-length
notify_target: "{{ input_notify_service | lower | replace('notify.', '') | replace(' ', '_') }}"
action:
- choose:
- alias: Door Unlocked
conditions:
- condition: trigger
id:
- unlock
sequence:
- choose:
- alias: Guest Check-in Notification
conditions:
- condition: and
conditions:
- "{{ slot_num >= input_slot_min }}"
- "{{ slot_num <= input_slot_max }}"
- condition: state
entity_id: !input guest_entry
state: "off"
sequence:
- service: input_boolean.turn_on
target:
entity_id: !input guest_entry
- service: notify.{{ notify_target }}
data:
title: "Guest {{ slot_name }}"
message: "Guest has checked-in"
- alias: Guest checkout
conditions:
- condition: trigger
id:
- guest_checkout
sequence:
- service: input_boolean.turn_off
target:
entity_id: !input guest_entry