Passing attribute and call service - Fingerprint R503

Hi everyone
I configured my GROW R503 sensor with esphome:

uart:
  rx_pin: GPIO13
  tx_pin: GPIO14
  baud_rate: 57600

fingerprint_grow:
  sensing_pin: GPIO12
  on_finger_scan_matched:
    - text_sensor.template.publish:
        id: fingerprint_state
        state: "Impronta autorizzata"
    - delay: 3000ms
    - lambda: |-
        if (finger_id == 0) {
          id(fingerprint_username).publish_state("Fred");
        } else if (finger_id == 1) {
          id(fingerprint_username).publish_state("Gianni");
        } else {
          id(fingerprint_username).publish_state("Unknown");
        };
    - text_sensor.template.publish:
        id: fingerprint_state
        state: "Attesa"
    - fingerprint_grow.aura_led_control:
        state: BREATHING
        speed: 200
        color: BLUE
        count: 1
  on_finger_scan_unmatched:
    - text_sensor.template.publish:
        id: fingerprint_state
        state: "Impronta non autorizzata"
    - fingerprint_grow.aura_led_control:
        state: FLASHING
        speed: 25
        color: RED
        count: 2
  on_enrollment_scan:
    - text_sensor.template.publish:
        id: fingerprint_state
        state: "Impronta acquisita"
    - text_sensor.template.publish:
        id: fingerprint_state
        state: "Impronta acquisita"
    - 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_failed:
    - text_sensor.template.publish:
        id: fingerprint_state
        state: "Acquisizione impronta fallita"
    - fingerprint_grow.aura_led_control:
        state: FLASHING
        speed: 25
        color: RED
        count: 4

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:

# Optional template text sensor for visual feedback
text_sensor:
  - platform: template
    id: fingerprint_state
    name: "Stato impronta"

  - platform: template
    id:       fingerprint_username
    name:     "Ultima scansione"
    update_interval: 30s

# Optional sensors
binary_sensor:
  - platform: fingerprint_grow
    id: fingerprint_enrolling
    name: "Acquisendo impronta"

sensor:
  - platform: fingerprint_grow
    fingerprint_count:
      name: "Conta impronte"
    last_finger_id:
      name: "Ultimo ID impronta"
    last_confidence:
      name: "AffidabilitĂ  ultima impronta"
    status:
      name: "Stato impronta"
    capacity:
      name: "CapacitĂ  impronta"
    security_level:
      name: "Livello di sicurezza"

i want pass to service call esphome.esphome_fingerprint_ingresso_enroll, finger_id the value of input_number_id_impronta for adding a new fingerprint.

I write the value

image

this is lovelace card

show_name: true
show_icon: true
type: button
tap_action:
  action: call-service
  service: esphome.esphome_fingerprint_ingresso_enroll
  target: {}
  data:
    finger_id: '{{ states(''input_number.id_impronta'') }}'
    num_scans: 2
name: Registra Impronta
icon: mdi:fingerprint
icon_height: 50px

help please…
Thank you :slight_smile:

1 Like

This thread has the best info on the R503.

1 Like

There is a simple solution in the code to enroll another fingerprint mentioned by nickrout. Just add this to the services in the api section:

  - service: enroll_next # Idea by Ralf KlĂĽber (thanks!)
    variables:
      num_scans: int
      count_plus: int
    then:
      - fingerprint_grow.enroll:
          finger_id: !lambda 'return count_plus + id(fingerprint_count).state;'
          num_scans: !lambda 'return num_scans;'

I just made some progress on adding your original question, but will post this seperately, once I am done.

Your approach seems fine,.e.g. the same i am summarizing below.

But i think you have to format the input as integer.
finger_id: "{{states('input_number.fingerprint_modification_id') | int}}"
At least thats the only notable difference i see. For me it is working.

The problem can be solved as follows.

  1. Create a number Helper in devices, helper. Call


    This you add to the frontend as part of a dashboard card to enter the number.

  2. Create a script for every button you want

alias: Fingerprint Learning 30s
sequence:
  - action: esphome.fingergarage_enroll
    metadata: {}
    data:
      finger_id: "{{states('input_number.fingerprint_modification_id') | int}}"
      num_scans: 2
  - delay:
      hours: 0
      minutes: 1
      seconds: 0
      milliseconds: 0
  - action: esphome.fingergarage_cancel_enroll
    metadata: {}
    data: {}
description: ""
icon: mdi:fingerprint

Certainly you skip the timer and the cancellation if not wanted.

  1. Now add the button to your card as well.
1 Like