Skip to content

Instantly share code, notes, and snippets.

@esbenr
Created April 15, 2021 12:55
Show Gist options
  • Save esbenr/edd10ef49d51236c66fbae9727e34b1b to your computer and use it in GitHub Desktop.
Save esbenr/edd10ef49d51236c66fbae9727e34b1b to your computer and use it in GitHub Desktop.
ESP32 connected keypad in ESPHome adding single digit and code sensor to HA
esphome:
name: keypad01
platform: ESP32
board: esp32dev
includes:
- keypad_textsensor.h
- keypad_sensor.h
libraries:
- "Keypad"
wifi:
ssid: "[Your SSID]"
password: "[Your WIFI password]"
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "Keypad01 Fallback Hotspot"
password: "elXNfB19fgJw"
captive_portal:
# Enable logging
logger:
# Enable Home Assistant API
api:
ota:
text_sensor:
- platform: custom
lambda: |-
auto my_sensor = new KeypadTextSensor();
App.register_component(my_sensor);
return {my_sensor};
text_sensors:
name: "Keypad01 Code sensor"
sensor:
- platform: custom
lambda: |-
auto my_sensor = new KeypadSensor();
App.register_component(my_sensor);
return {my_sensor};
sensors:
name: "Keypad01 Key sensor"
@esbenr
Copy link
Author

esbenr commented Apr 15, 2021

The keypad is connected to the ESP32 using the pins as per the code.
Then this configuration is compiled and loaded into the ESP32.
When the ESP32 is running it connects to ESPHome and appears as two sensors in HA.
One sensor that update with the value on each key pressed and another sensor that update it's value when you press # (i believe), with all keys pressed.

See video in danish here: https://www.facebook.com/esbenrr/videos/10158740941943209
Video coming up on YouTube later: https://www.youtube.com/channel/UCbPhGaepiG7M858RctCgQuQ

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment