forked from adonno/tagreader
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtagreader.yaml
125 lines (109 loc) · 2.61 KB
/
tagreader.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
115
116
117
118
119
120
121
122
123
124
125
# Insert your SSID and Your PWD after inital setup
wifi:
networks:
# - ssid: !secret wifi_ssid # Uncomment this line (remove # at beginning of line) and enter your details in secrets.yaml file!
# password: !secret wifi_password # Uncomment this line (remove # at beginning of line) and enter your details in secrets.yaml file!
ap:
ssid: ${devicename}
# Enable the captive portal for inital WiFi setup
captive_portal:
substitutions:
devicename: tagreader
friendly_name: TagReader
esphome:
name: $devicename
platform: ESP8266
board: d1_mini
# If buzzer is enabled, notify on api connection success
on_boot:
priority: -10
then:
- wait_until:
api.connected:
- logger.log: API is connected!
- rtttl.play: "success:d=24,o=5,b=100:c,g,b"
- light.turn_on:
id: activity_led
brightness: 100%
red: 0%
green: 0%
blue: 100%
flash_length: 500ms
# Define switches to control LED and buzzer from HA
switch:
- platform: template
name: "${friendly_name} Buzzer Enabled"
id: buzzer_enabled
icon: mdi:volume-high
optimistic: true
- platform: template
name: "${friendly_name} LED enabled"
id: led_enabled
icon: mdi:alarm-light-outline
optimistic: true
# Enable logging
logger:
# level: VERY_VERBOSE
# level: VERBOSE
# Enable Home Assistant API
api:
services:
- service: rfidreader_tag_ok
then:
- rtttl.play: "beep:d=16,o=5,b=100:b"
- service: rfidreader_tag_ko
then:
- rtttl.play: "beep:d=8,o=5,b=100:b"
- service: play_rtttl
variables:
song_str: string
then:
- rtttl.play: !lambda 'return song_str;'
# Enable OTA upgrade
ota:
i2c:
scan: False
frequency: 400kHz
pn532_i2c:
id: pn532_board
on_tag:
then:
- homeassistant.tag_scanned: !lambda 'return x;'
- if:
condition:
switch.is_on: buzzer_enabled
then:
- rtttl.play: "success:d=24,o=5,b=100:c,g,b"
- if:
condition:
switch.is_on: led_enabled
then:
- light.turn_on:
id: activity_led
brightness: 100%
red: 0%
green: 100%
blue: 0%
flash_length: 500ms
# Define the buzzer output
output:
- platform: esp8266_pwm
pin: D7
id: buzzer
binary_sensor:
- platform: status
name: "${friendly_name} Status"
# Define buzzer as output for RTTTL
rtttl:
output: buzzer
# Configure LED
light:
- platform: fastled_clockless
chipset: WS2812
pin: D8
default_transition_length: 10ms
num_leds: 1
rgb_order: GRB
id: activity_led
name: "${friendly_name} LED"
restore_mode: ALWAYS_OFF