2023-01-17 05:18:42 +01:00
|
|
|
.. _matrix_keypad:
|
|
|
|
|
2023-01-10 04:07:17 +01:00
|
|
|
Matrix keypad
|
|
|
|
=============
|
|
|
|
|
|
|
|
.. seo::
|
|
|
|
:description: Matrix key input panel
|
|
|
|
|
|
|
|
The ``matrix_keypad`` component allows you to integrate pads which
|
2023-05-31 15:31:55 +02:00
|
|
|
have the keys connected at the intersection points of the rows and columns
|
|
|
|
of a matrix.
|
2023-01-10 04:07:17 +01:00
|
|
|
|
|
|
|
.. figure:: ../images/matrix_keypad.jpg
|
|
|
|
:align: center
|
|
|
|
|
|
|
|
|
|
|
|
Component
|
|
|
|
---------
|
|
|
|
|
|
|
|
.. code-block:: yaml
|
|
|
|
|
|
|
|
# Example configuration entry
|
|
|
|
matrix_keypad:
|
|
|
|
id: mykeypad
|
|
|
|
rows:
|
2024-05-07 07:40:12 +02:00
|
|
|
- pin: GPIOXX
|
|
|
|
- pin: GPIOXX
|
|
|
|
- pin: GPIOXX
|
|
|
|
- pin: GPIOXX
|
2023-01-10 04:07:17 +01:00
|
|
|
columns:
|
2024-05-07 07:40:12 +02:00
|
|
|
- pin: GPIOXX
|
|
|
|
- pin: GPIOXX
|
|
|
|
- pin: GPIOXX
|
|
|
|
- pin: GPIOXX
|
2023-01-10 04:07:17 +01:00
|
|
|
keys: "123A456B789C*0#D"
|
|
|
|
has_diodes: false
|
|
|
|
|
|
|
|
|
|
|
|
Configuration variables:
|
|
|
|
|
|
|
|
- **id** (*Optional*, :ref:`config-id`): Set the ID of this device for use in lambdas.
|
|
|
|
- **rows** (**Required**, list): A list of :ref:`pins <config-pin_schema>` where the horrizontal
|
2023-02-22 21:43:07 +01:00
|
|
|
matrix lines are connected, in order from top to bottom. These pins need to be output capable.
|
2023-01-10 04:07:17 +01:00
|
|
|
- **columns** (**Required**, list): A list of :ref:`pins <config-pin_schema>` where the vertical
|
2023-02-22 21:43:07 +01:00
|
|
|
matrix lines are connected, in order from left to right. These pins need to be input capable
|
|
|
|
with pullups enabled. If there is no internal pullup, then an external one is required.
|
2023-05-31 15:31:55 +02:00
|
|
|
- **keys** (*Optional*, string): The keys present on the matrix, from top left to bottom right,
|
2023-01-10 04:07:17 +01:00
|
|
|
row by row. Required for ``key_collector`` and ``binary_sensor`` (if using key selection).
|
2023-05-31 15:31:55 +02:00
|
|
|
- **has_diodes** (*Optional*, boolean): For pads where row pins are outputs, and the keys are
|
2023-01-10 04:07:17 +01:00
|
|
|
connected with diodes. Defaults to ``false``.
|
2023-09-21 00:26:38 +02:00
|
|
|
- **has_pulldowns** (*Optional*, boolean): For pads where the column lines have external pulldowns. Defaults to ``false``.
|
2023-01-10 04:07:17 +01:00
|
|
|
|
|
|
|
|
2023-05-31 15:31:55 +02:00
|
|
|
Binary Sensor
|
|
|
|
-------------
|
2023-01-10 04:07:17 +01:00
|
|
|
|
|
|
|
Individual keys can be added independently to ESPHome as ``binary_sensor``:
|
|
|
|
|
|
|
|
.. code-block:: yaml
|
|
|
|
|
|
|
|
# Example configuration entry
|
|
|
|
binary_sensor:
|
|
|
|
- platform: matrix_keypad
|
|
|
|
keypad_id: mykeypad
|
|
|
|
id: key4
|
|
|
|
row: 1
|
|
|
|
col: 0
|
2023-03-10 19:27:07 +01:00
|
|
|
- platform: matrix_keypad
|
2023-01-10 04:07:17 +01:00
|
|
|
id: keyA
|
|
|
|
key: A
|
|
|
|
|
|
|
|
Configuration variables:
|
|
|
|
|
|
|
|
- **keypad_id** (*Optional*, :ref:`config-id`): The ID of the keypad to process keypresses from.
|
|
|
|
- **id** (*Optional*, :ref:`config-id`): Set the ID of this key for use in lambdas.
|
|
|
|
- **row** (*Optional*, integer): The row of the key.
|
|
|
|
- **col** (*Optional*, integer): The column of the key.
|
|
|
|
- **key** (*Optional*, string): The key from ``keys`` configuration entry above.
|
|
|
|
- All other options from :ref:`Binary Sensor <config-binary_sensor>`.
|
|
|
|
|
|
|
|
Either the ``row`` and ``col`` parameters, or the ``key`` parameter has to be provided.
|
|
|
|
|
|
|
|
|
|
|
|
.. note::
|
|
|
|
|
2023-05-31 15:31:55 +02:00
|
|
|
Automatic handling of multiple keys (e.g. PIN code entry) is possible with the
|
2023-01-17 05:18:42 +01:00
|
|
|
the :ref:`Key Collector <key_collector>` component.
|
2023-01-10 04:07:17 +01:00
|
|
|
|
|
|
|
See Also
|
|
|
|
--------
|
|
|
|
|
2023-01-17 05:18:42 +01:00
|
|
|
- :doc:`/components/key_collector`
|
2023-01-10 04:07:17 +01:00
|
|
|
- :ref:`Binary Sensor <config-binary_sensor>`
|
|
|
|
- :ghedit:`Edit`
|