-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathdoor_lock.yaml
95 lines (84 loc) · 2.43 KB
/
door_lock.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
esphome:
name: door_lock
platform: ESP8266
board: d1_mini
includes:
- door_lock_rfid.h
libraries:
- "ESP8266HTTPClient"
- "SPI"
- "MFRC522"
# Need to override -Wl,-T - the only way is by setting all build_flags
platformio_options:
build_flags: -DESPHOME_LOG_LEVEL=ESPHOME_LOG_LEVEL_DEBUG -DUSE_STORE_LOG_STR_IN_FLASH -Wl,-Teagle.flash.4m1m.ld -fno-exceptions
custom_component:
- lambda: |-
auto component = new RfidSensorsComponent();
return { component };
id: rfid_component
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
manual_ip:
static_ip: 192.168.77.247
gateway: 192.168.77.2
subnet: 255.255.255.0
# Enable logging
logger:
# Enable OTA updates
ota:
password: !secret ota_password
# Enable Home Assistant API
api:
password: !secret api_password
services:
- service: print_users_list
then:
lambda: |-
auto component_id = id(rfid_component);
RfidSensorsComponent* component = ((RfidSensorsComponent*) (component_id.get_component(0)));
component->send_users_list_notification();
- service: upload_users_list
variables:
list: string[]
then:
lambda: |-
auto component_id = id(rfid_component);
RfidSensorsComponent* component = ((RfidSensorsComponent*) (component_id.get_component(0)));
component->upload_users_list(list);
binary_sensor:
- platform: custom
lambda: |-
auto component_id = id(rfid_component);
RfidSensorsComponent* component = ((RfidSensorsComponent*) (component_id.get_component(0)));
return { component->valid_tag_sensor, component->invalid_tag_sensor };
binary_sensors:
- name: "Valid tag"
on_press:
switch.turn_on: door_lock
- name: "Invalid tag"
text_sensor:
- platform: custom
lambda: |-
auto component_id = id(rfid_component);
RfidSensorsComponent* component = ((RfidSensorsComponent*) (component_id.get_component(0)));
return { component->last_tag_id_sensor, component->last_tag_description_sensor };
text_sensors:
- name: "Last tag ID"
icon: "mdi:card-bulleted-outline"
- name: "Last tag description"
icon: "mdi:card-bulleted-outline"
status_led:
pin:
number: D4 # GPIO2 pin
inverted: true
switch:
- platform: gpio
pin: D0 # GPIO16 pin
restore_mode: ALWAYS_OFF
id: door_lock
name: "Door lock"
icon: "mdi:lock-outline"
on_turn_on:
- delay: 5s
- switch.turn_off: door_lock