-
Notifications
You must be signed in to change notification settings - Fork 1
/
esp32-ble-hub1.yaml
266 lines (189 loc) · 5.61 KB
/
esp32-ble-hub1.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
#------------------------------
#-- esp32-ble-hub1.yaml
#-- Code pour une esp32-cam pour tester un BLE tracker, un hub BLE (iBeacon, iTag ou Tile)
#-- Je squate une esp32-cam comme un esp32 simple avec Bluetooth
#-- zf220205.1622
#--
# sources:
# https://esphome.io/components/esp32_ble_tracker.html
# https://esphome.io/guides/automations.html#config-lambda
# https://esphome.io/components/sensor/template.html
#
esphome:
name: esp32-ble-hub1
project:
name: "zf.esp32-ble-hub1"
version: "1.0.1"
esp32:
board: esp32cam
framework:
type: arduino
# Configuration WIFI
wifi:
# ssid: !secret wifi_ssid_apzuzu7
# password: !secret wifi_pass_apzuzu7
networks:
- ssid: !secret wifi_ssid_apzuzu7
- password: !secret wifi_pass_apzuzu7
- ssid: !secret wifi_ssid_apzuzu6
- password: !secret wifi_pass_apzuzu6
- ssid: !secret wifi_ssid_3G_zf
- password: !secret wifi_pass_3G_zf2
- ssid: !secret wifi_ssid_3G_zf2
- password: !secret wifi_pass_3G_zf2
- ssid: !secret wifi_ssid_3g_s7
- password: !secret wifi_pass_3g_s7
- ssid: !secret wifi_ssid_apzuzu6_EXT
- password: !secret wifi_pass_apzuzu6_EXT
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "esp32-ble-hub1 Fallback"
password: !secret ap_wifi_password
captive_portal:
# Enable logging
logger:
level: DEBUG
# level: VERBOSE
# # level: VERY_VERBOSE
# logs:
# logger: INFO
# adc: INFO
# captive_portal: INFO
# deep_sleep: INFO
# htu21d: INFO
# i2c: INFO
# ota: INFO
# restart: INFO
# sensor: INFO
# switch: INFO
# switch.gpio: INFO
# uptime.sensor: INFO
# web_server: INFO
# wifi_signal.sensor: INFO
# mqtt: INFO
# mqtt.component: INFO
# mqtt.client: INFO
# mqtt.switch: INFO
# Enable Home Assistant API
api:
password: !secret api_password
# Enable OTA
ota:
password: !secret ota_password
# WEB Server
web_server:
port: 80
# Définition des Switch's
switch:
- platform: restart
name: "esp32-ble-hub1 Restart"
- platform: gpio
name: "esp32-ble-hub1 LED"
inverted: True
id: led
pin: GPIO33
- platform: gpio
name: "esp32-ble-hub1 LED FLASH"
# inverted: True
id: led_flash
pin: GPIO4
- platform: gpio
name: "esp32-ble-hub1 cam power"
inverted: True
id: cam_power
pin: GPIO32
esp32_ble_tracker:
scan_parameters:
duration: 15s
# on_ble_advertise:
# - lambda: |-
# if(x.get_ibeacon().has_value())
# { auto ibeacon = x.get_ibeacon().value();
# ESP_LOGD(ibeacon.get_uuid().to_string().c_str(), " iBeancon found***********************************");
# if(strcmp(ibeacon.get_uuid().to_string().c_str(), "485726A9-2B28-CCB7-354D-0A49B3C68C4E") == 0)
# { id(ble_rssiz).publish_state(x.get_rssi());
# ESP_LOGD("ble_adv", "My Phone found***********************************");
# }
# }
# Définition des sensors
sensor:
- platform: wifi_signal
name: "esp32-ble-hub1 Signal Wi-Fi"
update_interval: 60s
- platform: uptime
name: "esp32-ble-hub1 uptime"
update_interval: 60s
- platform: ble_rssi
name: "BLE SumUp 835 RSSI value"
mac_address: EF:D4:55:26:8C:27
id: toto0136
on_value:
then:
lambda: |-
static float zrssi_1m=-75.0;
static float zn=2.0;
//static float zdist = pow(10.0,zrssi_1m - x / (10.0 * zn));
//static float zdist = id(toto0136).state;
static float zdist = id(toto0136).state;
id(toto1755).publish_state(zdist);
- platform: template
name: "BLE SumUp 835 DIST value"
id: "toto1755"
icon: "mdi:signal-distance-variant"
unit_of_measurement: "m"
update_interval: 5s
- platform: ble_rssi
name: "BLE Tile 1 RSSI value"
mac_address: E0:AA:01:F9:AF:62
- platform: ble_rssi
name: "BLE Tile 2 RSSI value"
mac_address: E1:B0:A7:F3:63:03
- platform: ble_rssi
name: "BLE Beacon 4 RSSI value"
service_uuid: '4e8cc6b3-490a-4d35-b7cc-282ba9265748'
# function zcalc_distance(zrssi2)
# zrssi_1m=-40 zn=2
# zdist=10^((zrssi_1m - zrssi2) / (10 * zn))
# return zdist
# end
# --[[
# print("distance: "..zcalc_distance(-60).."m")
# La formule pour calculer la distance est assez simple.
# d = 10 ^ ((TxPower - RSSI) / (10 * n))
# - TxPower est le RSSI mesuré à 1 m d'un point d'accès connu. Par exemple: -84 dB.
# - n est la constante de propagation ou l'exposant d'affaiblissement de trajet. Par exemple: 2,7 à 4,3 (l'espace libre a n = 2 pour référence).
# - RSSI est le RSSI mesuré
# - d est la distance en mètre
# ]]
# Définition des text sensors
text_sensor:
- platform: version
name: "esp32-ble-hub1 Version"
- platform: wifi_info
ip_address:
name: esp32-ble-hub1 IP Address
id: wifi_ip
ssid:
name: esp32-ble-hub1 Connected SSID
id: wifi_ssid
# - platform: ble_scanner
# name: "BLE Devices Scanner"
# Définition des binary sensors
binary_sensor:
- platform: status
name: "esp32-ble-hub1 Status"
- platform: ble_presence
name: "BLE SumUp 835"
mac_address: EF:D4:55:26:8C:27
- platform: ble_presence
name: "BLE Tile 1"
mac_address: E0:AA:01:F9:AF:62
- platform: ble_presence
name: "BLE Tile 2"
mac_address: E1:B0:A7:F3:63:03
- platform: ble_presence
name: "BLE Beacon 4"
# service_uuid: '4e8cc6b3-490a-4d35-b7cc-282ba9265748'
ibeacon_uuid : 4e8cc6b3-490a-4d35-b7cc-282ba9265748
ibeacon_major : 100
ibeacon_minor : 1