-
Notifications
You must be signed in to change notification settings - Fork 0
/
bt-tph-p.yaml
276 lines (243 loc) · 6.08 KB
/
bt-tph-p.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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
substitutions:
name: esp32-bluetooth-proxy-e2ab8c
friendly_name: ESP32 BT Proxy ArOme
short_name: ESP32 ArOme
core_name: $short_name Core
bme680_name: $short_name TPH
ld2410_name: $short_name mmWave
comment: Bluetooth Proxy & BME680 Temperature Pressure Humidity & HLK-LD2410C-P Presence
esphome:
name: ${name}
name_add_mac_suffix: false
friendly_name: ${friendly_name}
comment: ${comment}
on_boot:
- priority: 900.0
then:
- lambda: |-
id(cpu_speed) = ESP.getCpuFreqMHz();
project:
name: esphome.bluetooth-proxy
version: "1.0"
# Define Card type
esp32:
board: esp32dev
framework:
type: arduino
# Enable logging & ota
logger:
improv_serial:
ota:
- platform: esphome
# Enable Home Assistant API
api:
encryption:
key: "VE4bNta9HDnOAcZ80v7Ujc4jXs4GFmMERLs4kybq1JA="
# Enable ESPHome Web
#web_server:
#local: true
# Local WiFI Config & fix IP
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
manual_ip:
static_ip: 192.168.1.177
gateway: 192.168.1.1
subnet: 255.255.255.0
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: ${name}
password: !secret wifi_ap_password
captive_portal:
# Define CPU Speed
globals:
- id: cpu_speed
type: int
restore_value: no
initial_value: "0"
# Define time & sync
time:
- platform: sntp
id: time_sntp
# Import BT
dashboard_import:
package_import_url: github://esphome/firmware/bluetooth-proxy/esp32-generic.yaml@main
# Bluetooth config
esp32_ble_tracker:
scan_parameters:
# We currently use the defaults to ensure Bluetooth
# can co-exist with WiFi In the future we may be able to
# enable the built-in coexistence logic in ESP-IDF
active: true
bluetooth_proxy:
active: true
# Define HLK-LD2410C-P
uart:
id: ld2410_uart
tx_pin: TX
rx_pin: RX
baud_rate: 256000
parity: NONE
stop_bits: 1
ld2410:
uart_id: ld2410_uart
id: mmwave
# Define i2c connection for BME680
i2c:
sda: 21
scl: 22
scan: true
id: bus_a
# Exposes control number
number:
# HLK-LD2410C-P
- platform: ld2410
timeout:
name: "$ld2410_name Timeout"
light_threshold:
name: "$ld2410_name Light threshold"
max_move_distance_gate:
name: "$ld2410_name Max move distance gate"
max_still_distance_gate:
name: "$ld2410_name Max still distance gate"
# Binary sensors
binary_sensor:
# HLK-LD2410C-P data from OUT PIN
- platform: gpio
pin: GPIO34
name: "$ld2410_name Out Pin"
device_class: presence
# HLK-LD2410C-P data from UART
- platform: ld2410
has_target:
name: "$ld2410_name Presence"
has_moving_target:
name: "$ld2410_name Moving Target"
has_still_target:
name: "$ld2410_name Still Target"
# Exposes control switches
switch:
# HLK-LD2410C-P
- platform: ld2410
bluetooth:
name: "$ld2410_name Control bluetooth"
# Exposes control selection
select:
# HLK-LD2410C-P
- platform: ld2410
distance_resolution:
name: "$ld2410_name Distance resolution"
light_function:
name: "$ld2410_name Light function"
# Sensors
sensor:
# Reports the WiFi signal strength/RSSI in dB
- platform: wifi_signal
name: "$core_name WiFi Signal dB"
id: wifi_signal_db
update_interval: 60s
entity_category: "diagnostic"
# Reports the WiFi signal strength in %
- platform: copy
source_id: wifi_signal_db
name: "$core_name WiFi Signal"
filters:
- lambda: return min(max(2 * (x + 100.0), 0.0), 100.0);
unit_of_measurement: "%"
entity_category: "diagnostic"
device_class: ""
# Reports the uptime
- platform: uptime
name: "$core_name Uptime Sensor"
id: uptime_seconds
# Device CPU Speed
- platform: template
name: "$core_name Cpu Speed"
accuracy_decimals: 0
unit_of_measurement: Mhz
lambda: |-
return (id(cpu_speed));
entity_category: "diagnostic"
# BME680
- platform: bme680
temperature:
name: "$bme680_name Temperature"
oversampling: 16x
pressure:
id: "humidity"
name: "$bme680_name Pressure"
humidity:
name: "$bme680_name Humidity"
gas_resistance:
id: "gas_resistance"
name: "$bme680_name Gas Resistance"
i2c_id: bus_a
address: 0x77
update_interval: 60s
- platform: template
name: "$bme680_name Indoor Air Quality"
id: iaq
icon: "mdi:gauge"
# Calculation: comp_gas = log(R_gas[ohm]) + 0.04 log(Ohm)/%rh * hum[%rh]
lambda: |-
return log(id(gas_resistance).state) + 0.04 * id(humidity).state;
# HLK-LD2410C-P
- platform: ld2410
light:
name: "$ld2410_name Light"
moving_distance:
name : "$ld2410_name Moving Distance"
still_distance:
name: "$ld2410_name Still Distance"
moving_energy:
name: "$ld2410_name Move Energy"
still_energy:
name: "$ld2410_name Still Energy"
detection_distance:
name: "$ld2410_name Detection Distance"
# Text Sensor
text_sensor:
# BME680 IAQ Classification
- platform: template
name: "$bme680_name IAQ Classification"
icon: "mdi:checkbox-marked-circle-outline"
lambda: |-
if (int(id(iaq).state) <= 50) {
return {"Excellent"};
}
else if (int(id(iaq).state) <= 100) {
return {"Good"};
}
else if (int(id(iaq).state) <= 150) {
return {"Lightly polluted"};
}
else if (int(id(iaq).state) <= 200) {
return {"Moderately polluted"};
}
else if (int(id(iaq).state) <= 250) {
return {"Heavily polluted"};
}
else if (int(id(iaq).state) <= 350) {
return {"Severely polluted"};
}
else if (int(id(iaq).state) <= 500) {
return {"Extremely polluted"};
}
else {
return {"unknown"};
}
# HLK-LD2410C-P
- platform: ld2410
version:
name: "$ld2410_name Firmware version"
mac_address:
name: "$ld2410_name MAC address"
#Exposes control buttons
button:
- platform: restart
icon: mdi:power-cycle
name: "$core_name Reboot"
# HLK-LD2410C-P
- platform: ld2410
restart:
name: "$ld2410_name Restart"