Extracted this keypad from a landline phone, found a schematic and wired it to an ESP8266. These are DTMF matrix keypads and they are usually wired like this
Example ESPhome YAML using as alarm keypad, seems to work well. still need to figure out waking up from deep sleep for battery-powered applications.
matrix_keypad:
id: mykeypad
rows:
- pin: D1 #row 1
- pin: D6 #row 2
- pin: D5 #row 3
- pin: D3 #row 4
columns:
- pin: D2 #col 1
- pin: D0 #col 2
- pin: D4 #col 3
#keys: "56890#"
keys: "123456789*0#"
has_diodes: false
on_key:
- lambda: ESP_LOGI("KEY", "key %d pressed", x);
key_collector:
- id: pincode_reader
source_id: mykeypad
min_length: 4
max_length: 4
end_keys: "#"
end_key_required: true
back_keys: "*"
clear_keys: "C"
allowed_keys: "0123456789"
timeout: 5s
on_progress:
- if:
condition:
lambda: 'return x == "0";'
then:
- homeassistant.service:
service: alarmo.arm
data:
entity_id: alarm_control_panel.alarmo
force: 'true'
on_result:
- logger.log:
format: "input result: '%s', started by '%c', ended by '%c'"
args: [ 'x.c_str()', "(start == 0 ? '~' : start)", "(end == 0 ? '~' : end)" ]
- homeassistant.action:
action: alarmo.disarm
data:
entity_id: alarm_control_panel.alarmo
code: !lambda 'return x.c_str();'