Created
March 9, 2023 18:22
-
-
Save ProtoxiDe22/ba02a522a40d0d9c9b006e3c48ec88e3 to your computer and use it in GitHub Desktop.
EspHome Template to use a numeric wiegand keypad for arbitrary automations in homeassistant, in the automation, just use the binary sensor as trigger and use a template to check the text sensor against a text variable in HA
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
esphome: | |
name: wiegand-keypad | |
friendly_name: wiegand keypad | |
#platform and board can be changed to anything else you want | |
esp32: | |
board: esp32dev | |
framework: | |
type: arduino | |
# Enable logging | |
logger: | |
# Enable Home Assistant API | |
api: | |
encryption: | |
key: "<CHANGEME>" | |
ota: | |
password: "<CHANGEME>" | |
wifi: | |
ssid: !secret wifi_ssid | |
password: !secret wifi_password | |
# Enable fallback hotspot (captive portal) in case wifi connection fails | |
ap: | |
ssid: "Weigand-Keypad Fallback Hotspot" | |
password: "<CHANGEME>" | |
captive_portal: | |
wiegand: | |
- id: keypad | |
#you can change the d1 and d0 pins as you like, htis could be mandatory if you change the board | |
d0: GPIO5 | |
d1: GPIO4 | |
on_key: | |
- lambda: ESP_LOGI("KEY", "received key %d", x); | |
on_tag: | |
- lambda: ESP_LOGI("TAG", "received tag %s", x.c_str()); | |
on_raw: | |
- lambda: ESP_LOGI("RAW", "received raw %d bits, value %llx", bits, value); | |
key_collector: | |
- id: pincode_reader | |
source_id: keypad | |
#length can be changed if needed | |
min_length: 5 | |
max_length: 5 | |
#end key can be changed if needed | |
end_keys: "#" | |
end_key_required: true | |
allowed_keys: "0123456789" | |
#timeout ccan be changed if needed | |
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)" ] | |
- lambda: id(keycode).publish_state(x.c_str()); | |
- lambda: id(coderec).publish_state(true); | |
- delay: 200ms | |
- lambda: id(coderec).publish_state(false); | |
on_timeout: | |
- logger.log: | |
format: "input timeout: '%s', started by '%c'" | |
args: [ 'x.c_str()', "(start == 0 ? '~' : start)" ] | |
text_sensor: | |
- platform: template | |
name: keycode | |
id: keycode | |
binary_sensor: | |
- platform: template | |
name: code received | |
id: coderec | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment