Hello there,
I have wiegand keyboard (https://www.aliexpress.com/item/4001029318011.html?spm=a2g0o.order_list.order_list_main.37.678d18022gJSNh) connected to ESPHome device via D1 and D0 wire.
It works fine with RFID tag, but when I added key_collector component, it doesn’t log or record anything. Would you be that kind and inspect my code?
esphome:
name: wiegand
friendly_name: Wiegand
esp8266:
board: esp01_1m
# Enable logging
logger:
# Enable Home Assistant API
api:
encryption:
key: "KulEen35yoDHxoJg+ihxnXrI4dNZV48FAROrMNHstD4="
ota:
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "Wiegand Fallback Hotspot"
password: "WBOBt908OlCO"
captive_portal:
wiegand:
- id: frontdoor
d0: GPIO4
d1: GPIO5
on_key:
- lambda: ESP_LOGI("KEY", "received key %d", x);
on_tag:
- lambda: ESP_LOGI("TAG", "received tag %s", x.c_str());
- homeassistant.tag_scanned: !lambda 'return x.c_str();'
on_raw:
- lambda: ESP_LOGI("RAW", "received raw %d bits, value %llx", bits, value);
key_collector:
- id: pincode_reader
source_id: frontdoor
min_length: 4
max_length: 4
end_keys: "#"
end_key_required: false
back_keys: "*"
clear_keys: "C"
# allowed_keys: "0123456789"
timeout: 5s
on_progress:
- logger.log:
format: "input progress: '%s', started by '%c'"
args: [ 'x.c_str()', "(start == 0 ? '~' : start)" ]
on_result:
- logger.log:
format: "input result: '%s', started by '%c', ended by '%c'"
args: [ 'x.c_str()', "(start == 0 ? '~' : start)", "(end == 0 ? '~' : end)" ]
- if:
condition:
lambda: |-
return x=="6911";
then:
homeassistant.tag_scanned: 'RFID 1'
- if:
condition:
lambda: |-
return x=="6922";
then:
homeassistant.tag_scanned: 'RFID 1'
on_timeout:
- logger.log:
format: "input timeout: '%s', started by '%c'"
args: [ 'x.c_str()', "(start == 0 ? '~' : start)" ]
Thank you kindly!