Advertisement
TuXaMaT

Untitled

Oct 25th, 2023
24
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.53 KB | None | 0 0
  1. esphome:
  2. name: fingerprint
  3. friendly_name: Fingerprint
  4. on_boot:
  5. priority: -800
  6. then:
  7. - script.execute: breathing_light
  8.  
  9. esp32:
  10. board: esp32dev
  11. framework:
  12. type: arduino
  13.  
  14. substitutions:
  15. door_icon: mdi:door
  16. motion_icon: mdi:motion-sensor
  17. device_name: Fingerprint
  18.  
  19. web_server:
  20. port: 80
  21.  
  22. wifi:
  23. ssid: !secret wifi_ssid
  24. password: !secret wifi_password
  25.  
  26. # Enable fallback hotspot (captive portal) in case wifi connection fails
  27. ap:
  28. ssid: "Fingerprint Fallback Hotspot"
  29. password: "123456789"
  30.  
  31. captive_portal:
  32.  
  33. # Enable logging
  34. logger:
  35.  
  36. ota:
  37. password: "esphome"
  38.  
  39. uart:
  40. rx_pin: GPIO13
  41. tx_pin: GPIO15
  42. baud_rate: 57600
  43.  
  44. fingerprint_grow:
  45. sensing_pin: GPIO14
  46. on_finger_scan_matched: # палец распознан
  47. - text_sensor.template.publish:
  48. id: fingerprint_state
  49. state: !lambda 'return "Finger " + to_string(finger_id) + ", confidence " + to_string(confidence);'
  50. - if:
  51. condition:
  52. lambda: 'return confidence > 50;'
  53. then:
  54. - homeassistant.tag_scanned: !lambda |-
  55. switch (finger_id) {
  56. case 0:
  57. return "Ilya";
  58. case 1:
  59. return "Ilya";
  60. case 2:
  61. return "Natasha";
  62. case 3:
  63. return "Natasha";
  64. case 4:
  65. return "Andrey";
  66. case 5:
  67. return "Andrey";
  68. case 6:
  69. return "Diana";
  70. case 7:
  71. return "Diana";
  72. case 8:
  73. return "Nastya";
  74. case 9:
  75. return "Nastya";
  76. case 10:
  77. return "Alexander";
  78. case 11:
  79. return "Alexander";
  80. default:
  81. return "person_unknown";
  82. }
  83. - lock.unlock: Gimdow #открываем замок
  84. - binary_sensor.template.publish: # включаем сеснор о правильном распозновании
  85. id: success_scanned
  86. state: ON
  87. - fingerprint_grow.aura_led_control:
  88. state: FLASHING
  89. speed: 25
  90. color: GREEN
  91. count: 5
  92. - delay: 2s
  93. - script.execute: breathing_light
  94. on_finger_scan_unmatched: # палец не распознан
  95. - text_sensor.template.publish:
  96. id: fingerprint_state
  97. state: "Unauthorized finger"
  98. - fingerprint_grow.aura_led_control:
  99. state: FLASHING
  100. speed: 25
  101. color: RED
  102. count: 5
  103. - delay: 1s
  104. - script.execute: breathing_light
  105. on_enrollment_scan: # запись пальца в память
  106. - text_sensor.template.publish:
  107. id: fingerprint_state
  108. state: "Finger scanned"
  109. - fingerprint_grow.aura_led_control:
  110. state: FLASHING
  111. speed: 25
  112. color: Green
  113. count: 3
  114. - fingerprint_grow.aura_led_control:
  115. state: ALWAYS_ON
  116. speed: 0
  117. color: PURPLE
  118. count: 0
  119. on_enrollment_done: # запись пальца прошла успешно
  120. - text_sensor.template.publish:
  121. id: fingerprint_state
  122. state: "Enrolled fingerprint"
  123. - fingerprint_grow.aura_led_control:
  124. state: FLASHING
  125. speed: 15
  126. color: GREEN
  127. count: 3
  128. - delay: 2s
  129. - script.execute: breathing_light
  130. on_enrollment_failed: # неудачная запись пальца
  131. - text_sensor.template.publish:
  132. id: fingerprint_state
  133. state: "Failed to enroll fingerprint"
  134. - fingerprint_grow.aura_led_control:
  135. state: FLASHING
  136. speed: 25
  137. color: RED
  138. count: 4
  139. - delay: 2s
  140. - script.execute: breathing_light
  141.  
  142.  
  143. # Optional template text sensor for visual feedback
  144. text_sensor:
  145. - platform: template
  146. id: fingerprint_state
  147. name: "Fingerprint State"
  148.  
  149. switch: # выход на управление брелком замка
  150. - platform: gpio
  151. pin: GPIO4
  152. inverted: true
  153. id: gate
  154. name: "Switch gate"
  155.  
  156. binary_sensor:
  157. - platform: fingerprint_grow
  158. id: fingerprint_enrolling
  159. name: "Fingerprint Enrolling"
  160. on_state:
  161. then:
  162. - fingerprint_grow.aura_led_control:
  163. state: ALWAYS_ON
  164. speed: 0
  165. color: PURPLE
  166. count: 0
  167. - platform: gpio # сенсор прикосновения к сканеру
  168. filters:
  169. - delayed_on: 10ms
  170. - invert:
  171. pin: GPIO14
  172. id: Finger_touch
  173. name: "Finger touch"
  174. icon: mdi:gesture-tap
  175. on_press:
  176. then:
  177. - if: # включаем звонок
  178. condition:
  179. - binary_sensor.is_off: fingerprint_enrolling
  180. then:
  181. - fingerprint_grow.aura_led_control:
  182. state: ALWAYS_ON
  183. speed: 0
  184. color: YELLOW
  185. count: 0
  186. on_release:
  187. then:
  188. - if: # включаем звонок
  189. condition:
  190. - binary_sensor.is_off: success_scanned
  191. - binary_sensor.is_off: fingerprint_enrolling
  192. then:
  193. - binary_sensor.template.publish:
  194. id: zvonok
  195. state: ON
  196. - script.execute: breathing_light
  197. - platform: homeassistant # использование датчика двери из Home Assistant
  198. name: "Door sensor"
  199. id: Door_sensor
  200. entity_id: binary_sensor.datchiki_ohrana_dver
  201. on_state:
  202. then:
  203. - if:
  204. condition:
  205. - binary_sensor.is_on: Door_sensor
  206. then:
  207. - fingerprint_grow.aura_led_control:
  208. state: BREATHING
  209. speed: 85
  210. color: GREEN
  211. count: 0
  212. else:
  213. - script.execute: breathing_light_zamok
  214. # - platform: gpio # вход бинарного датчика открытия двери
  215. # id: Door_sensor
  216. # name: "Door sensor"
  217. # pin:
  218. # number: 33
  219. # mode: INPUT_PULLUP
  220. - platform: gpio # вход бинарного датчика открытия замка
  221. id: Lock_sensor
  222. name: "Lock sensor"
  223. filters:
  224. - delayed_on: 200ms
  225. pin:
  226. number: 32
  227. mode: INPUT_PULLUP
  228. on_state:
  229. then:
  230. - script.execute: breathing_light_zamok
  231. - platform: template # сенсор удачного распознавания пальца
  232. name: success_scanned
  233. id: success_scanned
  234. icon: mdi:fingerprint
  235. on_state:
  236. then:
  237. - delay: 5 s
  238. - binary_sensor.template.publish:
  239. id: success_scanned
  240. state: OFF
  241. - platform: template # звонок
  242. name: zvonok
  243. id: zvonok
  244. icon: mdi:bell-ring
  245. on_state:
  246. then:
  247. - delay: 5 s
  248. - binary_sensor.template.publish:
  249. id: zvonok
  250. state: OFF
  251.  
  252. - platform: status
  253. name: "${device_name}_status"
  254.  
  255.  
  256. time:
  257. - platform: homeassistant
  258. id: homeassistant_time
  259.  
  260.  
  261.  
  262. sensor:
  263. - platform: fingerprint_grow
  264. fingerprint_count:
  265. name: "Fingerprint Count"
  266. last_finger_id:
  267. name: "Fingerprint Last Finger ID"
  268. last_confidence:
  269. name: "Fingerprint Last Confidence"
  270. status:
  271. name: "Fingerprint Status"
  272. capacity:
  273. name: "Fingerprint Capacity"
  274. security_level:
  275. name: "Fingerprint Security Level"
  276.  
  277. - platform: wifi_signal
  278. name: "${device_name}_rssi"
  279. update_interval: 5min
  280.  
  281. - platform: uptime
  282. id: uptime_sec
  283. name: "${device_name}_uptime"
  284. update_interval: 5min
  285.  
  286. api:
  287. encryption:
  288. key: "zZCS3TMQTh5vgtUDHHt04Cl/TUBiJE9xqkSAfDYFqmQ="
  289. services:
  290. - service: enroll
  291. variables:
  292. finger_id: int
  293. num_scans: int
  294. then:
  295. - fingerprint_grow.enroll:
  296. finger_id: !lambda 'return finger_id;'
  297. num_scans: !lambda 'return num_scans;'
  298. - service: cancel_enroll
  299. then:
  300. - fingerprint_grow.cancel_enroll:
  301. - service: delete
  302. variables:
  303. finger_id: int
  304. then:
  305. - fingerprint_grow.delete:
  306. finger_id: !lambda 'return finger_id;'
  307. - service: delete_all
  308. then:
  309. - fingerprint_grow.delete_all:
  310.  
  311. lock: # кнопки открытия/закрытия Gimdow с датчиком замка двери из ХА
  312. - platform: template
  313. name: Gimdow
  314. id: Gimdow
  315. optimistic: true
  316. assumed_state: true
  317. lock_action:
  318. - switch.turn_on: gate
  319. - delay: 100ms
  320. - switch.turn_off: gate
  321. unlock_action:
  322. - switch.turn_on: gate
  323. - delay: 100ms
  324. - switch.turn_off: gate
  325. - delay: 100ms
  326. - switch.turn_on: gate
  327. - delay: 100ms
  328. - switch.turn_off: gate
  329. lambda: |-
  330. if (id(Lock_sensor).state) {
  331. return LOCK_STATE_UNLOCKED;
  332. } else {
  333. return LOCK_STATE_LOCKED;
  334. }
  335.  
  336. script: #режим светодиода в зависимости от замка двери для возвращения значения после операций
  337. - id: breathing_light
  338. then:
  339. if:
  340. condition:
  341. - binary_sensor.is_off: Lock_sensor
  342. then:
  343. - fingerprint_grow.aura_led_control:
  344. state: BREATHING
  345. speed: 255
  346. color: BLUE
  347. count: 0
  348. else:
  349. - fingerprint_grow.aura_led_control:
  350. state: BREATHING
  351. speed: 85
  352. color: BLUE
  353. count: 0
  354. - id: breathing_light_zamok #режим светодиода в зависимости от замка двери только для самого замка
  355. then:
  356. if:
  357. condition:
  358. - binary_sensor.is_off: Lock_sensor
  359. then:
  360. - fingerprint_grow.aura_led_control:
  361. state: FLASHING
  362. speed: 35
  363. color: GREEN
  364. count: 1
  365. - fingerprint_grow.aura_led_control:
  366. state: BREATHING
  367. speed: 255
  368. color: BLUE
  369. count: 0
  370. else:
  371. - fingerprint_grow.aura_led_control:
  372. state: FLASHING
  373. speed: 35
  374. color: GREEN
  375. count: 1
  376. - fingerprint_grow.aura_led_control:
  377. state: BREATHING
  378. speed: 85
  379. color: BLUE
  380. count: 0
  381.  
  382.  
  383.  
  384.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement