Add Grow fingerprint reader docs (#835)

This commit is contained in:
Barry Loong 2021-04-29 06:08:31 +08:00 committed by GitHub
parent a155f16595
commit 486e91a07b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 532 additions and 0 deletions

View File

@ -0,0 +1,530 @@
Grow Fingerprint Reader
=======================
.. seo::
:description: Instructions for setting up Grow Fingerprint Reader integration in ESPHome.
:image: fingerprint.png
The ``fingerprint_grow`` component allows you to use your R307, R503, ZFM-20, ... fingerprint sensors with ESPHome.
.. figure:: images/r307-full.jpg
:align: center
:width: 50.0%
R307/ZFM-20 Optical Fingerprint Reader (`datasheet <https://cdn-shop.adafruit.com/datasheets/ZFM+user+manualV15.pdf>`__, `Adafruit <https://www.adafruit.com/product/751>`__). Image by `Adafruit <https://www.adafruit.com/product/751>`__.
.. figure:: images/r503-full.jpg
:align: center
:width: 50.0%
R503 Capacitive Fingerprint Reader with Bi-Color Aura LED (`datasheet <https://cdn-shop.adafruit.com/product-files/4651/4651_R503+fingerprint+module+user+manual.pdf>`__, `Adafruit <https://www.adafruit.com/product/4651>`__). Image by `Adafruit <https://www.adafruit.com/product/4651>`__.
Overview
--------
The reader can be powered by the 3.3V output of an NodeMCU. As the communication with the reader is done using UART (default baud rate is 57600), you need to have an :ref:`UART bus <uart>` in your configuration with the ``rx_pin`` connected to the reader's ``TX`` and the ``tx_pin`` connected to the reader's ``RX``.
If available on your reader model, it's recommended to connect 3.3VT (touch induction power supply) to 3.3V; WAKEUP (finger detection signal) to a free GPIO pin and define it with the ``sensing_pin`` option to allow the polling function to quickly return when there's no finger on the reader.
.. code-block:: yaml
# Example configuration entry
uart:
rx_pin: GPIO13
tx_pin: GPIO15
baud_rate: 57600
# Declare Grow Fingerprint Reader
fingerprint_grow:
sensing_pin: GPIO12
on_finger_scan_matched:
- text_sensor.template.publish:
id: fingerprint_state
state: "Authorized finger"
- switch.turn_on: gate
- delay: 500ms
- switch.turn_off: gate
on_finger_scan_unmatched:
- text_sensor.template.publish:
id: fingerprint_state
state: "Unauthorized finger"
on_enrollment_scan:
- text_sensor.template.publish:
id: fingerprint_state
state: "Finger scanned"
on_enrollment_done:
- text_sensor.template.publish:
id: fingerprint_state
state: "Enrolled fingerprint"
on_enrollment_failed:
- text_sensor.template.publish:
id: fingerprint_state
state: "Failed to enroll fingerprint"
# Optional template text sensor for visual feedback
text_sensor:
- platform: template
id: fingerprint_state
name: "Fingerprint State"
# Optional component (GPIO switch, lock etc.) to control in on_finger_scan_matched trigger
switch:
- platform: gpio
pin: GPIO14
id: gate
# Optional sensors
binary_sensor:
- platform: fingerprint_grow
id: fingerprint_enrolling
name: "Fingerprint Enrolling"
sensor:
- platform: fingerprint_grow
fingerprint_count:
name: "Fingerprint Count"
last_finger_id:
name: "Fingerprint Last Finger ID"
last_confidence:
name: "Fingerprint Last Confidence"
status:
name: "Fingerprint Status"
capacity:
name: "Fingerprint Capacity"
security_level:
name: "Fingerprint Security Level"
Configuration variables:
------------------------
The configuration is made up of three parts: The central component, optional individual sensors, and the optional enrolling binary sensor.
Base Configuration:
- **uart_id** (*Optional*, :ref:`config-id`): Manually specify the ID of the UART hub.
- **id** (*Optional*, :ref:`config-id`): Manually specify the ID used for code generation.
- **sensing_pin** (*Optional*, :ref:`Pin Schema <config-pin_schema>`): Pin connected to the reader's finger detection signal (WAKEUP) output.
- **password** (*Optional*, int): Password to use for authentication. Defaults to ``0x00``.
- **set_password** (*Optional*, int): Sets a new password to use for authentication. See :ref:`fingerprint_grow-set_new_password` for more information.
- **on_finger_scan_matched** (*Optional*, :ref:`Automation <automation>`): An action to be performed when an enrolled fingerprint is scanned. See :ref:`fingerprint_grow-on_finger_scan_matched`.
- **on_finger_scan_unmatched** (*Optional*, :ref:`Automation <automation>`): An action to be performed when an unknown fingerprint is scanned. See :ref:`fingerprint_grow-on_finger_scan_unmatched`.
- **on_enrollment_scan** (*Optional*, :ref:`Automation <automation>`): An action to be performed when a fingerprint is scanned during enrollment. See :ref:`fingerprint_grow-on_enrollment_scan`.
- **on_enrollment_done** (*Optional*, :ref:`Automation <automation>`): An action to be performed when a fingerprint is enrolled. See :ref:`fingerprint_grow-on_enrollment_done`.
- **on_enrollment_failed** (*Optional*, :ref:`Automation <automation>`): An action to be performed when a fingerprint enrollment failed. See :ref:`fingerprint_grow-on_enrollment_failed`.
Optional Binary Sensor Configuration:
- **name** (**Required**, string): The name for the enrolling binary sensor.
- **id** (*Optional*, :ref:`config-id`): Manually specify the ID used for code generation.
- All other options from :ref:`Binary Sensor <config-binary_sensor>`.
Optional Sensor Configuration:
Available sensors:
- **fingerprint_count**: The number of enrolled fingerprints stored on the reader.
- **name** (**Required**, string): The name for the sensor.
- **id** (*Optional*, :ref:`config-id`): Manually specify the ID used for code generation.
- All other options from :ref:`Sensor <config-sensor>`.
- **last_finger_id**: The last matched enrolled fingerprint as set by :ref:`fingerprint_grow-on_finger_scan_matched`.
- **name** (**Required**, string): The name for the sensor.
- **id** (*Optional*, :ref:`config-id`): Manually specify the ID used for code generation.
- All other options from :ref:`Sensor <config-sensor>`.
- **last_confidence**: The last matched confidence as set by :ref:`fingerprint_grow-on_finger_scan_matched`.
- **name** (**Required**, string): The name for the sensor.
- **id** (*Optional*, :ref:`config-id`): Manually specify the ID used for code generation.
- All other options from :ref:`Sensor <config-sensor>`.
- **status**: The integer representation of the internal status register of the reader.
- **name** (**Required**, string): The name for the sensor.
- **id** (*Optional*, :ref:`config-id`): Manually specify the ID used for code generation.
- All other options from :ref:`Sensor <config-sensor>`.
- **capacity**: The fingerprint storage capacity of the reader.
- **name** (**Required**, string): The name for the sensor.
- **id** (*Optional*, :ref:`config-id`): Manually specify the ID used for code generation.
- All other options from :ref:`Sensor <config-sensor>`.
- **security_level**: The integer representation of the currently configured security level of the reader. Higher security levels reduce the false acceptance rate (FAR) at the expense of increasing the false rejection rate (FRR). Range is 1 (lowest) to 5 (highest).
- **name** (**Required**, string): The name for the sensor.
- **id** (*Optional*, :ref:`config-id`): Manually specify the ID used for code generation.
- All other options from :ref:`Sensor <config-sensor>`.
.. _fingerprint_grow-set_new_password:
Setting a New Password
----------------------
.. warning::
Forgetting the password will render your fingerprint reader unusable!
You can set a new password for your fingerprint reader using the ``set_password:`` configuration option. The password is defined as a 32-bit unsigned integer.
.. code-block:: yaml
fingerprint_grow:
password: 0x275FE3D2 # Existing password, can be omitted if it's the default of 0x00
set_password: 0x72AB96CD # New password
The ``set_password:`` configuration option is meant to be compiled, flashed to the ESP device and run once, after which it's removed and the new password is defined in the ``password:`` configuration option to be compiled and flashed again.
.. code-block:: yaml
fingerprint_grow:
password: 0x72AB96CD # Update the existing password with the new one
.. _fingerprint_grow-on_finger_scan_matched:
``on_finger_scan_matched`` Trigger
----------------------------------
With this configuration option you can write complex automations whenever a finger scan is matched to an enrolled fingerprint.
To use the variables, use a :ref:`lambda <config-lambda>` template, the matched slot number and the confidence are available inside that lambda under the variables named ``finger_id`` and ``confidence``.
.. code-block:: yaml
on_finger_scan_matched:
- text_sensor.template.publish:
id: fingerprint_state
state: !lambda 'return "Authorized finger " + to_string(finger_id) + ", confidence " + tostring(confidence);'
# Pushing a tag_scanned event based on finger_id only if confidence is greater than 50
- if:
condition:
lambda: 'return confidence > 50;'
then:
- homeassistant.tag_scanned: !lambda |-
switch (finger_id) {
case 0:
return "person_a";
case 1:
return "person_b";
...
default:
return "person_unknown";
}
.. _fingerprint_grow-on_finger_scan_unmatched:
``on_finger_scan_unmatched`` Trigger
------------------------------------
With this configuration option you can write complex automations whenever an unknown fingerprint is scanned.
.. code-block:: yaml
on_finger_scan_unmatched:
- text_sensor.template.publish:
id: fingerprint_state
state: "Unauthorized finger"
.. _fingerprint_grow-on_enrollment_scan:
``on_enrollment_scan`` Trigger
------------------------------
With this configuration option you can write complex automations whenever a finger is scanned during enrollment.
To use the variables, use a :ref:`lambda <config-lambda>` template, the scan number and the slot number to be enrolled into are available inside that lambda under the variables named ``scan_num`` and ``finger_id``.
.. code-block:: yaml
on_enrollment_scan:
- text_sensor.template.publish:
id: fingerprint_state
state: !lambda 'return "Enrolling into slot " + to_string(finger_id) + ", scanned " + to_string(scan_num) + " time(s)";'
.. _fingerprint_grow-on_enrollment_done:
``on_enrollment_done`` Trigger
------------------------------
With this configuration option you can write complex automations whenever a finger is successfully enrolled.
To use the variables, use a :ref:`lambda <config-lambda>` template, the slot number enrolled into is available inside that lambda under the variable named ``finger_id``.
.. code-block:: yaml
on_enrollment_done:
- text_sensor.template.publish:
id: fingerprint_state
state: !lambda 'return "Enrolled into slot " + to_string(finger_id);'
.. _fingerprint_grow-on_enrollment_failed:
``on_enrollment_failed`` Trigger
--------------------------------
With this configuration option you can write complex automations whenever a finger failed to be enrolled.
To use the variables, use a :ref:`lambda <config-lambda>` template, the slot number that failed to be enrolled into is available inside that lambda under the variable named ``finger_id``.
.. code-block:: yaml
on_enrollment_failed:
- text_sensor.template.publish:
id: fingerprint_state
state: !lambda 'return "Failed to enroll into slot " + to_string(finger_id);'
# Retry enrollment into the same slot
- delay: 3s
- text_sensor.template.publish:
id: fingerprint_state
state: !lambda 'return "Retrying enrollment into slot " + to_string(finger_id) + " in 3 seconds...";'
- delay: 3s
- fingerprint_grow.enroll: !lambda 'return finger_id;'
``fingerprint_grow.enroll`` Action
----------------------------------
Starts the fingerprint enrollment process on the slot number defined.
.. code-block:: yaml
on_...:
then:
- fingerprint_grow.enroll:
finger_id: 0
num_scans: 2
# Shorthand
- fingerprint_grow.enroll: 0
# Update the template text sensor for visual feedback
- text_sensor.template.publish:
id: fingerprint_state
state: "Place a finger on the reader"
Configuration options:
- **finger_id** (**Required**, int, :ref:`templatable <config-templatable>`): The slot number to enroll the new fingerprint into. Limited to the fingerprint capacity available on the reader.
- **num_scans** (*Optional*, int, :ref:`templatable <config-templatable>`): Number of times to scan the finger to be enrolled. Limited to the number of character buffers available on the reader. Defaults to 2.
``fingerprint_grow.cancel_enroll`` Action
-----------------------------------------
Cancels the current fingerprint enrollment process. Triggers the ``on_enrollment_failed`` trigger.
.. code-block:: yaml
on_...:
then:
- fingerprint_grow.cancel_enroll:
``fingerprint_grow.delete`` Action
----------------------------------
Removes the enrolled fingerprint from the slot number defined.
.. code-block:: yaml
on_...:
then:
- fingerprint_grow.delete:
finger_id: 0
# Shorthand
- fingerprint_grow.delete: 0
Configuration options:
- **finger_id** (**Required**, int, :ref:`templatable <config-templatable>`): The slot number of the enrolled fingerprint to delete.
``fingerprint_grow.delete_all`` Action
--------------------------------------
Removes all enrolled fingerprints.
.. code-block:: yaml
on_...:
then:
- fingerprint_grow.delete_all:
``fingerprint_grow.led_control`` Action
---------------------------------------
Turns on or off the LED on the reader. Only available on select models. If you have the R503 use :ref:`fingerprint_grow-aura_led_control` instead.
.. code-block:: yaml
on_...:
then:
- fingerprint_grow.led_control:
state: ON
# Shorthand
- fingerprint_grow.led_control: ON
Configuration options:
- **state** (**Required**, boolean, :ref:`templatable <config-templatable>`): The state to set the LED.
.. _fingerprint_grow-aura_led_control:
``fingerprint_grow.aura_led_control`` Action
--------------------------------------------
Controls the Aura LED on the reader. Only available on select models.
.. code-block:: yaml
on_...:
then:
- fingerprint_grow.aura_led_control:
state: BREATHING
speed: 100
color: BLUE
count: 2
# Sample Aura LED config for all reader triggers
fingerprint_grow:
on_finger_scan_matched:
- fingerprint_grow.aura_led_control:
state: BREATHING
speed: 200
color: BLUE
count: 1
on_finger_scan_unmatched:
- fingerprint_grow.aura_led_control:
state: FLASHING
speed: 25
color: RED
count: 2
on_enrollment_scan:
- fingerprint_grow.aura_led_control:
state: FLASHING
speed: 25
color: BLUE
count: 2
- fingerprint_grow.aura_led_control:
state: ALWAYS_ON
speed: 0
color: PURPLE
count: 0
on_enrollment_done:
- fingerprint_grow.aura_led_control:
state: BREATHING
speed: 100
color: BLUE
count: 2
on_enrollment_failed:
- fingerprint_grow.aura_led_control:
state: FLASHING
speed: 25
color: RED
count: 4
on...:
then:
- fingerprint_grow.enroll: ...
- fingerprint_grow.aura_led_control:
state: ALWAYS_ON
speed: 0
color: PURPLE
count: 0
Configuration options:
- **state** (**Required**, string, :ref:`templatable <config-templatable>`): The state to set the LED. One of ``BREATHING``, ``FLASHING``, ``ALWAYS_ON``, ``ALWAYS_OFF``, ``GRADUAL_ON`` and ``GRADUAL_OFF``.
- **speed** (**Required**, int, :ref:`templatable <config-templatable>`): The duration each cycle lasts, a factor of 10ms. Only relevant for ``BREATHING``, ``FLASHING``, ``GRADUAL_ON`` and ``GRADUAL_OFF`` states. The total duration is defined by 10ms * speed * count. Range is 0 to 255.
- **color** (**Required**, string, :ref:`templatable <config-templatable>`): The LED color to activate. One of ``RED``, ``BLUE`` and ``PURPLE``.
- **count** (**Required**, int, :ref:`templatable <config-templatable>`): How many times to repeat the pattern. Only relevant for ``BREATHING`` and ``FLASHING`` states. 0 for infinite, or 1 to 255.
All actions
-----------
- **id** (*Optional*, :ref:`config-id`): Manually specify the ID of the Grow fingerprint reader if you have multiple components.
Test setup
----------
With the following code you can quickly setup a node and use Home Assistant's service in the developer tools.
E.g. for calling ``fingerprint_grow.enroll`` select the service ``esphome.test_node_enroll`` and in service data enter
.. code-block:: json
{ "finger_id": 0, "num_scans": 2 }
Sample code
***********
.. code-block:: yaml
esphome:
name: test_node
platform: ESP8266
board: nodemcu
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_pass
logger:
uart:
rx_pin: GPIO13
tx_pin: GPIO15
baud_rate: 57600
fingerprint_grow:
sensing_pin: GPIO12
on_finger_scan_matched:
- homeassistant.event:
event: esphome.test_node_finger_scan_matched
data:
finger_id: !lambda 'return finger_id;'
confidence: !lambda 'return confidence;'
on_finger_scan_unmatched:
- homeassistant.event:
event: esphome.test_node_finger_scan_unmatched
on_enrollment_scan:
- homeassistant.event:
event: esphome.test_node_enrollment_scan
data:
finger_id: !lambda 'return finger_id;'
scan_num: !lambda 'return scan_num;'
on_enrollment_done:
- homeassistant.event:
event: esphome.test_node_enrollment_done
data:
finger_id: !lambda 'return finger_id;'
on_enrollment_failed:
- homeassistant.event:
event: esphome.test_node_enrollment_failed
data:
finger_id: !lambda 'return finger_id;'
api:
services:
- service: enroll
variables:
finger_id: int
num_scans: int
then:
- fingerprint_grow.enroll:
finger_id: !lambda 'return finger_id;'
num_scans: !lambda 'return num_scans;'
- service: cancel_enroll
then:
- fingerprint_grow.cancel_enroll:
- service: delete
variables:
finger_id: int
then:
- fingerprint_grow.delete:
finger_id: !lambda 'return finger_id;'
- service: delete_all
then:
- fingerprint_grow.delete_all:
See Also
--------
- :apiref:`fingerprint_grow/fingerprint_grow.h`
- `Tutorial from Adafruit <https://learn.adafruit.com/adafruit-optical-fingerprint-sensor>`__
- `Adafruit Fingerprint Sensor Library <https://github.com/adafruit/Adafruit-Fingerprint-Sensor-Library>`__ by `Adafruit <https://www.adafruit.com/>`__
- :ghedit:`Edit`

Binary file not shown.

After

Width:  |  Height:  |  Size: 141 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 223 KiB

1
images/fingerprint.svg Normal file
View File

@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24"><path d="M17.81,4.47C17.73,4.47 17.65,4.45 17.58,4.41C15.66,3.42 14,3 12,3C10.03,3 8.15,3.47 6.44,4.41C6.2,4.54 5.9,4.45 5.76,4.21C5.63,3.97 5.72,3.66 5.96,3.53C7.82,2.5 9.86,2 12,2C14.14,2 16,2.47 18.04,3.5C18.29,3.65 18.38,3.95 18.25,4.19C18.16,4.37 18,4.47 17.81,4.47M3.5,9.72C3.4,9.72 3.3,9.69 3.21,9.63C3,9.47 2.93,9.16 3.09,8.93C4.08,7.53 5.34,6.43 6.84,5.66C10,4.04 14,4.03 17.15,5.65C18.65,6.42 19.91,7.5 20.9,8.9C21.06,9.12 21,9.44 20.78,9.6C20.55,9.76 20.24,9.71 20.08,9.5C19.18,8.22 18.04,7.23 16.69,6.54C13.82,5.07 10.15,5.07 7.29,6.55C5.93,7.25 4.79,8.25 3.89,9.5C3.81,9.65 3.66,9.72 3.5,9.72M9.75,21.79C9.62,21.79 9.5,21.74 9.4,21.64C8.53,20.77 8.06,20.21 7.39,19C6.7,17.77 6.34,16.27 6.34,14.66C6.34,11.69 8.88,9.27 12,9.27C15.12,9.27 17.66,11.69 17.66,14.66A0.5,0.5 0 0,1 17.16,15.16A0.5,0.5 0 0,1 16.66,14.66C16.66,12.24 14.57,10.27 12,10.27C9.43,10.27 7.34,12.24 7.34,14.66C7.34,16.1 7.66,17.43 8.27,18.5C8.91,19.66 9.35,20.15 10.12,20.93C10.31,21.13 10.31,21.44 10.12,21.64C10,21.74 9.88,21.79 9.75,21.79M16.92,19.94C15.73,19.94 14.68,19.64 13.82,19.05C12.33,18.04 11.44,16.4 11.44,14.66A0.5,0.5 0 0,1 11.94,14.16A0.5,0.5 0 0,1 12.44,14.66C12.44,16.07 13.16,17.4 14.38,18.22C15.09,18.7 15.92,18.93 16.92,18.93C17.16,18.93 17.56,18.9 17.96,18.83C18.23,18.78 18.5,18.96 18.54,19.24C18.59,19.5 18.41,19.77 18.13,19.82C17.56,19.93 17.06,19.94 16.92,19.94M14.91,22C14.87,22 14.82,22 14.78,22C13.19,21.54 12.15,20.95 11.06,19.88C9.66,18.5 8.89,16.64 8.89,14.66C8.89,13.04 10.27,11.72 11.97,11.72C13.67,11.72 15.05,13.04 15.05,14.66C15.05,15.73 16,16.6 17.13,16.6C18.28,16.6 19.21,15.73 19.21,14.66C19.21,10.89 15.96,7.83 11.96,7.83C9.12,7.83 6.5,9.41 5.35,11.86C4.96,12.67 4.76,13.62 4.76,14.66C4.76,15.44 4.83,16.67 5.43,18.27C5.53,18.53 5.4,18.82 5.14,18.91C4.88,19 4.59,18.87 4.5,18.62C4,17.31 3.77,16 3.77,14.66C3.77,13.46 4,12.37 4.45,11.42C5.78,8.63 8.73,6.82 11.96,6.82C16.5,6.82 20.21,10.33 20.21,14.65C20.21,16.27 18.83,17.59 17.13,17.59C15.43,17.59 14.05,16.27 14.05,14.65C14.05,13.58 13.12,12.71 11.97,12.71C10.82,12.71 9.89,13.58 9.89,14.65C9.89,16.36 10.55,17.96 11.76,19.16C12.71,20.1 13.62,20.62 15.03,21C15.3,21.08 15.45,21.36 15.38,21.62C15.33,21.85 15.12,22 14.91,22Z"/></svg>

After

Width:  |  Height:  |  Size: 2.2 KiB

View File

@ -382,6 +382,7 @@ Misc Components
Exposure Notifications, components/exposure_notifications, exposure_notifications.png
RTTTL Buzzer, components/rtttl, buzzer.jpg
Prometheus, components/prometheus, prometheus.svg
Grow Fingerprint Reader, components/fingerprint_grow, fingerprint.svg
Additional Custom Components
----------------------------