2018-05-13 11:37:02 +02:00
|
|
|
|
Configuration Types
|
|
|
|
|
===================
|
|
|
|
|
|
2018-11-14 22:12:27 +01:00
|
|
|
|
.. seo::
|
2019-02-16 23:25:23 +01:00
|
|
|
|
:description: Documentation of different configuration types in ESPHome
|
2021-11-16 03:19:33 +01:00
|
|
|
|
:image: settings.svg
|
2018-11-14 22:12:27 +01:00
|
|
|
|
|
2019-02-16 23:25:23 +01:00
|
|
|
|
ESPHome’s configuration files have several configuration types. This
|
2018-05-13 11:37:02 +02:00
|
|
|
|
page describes them.
|
|
|
|
|
|
2018-06-01 18:10:00 +02:00
|
|
|
|
.. _config-id:
|
|
|
|
|
|
2018-05-13 11:37:02 +02:00
|
|
|
|
ID
|
2018-10-12 16:33:22 +02:00
|
|
|
|
--
|
2018-05-13 11:37:02 +02:00
|
|
|
|
|
2021-05-03 13:10:47 +02:00
|
|
|
|
Quite an important aspect of ESPHome are “IDs”. They are used to
|
2018-05-13 11:37:02 +02:00
|
|
|
|
connect components from different domains. For example, you define an
|
2021-05-03 13:10:47 +02:00
|
|
|
|
output component together with an ID and then later specify that same ID
|
2018-05-13 11:37:02 +02:00
|
|
|
|
in the light component. IDs should always be unique within a
|
2019-02-16 23:25:23 +01:00
|
|
|
|
configuration and ESPHome will warn you if you try to use the same
|
2018-05-13 11:37:02 +02:00
|
|
|
|
ID twice.
|
|
|
|
|
|
2019-02-16 23:25:23 +01:00
|
|
|
|
Because ESPHome converts your configuration into C++ code and the
|
2021-05-03 13:10:47 +02:00
|
|
|
|
IDs are in reality just C++ variable names, they must also adhere to
|
2018-05-13 11:37:02 +02:00
|
|
|
|
C++’s naming conventions. `C++ Variable
|
2018-11-19 18:32:16 +01:00
|
|
|
|
names <https://venus.cs.qc.cuny.edu/~krishna/cs111/lectures/D3_C++_Variables.pdf>`__
|
2018-05-13 11:37:02 +02:00
|
|
|
|
…
|
|
|
|
|
|
|
|
|
|
- … must start with a letter and can end with numbers.
|
|
|
|
|
- … must not have a space in the name.
|
|
|
|
|
- … can not have special characters except the underscore (“_“).
|
|
|
|
|
- … must not be a keyword.
|
|
|
|
|
|
2023-01-13 10:03:13 +01:00
|
|
|
|
|
|
|
|
|
.. note::
|
|
|
|
|
|
2024-05-07 07:40:12 +02:00
|
|
|
|
These IDs are used only within ESPHome and are not translated to Home Assistant's Entity ID.
|
2023-01-13 10:03:13 +01:00
|
|
|
|
|
|
|
|
|
|
2018-06-01 18:10:00 +02:00
|
|
|
|
.. _config-pin:
|
|
|
|
|
|
2018-05-13 11:37:02 +02:00
|
|
|
|
Pin
|
2018-10-12 16:33:22 +02:00
|
|
|
|
---
|
2018-05-13 11:37:02 +02:00
|
|
|
|
|
2019-02-16 23:25:23 +01:00
|
|
|
|
ESPHome always uses the **chip-internal GPIO numbers**. These
|
2018-05-13 11:37:02 +02:00
|
|
|
|
internal numbers are always integers like ``16`` and can be prefixed by
|
|
|
|
|
``GPIO``. For example to use the pin with the **internal** GPIO number 16,
|
|
|
|
|
you could type ``GPIO16`` or just ``16``.
|
|
|
|
|
|
|
|
|
|
Most boards however have aliases for certain pins. For example the NodeMCU
|
|
|
|
|
ESP8266 uses pin names ``D0`` through ``D8`` as aliases for the internal GPIO
|
2019-02-16 23:25:23 +01:00
|
|
|
|
pin numbers. Each board (defined in :doc:`ESPHome section </components/esphome>`)
|
2018-05-13 11:37:02 +02:00
|
|
|
|
has their own aliases and so not all of them are supported yet. For example,
|
|
|
|
|
for the ``D0`` (as printed on the PCB silkscreen) pin on the NodeMCU ESP8266
|
|
|
|
|
has the internal GPIO name ``GPIO16``, but also has an alias ``D0``. So using
|
|
|
|
|
either one of these names in your configuration will lead to the same result.
|
|
|
|
|
|
2018-11-19 18:32:16 +01:00
|
|
|
|
.. code-block:: yaml
|
2018-05-13 11:37:02 +02:00
|
|
|
|
|
|
|
|
|
some_config_option:
|
|
|
|
|
pin: GPIO16
|
|
|
|
|
|
|
|
|
|
some_config_option:
|
|
|
|
|
# alias on the NodeMCU ESP8266:
|
|
|
|
|
pin: D0
|
|
|
|
|
|
2018-06-01 18:10:00 +02:00
|
|
|
|
.. _config-pin_schema:
|
|
|
|
|
|
2018-05-13 11:37:02 +02:00
|
|
|
|
Pin Schema
|
2018-10-12 16:33:22 +02:00
|
|
|
|
----------
|
2018-05-13 11:37:02 +02:00
|
|
|
|
|
2019-02-16 23:25:23 +01:00
|
|
|
|
In some places, ESPHome also supports a more advanced “pin schema”.
|
2018-05-13 11:37:02 +02:00
|
|
|
|
|
2018-11-19 18:32:16 +01:00
|
|
|
|
.. code-block:: yaml
|
2018-05-13 11:37:02 +02:00
|
|
|
|
|
|
|
|
|
some_config_option:
|
|
|
|
|
# Basic:
|
2024-05-07 07:40:12 +02:00
|
|
|
|
pin: GPIOXX
|
2018-05-13 11:37:02 +02:00
|
|
|
|
|
|
|
|
|
# Advanced:
|
|
|
|
|
pin:
|
2024-05-07 07:40:12 +02:00
|
|
|
|
number: GPIOXX
|
2021-07-28 23:56:11 +02:00
|
|
|
|
inverted: true
|
2021-10-19 21:53:24 +02:00
|
|
|
|
mode:
|
|
|
|
|
input: true
|
|
|
|
|
pullup: true
|
2018-05-13 11:37:02 +02:00
|
|
|
|
|
|
|
|
|
Configuration variables:
|
|
|
|
|
|
|
|
|
|
- **number** (**Required**, pin): The pin number.
|
|
|
|
|
- **inverted** (*Optional*, boolean): If all read and written values
|
2021-07-28 23:56:11 +02:00
|
|
|
|
should be treated as inverted. Defaults to ``false``.
|
2023-12-05 00:56:57 +01:00
|
|
|
|
- **allow_other_uses** (*Optional*, boolean): If the pin is also specified elsewhere in the configuration.
|
|
|
|
|
By default multiple uses of the same pin will be flagged as an error. This option will suppress the error and is
|
|
|
|
|
intended for rare cases where a pin is shared between multiple components. Defaults to ``false``.
|
|
|
|
|
|
2021-10-19 21:53:24 +02:00
|
|
|
|
- **mode** (*Optional*, string or mapping): Configures the pin to behave in different
|
|
|
|
|
modes like input or output. The default value depends on the context.
|
2022-02-10 23:10:43 +01:00
|
|
|
|
Accepts either a shorthand string or a mapping where each feature can be individually
|
2021-10-19 21:53:24 +02:00
|
|
|
|
enabled/disabled:
|
|
|
|
|
|
|
|
|
|
- **input** (*Optional*, boolean): If true, configure the pin as an input.
|
|
|
|
|
- **output** (*Optional*, boolean): If true, configure the pin as an output.
|
|
|
|
|
- **pullup** (*Optional*, boolean): Activate internal pullup resistors on the pin.
|
|
|
|
|
- **pulldown** (*Optional*, boolean): Activate internal pulldown resistors on the pin.
|
|
|
|
|
- **open_drain** (*Optional*, boolean): Set the pin to open-drain (as opposed to push-pull).
|
|
|
|
|
The active pin state will then result in a high-impedance state.
|
|
|
|
|
|
|
|
|
|
For compatibility some shorthand modes can also be used.
|
|
|
|
|
|
|
|
|
|
- ``INPUT``
|
|
|
|
|
- ``OUTPUT``
|
|
|
|
|
- ``OUTPUT_OPEN_DRAIN``
|
|
|
|
|
- ``ANALOG``
|
|
|
|
|
- ``INPUT_PULLUP``
|
|
|
|
|
- ``INPUT_PULLDOWN``
|
2023-02-07 00:55:38 +01:00
|
|
|
|
- ``INPUT_OUTPUT_OPEN_DRAIN``
|
2021-10-19 21:53:24 +02:00
|
|
|
|
|
|
|
|
|
Advanced options:
|
|
|
|
|
|
|
|
|
|
- **drive_strength** (*Optional*, string): On ESP32s with esp-idf framework the pad drive strength,
|
|
|
|
|
i.e. the maximum amount of current can additionally be set. Defaults to ``20mA``.
|
|
|
|
|
Options are ``5mA``, ``10mA``, ``20mA``, ``40mA``.
|
2023-10-19 02:04:56 +02:00
|
|
|
|
- **ignore_strapping_warning** (*Optional*, boolean): Certain pins on ESP32s are designated *strapping pins* and are read
|
|
|
|
|
by the chip on reset to configure initial operation, e.g. to enable bootstrap mode.
|
|
|
|
|
Using such pins for I/O should be avoided and ESPHome will warn if I/O is configured on a strapping pin.
|
|
|
|
|
|
|
|
|
|
For more detail see :ref:`strapping-warnings`.
|
|
|
|
|
|
|
|
|
|
If you are *absolutely* sure that you are using a strapping pin for I/O in a way that will not cause problems,
|
|
|
|
|
you can suppress the warning by setting this option to ``true`` in the pin configuration.
|
2020-06-28 23:37:55 +02:00
|
|
|
|
|
2018-06-01 18:10:00 +02:00
|
|
|
|
.. _config-time:
|
|
|
|
|
|
2018-05-13 11:37:02 +02:00
|
|
|
|
Time
|
2018-10-12 16:33:22 +02:00
|
|
|
|
----
|
2018-05-13 11:37:02 +02:00
|
|
|
|
|
2019-02-16 23:25:23 +01:00
|
|
|
|
In lots of places in ESPHome you need to define time periods.
|
2018-05-14 21:15:49 +02:00
|
|
|
|
There are several ways of doing this. See below examples to see how you can specify time periods:
|
2018-05-13 11:37:02 +02:00
|
|
|
|
|
2018-11-19 18:32:16 +01:00
|
|
|
|
.. code-block:: yaml
|
2018-05-13 11:37:02 +02:00
|
|
|
|
|
|
|
|
|
some_config_option:
|
2018-05-14 21:15:49 +02:00
|
|
|
|
some_time_option: 1000us # 1000 microseconds = 1ms
|
2018-05-13 11:37:02 +02:00
|
|
|
|
some_time_option: 1000ms # 1000 milliseconds
|
|
|
|
|
some_time_option: 1.5s # 1.5 seconds
|
|
|
|
|
some_time_option: 0.5min # half a minute
|
|
|
|
|
some_time_option: 2h # 2 hours
|
2018-06-07 23:12:51 +02:00
|
|
|
|
|
|
|
|
|
# Make sure you wrap these in quotes
|
|
|
|
|
some_time_option: '2:01' # 2 hours 1 minute
|
|
|
|
|
some_time_option: '2:01:30' # 2 hours 1 minute 30 seconds
|
|
|
|
|
|
2018-05-14 21:15:49 +02:00
|
|
|
|
# 10ms + 30s + 25min + 3h
|
|
|
|
|
some_time_option:
|
2018-05-13 11:37:02 +02:00
|
|
|
|
milliseconds: 10
|
|
|
|
|
seconds: 30
|
|
|
|
|
minutes: 25
|
|
|
|
|
hours: 3
|
|
|
|
|
days: 0
|
2018-06-01 18:10:00 +02:00
|
|
|
|
|
2018-08-24 22:44:01 +02:00
|
|
|
|
# for all 'update_interval' options, also
|
|
|
|
|
update_interval: never # never update
|
|
|
|
|
update_interval: 0ms # update in every loop() iteration
|
|
|
|
|
|
2018-06-01 18:10:00 +02:00
|
|
|
|
See Also
|
2018-10-12 16:33:22 +02:00
|
|
|
|
--------
|
2018-06-01 18:10:00 +02:00
|
|
|
|
|
2019-02-07 13:54:45 +01:00
|
|
|
|
- :doc:`ESPHome index </index>`
|
2018-06-01 18:10:00 +02:00
|
|
|
|
- :doc:`getting_started_command_line`
|
|
|
|
|
- :doc:`faq`
|
2019-02-07 13:54:45 +01:00
|
|
|
|
- :ghedit:`Edit`
|