2018-05-13 11:37:02 +02:00
|
|
|
|
Configuration Types
|
|
|
|
|
===================
|
|
|
|
|
|
|
|
|
|
esphomeyaml’s configuration files have several configuration types. This
|
|
|
|
|
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
|
|
|
|
|
|
|
|
|
Quite an important aspect of esphomeyaml are “ids”. They are used to
|
|
|
|
|
connect components from different domains. For example, you define an
|
|
|
|
|
output component together with an id and then later specify that same id
|
|
|
|
|
in the light component. IDs should always be unique within a
|
|
|
|
|
configuration and esphomeyaml will warn you if you try to use the same
|
|
|
|
|
ID twice.
|
|
|
|
|
|
|
|
|
|
Because esphomeyaml converts your configuration into C++ code and the
|
|
|
|
|
ids are in reality just C++ variable names, they must also adhere to
|
|
|
|
|
C++’s naming conventions. `C++ Variable
|
|
|
|
|
names <http://venus.cs.qc.cuny.edu/~krishna/cs111/lectures/D3_C++_Variables.pdf>`__
|
|
|
|
|
…
|
|
|
|
|
|
|
|
|
|
- … 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.
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
|
esphomeyaml always uses the **chip-internal GPIO numbers**. These
|
|
|
|
|
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
|
2018-06-01 18:10:00 +02:00
|
|
|
|
pin numbers. Each board (defined in :doc:`esphomeyaml section </esphomeyaml/components/esphomeyaml>`)
|
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.
|
|
|
|
|
|
|
|
|
|
.. code:: yaml
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
|
In some places, esphomeyaml also supports a more advanced “pin schema”.
|
|
|
|
|
|
|
|
|
|
.. code:: yaml
|
|
|
|
|
|
|
|
|
|
some_config_option:
|
|
|
|
|
# Basic:
|
|
|
|
|
pin: D0
|
|
|
|
|
|
|
|
|
|
# Advanced:
|
|
|
|
|
pin:
|
|
|
|
|
number: D0
|
|
|
|
|
inverted: True
|
|
|
|
|
mode: INPUT_PULLUP
|
|
|
|
|
|
|
|
|
|
Configuration variables:
|
|
|
|
|
|
|
|
|
|
- **number** (**Required**, pin): The pin number.
|
|
|
|
|
- **inverted** (*Optional*, boolean): If all read and written values
|
|
|
|
|
should be treated as inverted. Defaults to ``False``.
|
|
|
|
|
- **mode** (*Optional*, string): A pin mode to set for the pin at
|
|
|
|
|
startup, corresponds to Arduino’s ``pinMode`` call.
|
|
|
|
|
|
|
|
|
|
Available Pin Modes:
|
|
|
|
|
|
|
|
|
|
- ``INPUT``
|
|
|
|
|
- ``OUTPUT``
|
|
|
|
|
- ``OUTPUT_OPEN_DRAIN``
|
2018-05-14 21:15:49 +02:00
|
|
|
|
- ``ANALOG`` (only on ESP32)
|
|
|
|
|
- ``INPUT_PULLUP``
|
|
|
|
|
- ``INPUT_PULLDOWN`` (only on ESP32)
|
|
|
|
|
- ``INPUT_PULLDOWN_16`` (only on ESP8266 and only on GPIO16)
|
|
|
|
|
|
|
|
|
|
More exotic Pin Modes are also supported, but rarely used:
|
|
|
|
|
|
2018-05-13 11:37:02 +02:00
|
|
|
|
- ``WAKEUP_PULLUP`` (only on ESP8266)
|
|
|
|
|
- ``WAKEUP_PULLDOWN`` (only on ESP8266)
|
|
|
|
|
- ``SPECIAL``
|
|
|
|
|
- ``FUNCTION_0`` (only on ESP8266)
|
|
|
|
|
- ``FUNCTION_1``
|
|
|
|
|
- ``FUNCTION_2``
|
|
|
|
|
- ``FUNCTION_3``
|
|
|
|
|
- ``FUNCTION_4``
|
|
|
|
|
- ``FUNCTION_5`` (only on ESP32)
|
|
|
|
|
- ``FUNCTION_6`` (only on ESP32)
|
|
|
|
|
|
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
|
|
|
|
|
2018-05-14 21:15:49 +02:00
|
|
|
|
In lots of places in esphomeyaml you need to define time periods.
|
|
|
|
|
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
|
|
|
|
|
|
|
|
|
.. code:: yaml
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
|
- :doc:`esphomeyaml index </esphomeyaml/index>`
|
|
|
|
|
- :doc:`getting_started_command_line`
|
|
|
|
|
- :doc:`faq`
|
2018-06-04 08:17:22 +02:00
|
|
|
|
- `Edit this page on GitHub <https://github.com/OttoWinter/esphomedocs/blob/current/esphomeyaml/guides/configuration-types.rst>`__
|
2018-10-12 16:33:22 +02:00
|
|
|
|
|
|
|
|
|
.. disqus::
|