2018-05-13 11:37:02 +02:00
|
|
|
|
Light Component
|
|
|
|
|
===============
|
|
|
|
|
|
2018-11-14 22:12:27 +01:00
|
|
|
|
.. seo::
|
2019-02-16 23:25:23 +01:00
|
|
|
|
:description: Instructions for setting up lights and light effects in ESPHome.
|
2018-11-19 18:32:16 +01:00
|
|
|
|
:image: folder-open.png
|
2018-11-14 22:12:27 +01:00
|
|
|
|
|
2019-02-16 23:25:23 +01:00
|
|
|
|
The ``light`` domain in ESPHome lets you create lights that will
|
2018-05-13 11:37:02 +02:00
|
|
|
|
automatically be shown in Home Assistant’s frontend and have many
|
|
|
|
|
features such as RGB colors, transitions, flashing and effects.
|
|
|
|
|
|
2019-03-17 12:10:03 +01:00
|
|
|
|
This component restores its state on reboot/reset.
|
|
|
|
|
|
2019-05-12 22:44:59 +02:00
|
|
|
|
.. _config-light:
|
|
|
|
|
|
|
|
|
|
Base Light Configuration
|
|
|
|
|
------------------------
|
|
|
|
|
|
|
|
|
|
All light configuration schemas inherit these options.
|
|
|
|
|
|
|
|
|
|
.. code-block:: yaml
|
|
|
|
|
|
|
|
|
|
light:
|
|
|
|
|
- platform: ...
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Configuration variables:
|
|
|
|
|
|
|
|
|
|
- **effects** (*Optional*, list): A list of :ref:`light effects <light-effects>` to use for this light.
|
|
|
|
|
- **gamma_correct** (*Optional*, float): Apply a `gamma correction
|
|
|
|
|
factor <https://en.wikipedia.org/wiki/Gamma_correction>`__ to the light channels.
|
|
|
|
|
Defaults to ``2.8``.
|
|
|
|
|
- **default_transition_length** (*Optional*, :ref:`config-time`): The default transition length
|
|
|
|
|
to use when no transition length is set in the light call. Defaults to ``1s``.
|
2019-05-27 19:22:49 +02:00
|
|
|
|
- **restore_mode** (*Optional*): Control how the GPIO Switch attempts to restore state on bootup.
|
|
|
|
|
For restoring on ESP8266s, also see ``esp8266_restore_from_flash`` in the
|
|
|
|
|
:doc:`esphome section </components/esphome>`.
|
|
|
|
|
|
|
|
|
|
- ``RESTORE_DEFAULT_OFF`` (Default) - Attempt to restore state and default to OFF if not possible to restore.
|
|
|
|
|
- ``RESTORE_DEFAULT_ON`` - Attempt to restore state and default to ON.
|
|
|
|
|
- ``ALWAYS_OFF`` - Always initialize the light as OFF on bootup.
|
|
|
|
|
- ``ALWAYS_ON`` - Always initialize the light as ON on bootup.
|
2019-05-12 22:44:59 +02:00
|
|
|
|
|
|
|
|
|
Additional Configuration variables for addressable lights:
|
|
|
|
|
|
|
|
|
|
- **color_correct** (*Optional*, list of float): Apply a color correction to each color channel.
|
|
|
|
|
This defines the maximum brightness of each channel. For example ``[100%, 50%, 100%]`` would set the
|
|
|
|
|
green channel to be at most at 50% brightness.
|
|
|
|
|
- **power_supply** (*Optional*, :ref:`config-id`): The :doc:`/components/power_supply` to connect to
|
|
|
|
|
this light. When the light is turned on, the power supply will automatically be switched on too.
|
|
|
|
|
|
|
|
|
|
Advanced options:
|
|
|
|
|
|
|
|
|
|
- **internal** (*Optional*, boolean): Mark this component as internal. Internal components will
|
|
|
|
|
not be exposed to the frontend (like Home Assistant). Only specifying an ``id`` without
|
|
|
|
|
a ``name`` will implicitly set this to true.
|
|
|
|
|
- If MQTT enabled, all other options from :ref:`MQTT Component <config-mqtt-component>`.
|
|
|
|
|
|
2018-06-01 18:10:00 +02:00
|
|
|
|
.. _light-toggle_action:
|
2018-05-13 11:37:02 +02:00
|
|
|
|
|
2018-06-01 18:10:00 +02:00
|
|
|
|
``light.toggle`` Action
|
2018-08-22 22:05:28 +02:00
|
|
|
|
-----------------------
|
2018-05-13 11:37:02 +02:00
|
|
|
|
|
2018-06-01 18:10:00 +02:00
|
|
|
|
This action toggles a light with the given ID when executed.
|
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
|
|
|
|
|
2018-06-01 18:10:00 +02:00
|
|
|
|
on_...:
|
|
|
|
|
then:
|
|
|
|
|
- light.toggle:
|
|
|
|
|
id: light_1
|
2018-11-10 14:31:27 +01:00
|
|
|
|
# Shorthand:
|
|
|
|
|
- light.toggle: light_1
|
2018-05-13 11:37:02 +02:00
|
|
|
|
|
2018-06-01 18:10:00 +02:00
|
|
|
|
Configuration options:
|
2018-05-13 11:37:02 +02:00
|
|
|
|
|
2018-06-01 18:10:00 +02:00
|
|
|
|
- **id** (**Required**, :ref:`config-id`): The ID of the light.
|
|
|
|
|
- **transition_length** (*Optional*, :ref:`config-time`, :ref:`templatable <config-templatable>`): The length of the transition
|
|
|
|
|
if the light supports it.
|
2018-05-13 11:37:02 +02:00
|
|
|
|
|
2018-10-20 14:53:27 +02:00
|
|
|
|
.. note::
|
|
|
|
|
|
|
|
|
|
This action can also be expressed in :ref:`lambdas <config-lambda>`:
|
|
|
|
|
|
2018-11-19 18:32:16 +01:00
|
|
|
|
.. code-block:: cpp
|
2018-10-20 14:53:27 +02:00
|
|
|
|
|
|
|
|
|
auto call = id(light_1).toggle();
|
|
|
|
|
// perform action:
|
|
|
|
|
call.perform();
|
|
|
|
|
|
2018-06-01 18:10:00 +02:00
|
|
|
|
.. _light-turn_on_action:
|
2018-05-13 11:37:02 +02:00
|
|
|
|
|
2018-06-01 18:10:00 +02:00
|
|
|
|
``light.turn_on`` Action
|
2018-08-22 22:05:28 +02:00
|
|
|
|
------------------------
|
2018-06-01 18:10:00 +02:00
|
|
|
|
|
|
|
|
|
This action turns a light with the given ID on when executed.
|
|
|
|
|
|
2018-11-19 18:32:16 +01:00
|
|
|
|
.. code-block:: yaml
|
2018-06-01 18:10:00 +02:00
|
|
|
|
|
|
|
|
|
on_...:
|
|
|
|
|
then:
|
|
|
|
|
- light.turn_on:
|
|
|
|
|
id: light_1
|
|
|
|
|
brightness: 100%
|
|
|
|
|
red: 100%
|
|
|
|
|
green: 100%
|
|
|
|
|
blue: 1.0
|
|
|
|
|
|
|
|
|
|
# Templated
|
|
|
|
|
- light.turn_on:
|
|
|
|
|
id: light_1
|
2019-01-06 18:56:14 +01:00
|
|
|
|
brightness: !lambda |-
|
2018-06-01 18:10:00 +02:00
|
|
|
|
// output value must be in range 0 - 1.0
|
2018-10-20 14:53:27 +02:00
|
|
|
|
return id(some_sensor).state / 100.0;
|
2018-06-01 18:10:00 +02:00
|
|
|
|
|
2018-11-10 14:31:27 +01:00
|
|
|
|
# Shorthand
|
|
|
|
|
- light.turn_on: light_1
|
|
|
|
|
|
2018-06-01 18:10:00 +02:00
|
|
|
|
Configuration options:
|
|
|
|
|
|
|
|
|
|
- **id** (**Required**, :ref:`config-id`): The ID of the light.
|
|
|
|
|
- **transition_length** (*Optional*, :ref:`config-time`, :ref:`templatable <config-templatable>`): The length of the transition
|
|
|
|
|
if the light supports it.
|
|
|
|
|
- **brightness** (*Optional*, percentage, :ref:`templatable <config-templatable>`): The brightness of the light. Must be in range
|
|
|
|
|
``0%`` to ``100%`` or ``0.0`` to ``1.0``. Defaults to not changing brightness.
|
|
|
|
|
- **red** (*Optional*, percentage, :ref:`templatable <config-templatable>`): The red channel of the light. Must be in range
|
|
|
|
|
``0%`` to ``100%`` or ``0.0`` to ``1.0``. Defaults to not changing red.
|
|
|
|
|
- **green** (*Optional*, percentage, :ref:`templatable <config-templatable>`): The green channel of the light. Must be in range
|
|
|
|
|
``0%`` to ``100%`` or ``0.0`` to ``1.0``. Defaults to not changing green channel.
|
|
|
|
|
- **blue** (*Optional*, percentage, :ref:`templatable <config-templatable>`): The blue channel of the light. Must be in range
|
|
|
|
|
``0%`` to ``100%`` or ``0.0`` to ``1.0``. Defaults to not changing blue channel.
|
|
|
|
|
- **white** (*Optional*, percentage, :ref:`templatable <config-templatable>`): The white channel value of RGBW lights. Must be in range
|
|
|
|
|
``0%`` to ``100%`` or ``0.0`` to ``1.0``. Defaults to not changing white value.
|
|
|
|
|
- **flash_length** (*Optional*, :ref:`config-time`, :ref:`templatable <config-templatable>`): If set, will flash the given color
|
|
|
|
|
for this period of time and then go back to the previous state.
|
|
|
|
|
- **effect** (*Optional*, string, :ref:`templatable <config-templatable>`): If set, will attempt to
|
|
|
|
|
start an effect with the given name.
|
|
|
|
|
|
2018-10-20 14:53:27 +02:00
|
|
|
|
.. note::
|
|
|
|
|
|
|
|
|
|
This action can also be expressed in :ref:`lambdas <config-lambda>`:
|
|
|
|
|
|
2018-11-19 18:32:16 +01:00
|
|
|
|
.. code-block:: cpp
|
2018-10-20 14:53:27 +02:00
|
|
|
|
|
|
|
|
|
auto call = id(light_1).turn_on();
|
|
|
|
|
// set parameters (optional)
|
|
|
|
|
call.set_transition_length(1000); // in ms
|
|
|
|
|
call.set_brightness(1.0); // 1.0 is full brightness
|
|
|
|
|
call.set_rgb(1.0, 1.0, 1.0); // color, 1.0 is fully lit
|
|
|
|
|
call.set_effect("The Effect");
|
|
|
|
|
// perform action:
|
|
|
|
|
call.perform();
|
|
|
|
|
|
2019-03-17 12:10:03 +01:00
|
|
|
|
.. note::
|
|
|
|
|
|
|
|
|
|
The ``red``, ``green`` and ``blue`` values only control the color of the light, not its
|
|
|
|
|
brightness! If you assign ``50%`` to all RGB channels it will be interpreted as 100% on.
|
|
|
|
|
Only use ``brightness`` to control the brightness of the light.
|
|
|
|
|
|
2018-06-01 18:10:00 +02:00
|
|
|
|
.. _light-turn_off_action:
|
|
|
|
|
|
|
|
|
|
``light.turn_off`` Action
|
2018-08-22 22:05:28 +02:00
|
|
|
|
-------------------------
|
2018-06-01 18:10:00 +02:00
|
|
|
|
|
|
|
|
|
This action turns a light with the given ID off when executed.
|
|
|
|
|
|
2018-11-19 18:32:16 +01:00
|
|
|
|
.. code-block:: yaml
|
2018-06-01 18:10:00 +02:00
|
|
|
|
|
|
|
|
|
on_...:
|
|
|
|
|
then:
|
|
|
|
|
- light.turn_off:
|
|
|
|
|
id: light_1
|
|
|
|
|
|
2018-11-10 14:31:27 +01:00
|
|
|
|
# Shorthand
|
|
|
|
|
- light.turn_off: light_1
|
|
|
|
|
|
2018-06-01 18:10:00 +02:00
|
|
|
|
Configuration options:
|
|
|
|
|
|
|
|
|
|
- **id** (**Required**, :ref:`config-id`): The ID of the light.
|
|
|
|
|
- **transition_length** (*Optional*, :ref:`config-time`, :ref:`templatable <config-templatable>`): The length of the transition
|
|
|
|
|
if the light supports it.
|
|
|
|
|
|
2018-10-20 14:53:27 +02:00
|
|
|
|
.. note::
|
|
|
|
|
|
|
|
|
|
This action can also be expressed in :ref:`lambdas <config-lambda>`:
|
|
|
|
|
|
2018-11-19 18:32:16 +01:00
|
|
|
|
.. code-block:: cpp
|
2018-10-20 14:53:27 +02:00
|
|
|
|
|
|
|
|
|
auto call = id(light_1).turn_off();
|
|
|
|
|
// set parameters (optional)
|
|
|
|
|
call.set_transition_length(1000); // in ms
|
|
|
|
|
// perform action:
|
|
|
|
|
call.perform();
|
2018-06-01 18:10:00 +02:00
|
|
|
|
|
2019-05-12 22:44:59 +02:00
|
|
|
|
.. _light-control_action:
|
|
|
|
|
|
|
|
|
|
``light.control`` Action
|
|
|
|
|
------------------------
|
|
|
|
|
|
|
|
|
|
This :ref:`Action <config-action>` is a generic call to change the state of a light - it
|
|
|
|
|
is essentially just a combination of the turn_on and turn_off calls.
|
|
|
|
|
|
|
|
|
|
.. code-block:: yaml
|
|
|
|
|
|
|
|
|
|
on_...:
|
|
|
|
|
then:
|
|
|
|
|
- light.control:
|
|
|
|
|
id: light_1
|
|
|
|
|
state: on
|
|
|
|
|
|
|
|
|
|
Configuration options:
|
|
|
|
|
|
|
|
|
|
- **id** (**Required**, :ref:`config-id`): The ID of the light.
|
|
|
|
|
- **state** (*Optional*, :ref:`templatable <config-templatable>`, boolean): Change the ON/OFF
|
|
|
|
|
state of the light.
|
|
|
|
|
- All other options from :ref:`light.turn_on <light-turn_on_action>`.
|
|
|
|
|
|
|
|
|
|
.. _light-dim_relative_action:
|
|
|
|
|
|
|
|
|
|
``light.dim_relative`` Action
|
|
|
|
|
-----------------------------
|
|
|
|
|
|
|
|
|
|
This :ref:`Action <config-action>` allows you to dim a light that supports brightness
|
|
|
|
|
by a relative amount.
|
|
|
|
|
|
|
|
|
|
.. code-block:: yaml
|
|
|
|
|
|
|
|
|
|
on_...:
|
|
|
|
|
then:
|
|
|
|
|
# Increases the brightness by 5%
|
|
|
|
|
- light.dim_relative:
|
|
|
|
|
id: light_1
|
|
|
|
|
relative_brightness: 5%
|
|
|
|
|
|
|
|
|
|
Configuration options:
|
|
|
|
|
|
|
|
|
|
- **id** (**Required**, :ref:`config-id`): The ID of the light.
|
|
|
|
|
- **relative_brightness** (**Required***, :ref:`templatable <config-templatable>`, percentage):
|
|
|
|
|
The relative brightness to dim the light by.
|
|
|
|
|
- **transition_length** (*Optional*, :ref:`config-time`, :ref:`templatable <config-templatable>`): The length of the transition.
|
|
|
|
|
|
|
|
|
|
.. note::
|
|
|
|
|
|
|
|
|
|
Example: dimming a light with a button press
|
|
|
|
|
|
|
|
|
|
.. code-block:: yaml
|
|
|
|
|
|
|
|
|
|
binary_sensor:
|
|
|
|
|
- platform: gpio
|
|
|
|
|
# ...
|
|
|
|
|
id: my_binary_sensor
|
|
|
|
|
on_press:
|
|
|
|
|
- while:
|
|
|
|
|
condition:
|
|
|
|
|
binary_sensor.is_on: my_binary_sensor
|
|
|
|
|
then:
|
|
|
|
|
- light.dim_relative:
|
|
|
|
|
id: light_1
|
|
|
|
|
relative_brightness: 5%
|
|
|
|
|
transition_length: 0.1s
|
|
|
|
|
- delay: 0.1s
|
|
|
|
|
|
|
|
|
|
.. _light-addressable_set_action:
|
|
|
|
|
|
|
|
|
|
``light.addressable_set`` Action
|
|
|
|
|
--------------------------------
|
|
|
|
|
|
|
|
|
|
This :ref:`Action <config-action>` allows you to manually set a range of LEDs on an addressable light
|
|
|
|
|
to a specific color.
|
|
|
|
|
|
|
|
|
|
.. code-block:: yaml
|
|
|
|
|
|
|
|
|
|
on_...:
|
|
|
|
|
- light.addressable_set:
|
|
|
|
|
id: my_light
|
2019-05-13 21:51:04 +02:00
|
|
|
|
range_from: 0
|
2019-05-12 22:44:59 +02:00
|
|
|
|
range_to: 50
|
|
|
|
|
red: 100%
|
|
|
|
|
green: 0%
|
|
|
|
|
blue: 0%
|
|
|
|
|
|
|
|
|
|
Configuration variables:
|
|
|
|
|
|
|
|
|
|
- **id** (**Required**, :ref:`config-id`): The ID of the addressable light to control.
|
|
|
|
|
- **range_from** (*Optional*, :ref:`templatable <config-templatable>`, int): The beginning
|
2019-05-13 21:51:04 +02:00
|
|
|
|
of the range of LEDs to control. 0-based indexing. Defaults to 0 (the beginning of the strip).
|
2019-05-12 22:44:59 +02:00
|
|
|
|
- **range_to** (*Optional*, :ref:`templatable <config-templatable>`, int): The end of the
|
2019-05-13 21:51:04 +02:00
|
|
|
|
range of LEDs to control - this is a half-open interval. 0-based indexing.
|
|
|
|
|
Defaults to the end of the strip (``num_leds``).
|
2019-05-12 22:44:59 +02:00
|
|
|
|
- **red** (*Optional*, :ref:`templatable <config-templatable>`, percentage): The value to
|
|
|
|
|
set the red channel to.
|
|
|
|
|
- **green** (*Optional*, :ref:`templatable <config-templatable>`, percentage): The value to
|
|
|
|
|
set the green channel to.
|
|
|
|
|
- **blue** (*Optional*, :ref:`templatable <config-templatable>`, percentage): The value to
|
|
|
|
|
set the blue channel to.
|
|
|
|
|
- **white** (*Optional*, :ref:`templatable <config-templatable>`, percentage): The value to
|
|
|
|
|
set the white channel to.
|
|
|
|
|
|
2019-05-30 13:00:16 +02:00
|
|
|
|
.. _light-is_on_condition:
|
|
|
|
|
.. _light-is_off_condition:
|
|
|
|
|
|
|
|
|
|
``light.is_on`` / ``light.is_off`` Condition
|
|
|
|
|
********************************************
|
|
|
|
|
|
|
|
|
|
This :ref:`Condition <config-condition>` checks if the given light is ON or OFF. OFF means
|
|
|
|
|
that the light is completely OFF, and ON means that the light is emitting at least a bit of light.
|
|
|
|
|
|
|
|
|
|
.. code-block:: yaml
|
|
|
|
|
|
|
|
|
|
# In some trigger:
|
|
|
|
|
on_...:
|
|
|
|
|
if:
|
|
|
|
|
condition:
|
|
|
|
|
# Same syntax for is_off
|
|
|
|
|
light.is_on: my_light
|
|
|
|
|
|
2018-08-22 22:05:28 +02:00
|
|
|
|
.. _light-effects:
|
|
|
|
|
|
|
|
|
|
Light Effects
|
|
|
|
|
-------------
|
|
|
|
|
|
2019-02-16 23:25:23 +01:00
|
|
|
|
ESPHome also offers a bunch of light effects you can use for your lights. The defaults for the
|
|
|
|
|
effect parameters are made to work well on their own but of course ESPHome gives you the option to manually change
|
2018-08-22 22:05:28 +02:00
|
|
|
|
these parameters.
|
|
|
|
|
|
2019-02-16 23:25:23 +01:00
|
|
|
|
With ESPHome's light effects system you're basically creating a bunch of entries for the effects dropdown in
|
2018-08-22 22:05:28 +02:00
|
|
|
|
Home Assistant. If you wish to have several variants of the same effect you can of course also create multiple
|
|
|
|
|
entries with each having a unique name like so:
|
|
|
|
|
|
2018-11-19 18:32:16 +01:00
|
|
|
|
.. code-block:: yaml
|
2018-08-22 22:05:28 +02:00
|
|
|
|
|
|
|
|
|
light:
|
|
|
|
|
- platform: ...
|
|
|
|
|
# ...
|
|
|
|
|
effects:
|
2019-01-06 18:56:14 +01:00
|
|
|
|
# Use default parameters:
|
|
|
|
|
- random:
|
|
|
|
|
# Customize parameters
|
2018-08-22 22:05:28 +02:00
|
|
|
|
- random:
|
|
|
|
|
name: "My Slow Random Effect"
|
|
|
|
|
transition_length: 30s
|
|
|
|
|
update_interval: 30s
|
|
|
|
|
- random:
|
|
|
|
|
name: "My Fast Random Effect"
|
|
|
|
|
transition_length: 4s
|
|
|
|
|
update_interval: 5s
|
|
|
|
|
|
|
|
|
|
Random Effect
|
|
|
|
|
*************
|
|
|
|
|
|
|
|
|
|
This effect makes a transition (of length ``transition_length``) to a randomly-chosen color every ``update_interval``.
|
|
|
|
|
|
2018-11-19 18:32:16 +01:00
|
|
|
|
.. code-block:: yaml
|
2018-08-22 22:05:28 +02:00
|
|
|
|
|
|
|
|
|
light:
|
|
|
|
|
- platform: ...
|
|
|
|
|
# ...
|
|
|
|
|
effects:
|
|
|
|
|
- random:
|
|
|
|
|
- random:
|
|
|
|
|
name: Random Effect With Custom Values
|
|
|
|
|
transition_length: 5s
|
|
|
|
|
update_interval: 7s
|
|
|
|
|
|
|
|
|
|
Configuration variables:
|
|
|
|
|
|
|
|
|
|
- **name** (*Optional*, string): The name of the effect. Defaults to ``Random``.
|
|
|
|
|
- **transition_length** (*Optional*, :ref:`config-time`): The duration of each transition to start. Defaults to ``5s``.
|
|
|
|
|
- **update_interval** (*Optional*, :ref:`config-time`): The interval with which a new color is selected and transitioned
|
|
|
|
|
to.
|
|
|
|
|
|
|
|
|
|
Strobe Effect
|
|
|
|
|
*************
|
|
|
|
|
|
|
|
|
|
This effect cycles through a list of colors with specific durations.
|
|
|
|
|
|
2018-11-19 18:32:16 +01:00
|
|
|
|
.. code-block:: yaml
|
2018-08-22 22:05:28 +02:00
|
|
|
|
|
|
|
|
|
light:
|
|
|
|
|
- platform: ...
|
|
|
|
|
# ...
|
|
|
|
|
effects:
|
|
|
|
|
- strobe:
|
|
|
|
|
- strobe:
|
|
|
|
|
name: Strobe Effect With Custom Values
|
|
|
|
|
colors:
|
|
|
|
|
- state: True
|
|
|
|
|
brightness: 100%
|
|
|
|
|
red: 100%
|
|
|
|
|
green: 90%
|
|
|
|
|
blue: 0%
|
|
|
|
|
duration: 500ms
|
|
|
|
|
- state: False
|
|
|
|
|
duration: 250ms
|
|
|
|
|
- state: True
|
|
|
|
|
brightness: 100%
|
|
|
|
|
red: 0%
|
|
|
|
|
green: 100%
|
|
|
|
|
blue: 0%
|
|
|
|
|
duration: 500ms
|
|
|
|
|
|
|
|
|
|
Configuration variables:
|
|
|
|
|
|
|
|
|
|
- **name** (*Optional*, string): The name of the effect. Defaults to ``Strobe``.
|
|
|
|
|
- **colors** (*Optional*, list): A list of colors to cycle through. Defaults to a quick cycle between ON and OFF.
|
|
|
|
|
|
|
|
|
|
- **state** (*Optional*, boolean): The ON/OFF state to show. Defaults to ``True``.
|
|
|
|
|
- **brightness** (*Optional*, percentage): The brightness of the light. Defaults to ``100%``.
|
|
|
|
|
- **red** (*Optional*, percentage): The percentage that the red color should be on for RGB lights. Defaults to ``100%``.
|
|
|
|
|
- **green** (*Optional*, percentage): The percentage that the green color should be on for RGB lights. Defaults to ``100%``.
|
|
|
|
|
- **blue** (*Optional*, percentage): The percentage that the blue color should be on for RGB lights. Defaults to ``100%``.
|
|
|
|
|
- **white** (*Optional*, percentage): The percentage that the white color should be on for RGBW lights. Defaults to ``100%``.
|
|
|
|
|
- **duration** (**Required**, :ref:`config-time`): The duration this color should be active.
|
|
|
|
|
|
|
|
|
|
Flicker Effect
|
|
|
|
|
**************
|
|
|
|
|
|
|
|
|
|
This effect "hovers" around the active color of the light and flickers each color channel a bit.
|
|
|
|
|
|
2018-11-19 18:32:16 +01:00
|
|
|
|
.. code-block:: yaml
|
2018-08-22 22:05:28 +02:00
|
|
|
|
|
|
|
|
|
light:
|
|
|
|
|
- platform: ...
|
|
|
|
|
# ...
|
|
|
|
|
effects:
|
|
|
|
|
- flicker:
|
|
|
|
|
- flicker:
|
|
|
|
|
name: Flicker Effect With Custom Values
|
|
|
|
|
alpha: 95%
|
|
|
|
|
intensity: 1.5%
|
|
|
|
|
|
|
|
|
|
Configuration variables:
|
|
|
|
|
|
|
|
|
|
- **name** (*Optional*, string): The name of the effect. Defaults to ``Flicker``.
|
|
|
|
|
- **alpha** (*Optional*, percentage): The percentage that the last color value should affect the light. More
|
|
|
|
|
or less the "forget-factor" of an exponential moving average. Defaults to ``95%``.
|
|
|
|
|
- **intensity** (*Optional*, percentage): The intensity of the flickering, basically the maximum amplitude of the
|
|
|
|
|
random offsets. Defaults to ``1.5%``.
|
|
|
|
|
|
|
|
|
|
Lambda Effect
|
|
|
|
|
*************
|
|
|
|
|
|
|
|
|
|
This effect allows you to write completely custom light effects yourself using :ref:`lambdas <config-lambda>`.
|
|
|
|
|
|
2018-11-19 18:32:16 +01:00
|
|
|
|
.. code-block:: yaml
|
2018-08-22 22:05:28 +02:00
|
|
|
|
|
|
|
|
|
light:
|
|
|
|
|
- platform: ...
|
|
|
|
|
# ...
|
|
|
|
|
effects:
|
|
|
|
|
- lambda:
|
|
|
|
|
name: My Custom Effect
|
|
|
|
|
update_interval: 1s
|
|
|
|
|
lambda: |-
|
|
|
|
|
static int state = 0;
|
2019-01-17 19:48:59 +01:00
|
|
|
|
auto call = id(my_light).turn_on();
|
|
|
|
|
// Transtion of 1000ms = 1s
|
|
|
|
|
call.set_transition_length(1000);
|
2018-08-22 22:05:28 +02:00
|
|
|
|
if (state == 0) {
|
2019-01-17 19:48:59 +01:00
|
|
|
|
call.set_rgb(1.0, 1.0, 1.0);
|
2018-08-22 22:05:28 +02:00
|
|
|
|
} else if (state == 1) {
|
2019-01-17 19:48:59 +01:00
|
|
|
|
call.set_rgb(1.0, 0.0, 1.0);
|
2018-08-22 22:05:28 +02:00
|
|
|
|
} else if (state == 2) {
|
2019-01-17 19:48:59 +01:00
|
|
|
|
call.set_rgb(0.0, 0.0, 1.0);
|
2018-08-22 22:05:28 +02:00
|
|
|
|
} else {
|
2019-01-17 19:48:59 +01:00
|
|
|
|
call.set_rgb(1.0, 0.0, 0.0);
|
2018-08-22 22:05:28 +02:00
|
|
|
|
}
|
2019-02-16 10:18:43 +01:00
|
|
|
|
call.perform();
|
2018-08-22 22:05:28 +02:00
|
|
|
|
state += 1;
|
|
|
|
|
if (state == 4)
|
|
|
|
|
state = 0;
|
|
|
|
|
|
|
|
|
|
Configuration variables:
|
|
|
|
|
|
|
|
|
|
- **name** (**Required**, string): The name of the custom effect.
|
|
|
|
|
- **update_interval** (*Optional*, :ref:`config-time`): The interval with which the lambda code is executed.
|
|
|
|
|
A value of ``0ms`` means that the lambda is always executed, without a cool-down. Defaults to ``0ms``.
|
|
|
|
|
- **lambda** (**Required**, :ref:`lambda <config-lambda>`): The code to execute. ``static`` variables are
|
|
|
|
|
especially useful.
|
|
|
|
|
|
2019-01-06 18:56:14 +01:00
|
|
|
|
Addressable Rainbow Effect
|
|
|
|
|
**************************
|
2018-08-22 22:05:28 +02:00
|
|
|
|
|
|
|
|
|
A light effect for individually-addressable LEDs that creates a moving rainbow over the whole LED strip using
|
|
|
|
|
the HSV color wheel.
|
|
|
|
|
|
2018-11-19 18:32:16 +01:00
|
|
|
|
.. code-block:: yaml
|
2018-08-22 22:05:28 +02:00
|
|
|
|
|
|
|
|
|
light:
|
2019-01-06 18:56:14 +01:00
|
|
|
|
- platform: ...
|
2018-08-22 22:05:28 +02:00
|
|
|
|
# ...
|
|
|
|
|
effects:
|
2019-01-06 18:56:14 +01:00
|
|
|
|
- addressable_rainbow:
|
|
|
|
|
- addressable_rainbow:
|
2018-08-22 22:05:28 +02:00
|
|
|
|
name: Rainbow Effect With Custom Values
|
|
|
|
|
speed: 10
|
|
|
|
|
width: 50
|
|
|
|
|
|
|
|
|
|
Configuration variables:
|
|
|
|
|
|
|
|
|
|
- **name** (*Optional*, string): The name of the effect. Defaults to ``Rainbow``.
|
|
|
|
|
- **speed** (*Optional*, int): The speed of the effect, unitless. Defaults to ``10``.
|
|
|
|
|
- **width** (*Optional*, int): The "width" of a full-scale rainbow, unitless. Defaults to ``50``.
|
|
|
|
|
|
|
|
|
|
|
2019-01-06 18:56:14 +01:00
|
|
|
|
Addressable Color Wipe Effect
|
|
|
|
|
*****************************
|
2018-08-22 22:05:28 +02:00
|
|
|
|
|
|
|
|
|
A light effect for individually-addressable LEDs that continuously introduces new colors at the beginning of
|
|
|
|
|
the strip and shifts them forward every ``add_led_interval``.
|
|
|
|
|
|
2018-11-19 18:32:16 +01:00
|
|
|
|
.. code-block:: yaml
|
2018-08-22 22:05:28 +02:00
|
|
|
|
|
|
|
|
|
light:
|
2019-01-06 18:56:14 +01:00
|
|
|
|
- platform: ...
|
2018-08-22 22:05:28 +02:00
|
|
|
|
# ...
|
|
|
|
|
effects:
|
2019-01-06 18:56:14 +01:00
|
|
|
|
- addressable_color_wipe:
|
|
|
|
|
- addressable_color_wipe:
|
2018-08-22 22:05:28 +02:00
|
|
|
|
name: Color Wipe Effect With Custom Values
|
|
|
|
|
colors:
|
|
|
|
|
- red: 100%
|
|
|
|
|
green: 100%
|
|
|
|
|
blue: 100%
|
|
|
|
|
num_leds: 1
|
|
|
|
|
- red: 0%
|
|
|
|
|
green: 0%
|
|
|
|
|
blue: 0%
|
|
|
|
|
num_leds: 1
|
|
|
|
|
add_led_interval: 100ms
|
|
|
|
|
reverse: False
|
|
|
|
|
|
|
|
|
|
Configuration variables:
|
|
|
|
|
|
|
|
|
|
- **name** (*Optional*, string): The name of the effect. Defaults to ``Color Wipe``.
|
|
|
|
|
- **colors** (*Optional*, list): The colors to shift in at the beginning of the strip. Defaults to shifting in random
|
|
|
|
|
colors.
|
|
|
|
|
|
|
|
|
|
- **red** (*Optional*, percentage): The percentage the red color channel should be on. Defaults to ``100%``.
|
|
|
|
|
- **green** (*Optional*, percentage): The percentage the green color channel should be on. Defaults to ``100%``.
|
|
|
|
|
- **blue** (*Optional*, percentage): The percentage the blue color channel should be on. Defaults to ``100%``.
|
|
|
|
|
- **random** (*Optional*, boolean): If set to ``True``, will overwrite the RGB colors by a new, randomly-chosen
|
|
|
|
|
color each time. Defaults to ``False``.
|
|
|
|
|
- **num_leds** (*Optional*, int): The number of leds of this type to have before moving on to the next color.
|
|
|
|
|
|
|
|
|
|
- **add_led_interval** (*Optional*, :ref:`config-time`): The interval with which to shift in new leds at the
|
|
|
|
|
beginning of the strip. Defaults to ``100ms``.
|
|
|
|
|
- **reverse** (*Optional*, boolean): Whether to reverse the direction of the color wipe. Defaults to ``False``.
|
|
|
|
|
|
2019-01-06 18:56:14 +01:00
|
|
|
|
Addressable Scan Effect
|
|
|
|
|
***********************
|
2018-08-22 22:05:28 +02:00
|
|
|
|
|
|
|
|
|
Create a single, fast-moving dot moving back and forth an individually-addressable LED strip. The color is chosen by the
|
|
|
|
|
currently active light color.
|
|
|
|
|
|
2018-11-19 18:32:16 +01:00
|
|
|
|
.. code-block:: yaml
|
2018-08-22 22:05:28 +02:00
|
|
|
|
|
|
|
|
|
light:
|
2019-01-06 18:56:14 +01:00
|
|
|
|
- platform: ...
|
2018-08-22 22:05:28 +02:00
|
|
|
|
# ...
|
|
|
|
|
effects:
|
2019-01-06 18:56:14 +01:00
|
|
|
|
- addressable_scan:
|
|
|
|
|
- addressable_scan:
|
2018-08-22 22:05:28 +02:00
|
|
|
|
name: Scan Effect With Custom Values
|
|
|
|
|
move_interval: 100ms
|
|
|
|
|
|
|
|
|
|
Configuration variables:
|
|
|
|
|
|
|
|
|
|
- **name** (*Optional*, string): The name of the effect. Defaults to ``Scan``.
|
|
|
|
|
- **move_interval** (*Optional*, :ref:`config-time`): The interval with which to move the dot one LED forward.
|
|
|
|
|
Defaults to ``100ms``.
|
|
|
|
|
|
2019-01-06 18:56:14 +01:00
|
|
|
|
Addressable Twinkle Effect
|
|
|
|
|
**************************
|
2018-08-22 22:05:28 +02:00
|
|
|
|
|
|
|
|
|
A light effect for individually-addressable LED strips that randomly chooses some LEDs and let's them bright
|
|
|
|
|
up for a moment, like a stars twinkling in the night's sky. The color of the pixels will be chosen by the
|
|
|
|
|
currently active light color.
|
|
|
|
|
|
2018-11-19 18:32:16 +01:00
|
|
|
|
.. code-block:: yaml
|
2018-08-22 22:05:28 +02:00
|
|
|
|
|
|
|
|
|
light:
|
2019-01-06 18:56:14 +01:00
|
|
|
|
- platform: ...
|
2018-08-22 22:05:28 +02:00
|
|
|
|
# ...
|
|
|
|
|
effects:
|
2019-01-06 18:56:14 +01:00
|
|
|
|
- addressable_twinkle:
|
|
|
|
|
- addressable_twinkle:
|
2018-08-22 22:05:28 +02:00
|
|
|
|
name: Twinkle Effect With Custom Values
|
|
|
|
|
twinkle_probability: 5%
|
|
|
|
|
progress_interval: 4ms
|
|
|
|
|
|
|
|
|
|
Configuration variables:
|
|
|
|
|
|
|
|
|
|
- **name** (*Optional*, string): The name of the effect. Defaults to ``Twinkle``.
|
|
|
|
|
- **twinkle_probability** (*Optional*, percentage): The percentage with which, at any time step, a randomly-chosen
|
|
|
|
|
LED should start its twinkle animation.
|
|
|
|
|
- **progress_interval** (*Optional*, :ref:`config-time`): The interval with which to progress the effect. This
|
|
|
|
|
affects the duration of a twinkle animation. Defaults to ``4ms``.
|
|
|
|
|
|
2019-01-06 18:56:14 +01:00
|
|
|
|
Addressable Random Twinkle Effect
|
|
|
|
|
*********************************
|
2018-08-22 22:05:28 +02:00
|
|
|
|
|
2019-01-06 18:56:14 +01:00
|
|
|
|
A light effect similar to ``addressable_twinkle``, but using random colors for each twinkle animation.
|
2018-08-22 22:05:28 +02:00
|
|
|
|
|
2018-11-19 18:32:16 +01:00
|
|
|
|
.. code-block:: yaml
|
2018-08-22 22:05:28 +02:00
|
|
|
|
|
|
|
|
|
light:
|
2019-01-06 18:56:14 +01:00
|
|
|
|
- platform: ...
|
2018-08-22 22:05:28 +02:00
|
|
|
|
# ...
|
|
|
|
|
effects:
|
2019-01-06 18:56:14 +01:00
|
|
|
|
- addressable_random_twinkle:
|
|
|
|
|
- addressable_random_twinkle:
|
2018-08-22 22:05:28 +02:00
|
|
|
|
name: Random Twinkle Effect With Custom Values
|
|
|
|
|
twinkle_probability: 5%
|
|
|
|
|
progress_interval: 32ms
|
|
|
|
|
|
|
|
|
|
Configuration variables:
|
|
|
|
|
|
|
|
|
|
- **name** (*Optional*, string): The name of the effect. Defaults to ``Random Twinkle``.
|
|
|
|
|
- **twinkle_probability** (*Optional*, percentage): The percentage with which, at any time step, a randomly-chosen
|
|
|
|
|
LED should start its twinkle animation.
|
|
|
|
|
- **progress_interval** (*Optional*, :ref:`config-time`): The interval with which to progress the effect. This
|
|
|
|
|
affects the duration of a twinkle animation. Defaults to ``4ms``.
|
|
|
|
|
|
|
|
|
|
|
2019-01-06 18:56:14 +01:00
|
|
|
|
Addressable Fireworks Effect
|
|
|
|
|
****************************
|
2018-08-22 22:05:28 +02:00
|
|
|
|
|
|
|
|
|
A light effect for individually-addressable LED strips that randomly sparks some fireworks at random positions
|
|
|
|
|
and lets the sparkles cascade over the LED strip.
|
|
|
|
|
|
2018-11-19 18:32:16 +01:00
|
|
|
|
.. code-block:: yaml
|
2018-08-22 22:05:28 +02:00
|
|
|
|
|
|
|
|
|
light:
|
2019-01-06 18:56:14 +01:00
|
|
|
|
- platform: ...
|
2018-08-22 22:05:28 +02:00
|
|
|
|
# ...
|
|
|
|
|
effects:
|
2019-01-06 18:56:14 +01:00
|
|
|
|
- addressable_fireworks:
|
|
|
|
|
- addressable_fireworks:
|
2018-08-22 22:05:28 +02:00
|
|
|
|
name: Fireworks Effect With Custom Values
|
|
|
|
|
update_interval: 32ms
|
|
|
|
|
spark_probability: 10%
|
|
|
|
|
use_random_color: false
|
|
|
|
|
fade_out_rate: 120
|
|
|
|
|
|
|
|
|
|
Configuration variables:
|
|
|
|
|
|
|
|
|
|
- **name** (*Optional*, string): The name of the effect. Defaults to ``Fireworks``.
|
|
|
|
|
- **update_interval** (*Optional*, :ref:`config-time`): The interval with which to progress the effect.
|
|
|
|
|
Defaults to ``32ms``.
|
|
|
|
|
- **spark_probability** (*Optional*, percentage): The probability to start a new firework spark at a randomly-chosen
|
|
|
|
|
LED at any given time step. Defaults to ``10%``.
|
|
|
|
|
- **use_random_color** (*Optional*, boolean): Whether to use random colors for new firework sparks. Defaults to
|
|
|
|
|
using the currently active light color.
|
|
|
|
|
- **fade_out_rate** (*Optional*, integer): The rate with which to fade out the LED strip, unitless. Needs to be carefully
|
|
|
|
|
chosen so that the whole strip doesn't light up forever if the fade out rate is too low or that the firework
|
|
|
|
|
sparks do not propagate for a long time. Defaults to ``120``.
|
|
|
|
|
|
2019-01-06 18:56:14 +01:00
|
|
|
|
Addressable Flicker Effect
|
|
|
|
|
**************************
|
2018-08-22 22:05:28 +02:00
|
|
|
|
|
|
|
|
|
An effect similar to the ``flicker`` effect, but for individually-addressable LED strips. This effect flickers
|
|
|
|
|
each LED by its own random amount around the currently active light color.
|
|
|
|
|
|
2018-11-19 18:32:16 +01:00
|
|
|
|
.. code-block:: yaml
|
2018-08-22 22:05:28 +02:00
|
|
|
|
|
|
|
|
|
light:
|
2019-01-06 18:56:14 +01:00
|
|
|
|
- platform: ...
|
2018-08-22 22:05:28 +02:00
|
|
|
|
# ...
|
|
|
|
|
effects:
|
2019-01-06 18:56:14 +01:00
|
|
|
|
- addressable_flicker:
|
|
|
|
|
- addressable_flicker:
|
2018-08-22 22:05:28 +02:00
|
|
|
|
name: Flicker Effect With Custom Values
|
|
|
|
|
update_interval: 16ms
|
|
|
|
|
intensity: 5%
|
|
|
|
|
|
|
|
|
|
Configuration variables:
|
|
|
|
|
|
2019-01-06 18:56:14 +01:00
|
|
|
|
- **name** (*Optional*, string): The name of the effect. Defaults to ``Addressable Flicker``.
|
2018-08-22 22:05:28 +02:00
|
|
|
|
- **update_interval** (*Optional*, :ref:`config-time`): The time interval for updating the random offsets.
|
|
|
|
|
Defaults to ``16ms``.
|
|
|
|
|
- **intensity** (*Optional*, percentage): The intensity of the effect, basically how much the random values can offset
|
|
|
|
|
the currently active light color. Defaults to ``5%``.
|
|
|
|
|
|
2019-02-17 19:28:27 +01:00
|
|
|
|
Addressable Lambda Effect
|
|
|
|
|
*************************
|
|
|
|
|
|
|
|
|
|
This effect allows you to access each LED individually in a custom light effect.
|
|
|
|
|
|
2019-05-12 22:44:59 +02:00
|
|
|
|
You're passed in one variable: ``it`` - an :apiclass:`AddressableLight <light::AddressableLight>`
|
2019-02-17 19:28:27 +01:00
|
|
|
|
instance (see API reference for more info).
|
|
|
|
|
|
|
|
|
|
.. code-block:: yaml
|
|
|
|
|
|
|
|
|
|
light:
|
|
|
|
|
- platform: ...
|
|
|
|
|
effects:
|
|
|
|
|
- addressable_lambda:
|
|
|
|
|
name: "My Custom Effect"
|
|
|
|
|
update_interval: 16ms
|
|
|
|
|
lambda: |-
|
|
|
|
|
// it.size() - Number of LEDs
|
|
|
|
|
// it[num] - Access the LED at index num.
|
|
|
|
|
// Set the LED at num to the given r, g, b values
|
2019-05-12 22:44:59 +02:00
|
|
|
|
// it[num] = ESPColor(r, g, b);
|
2019-02-17 19:28:27 +01:00
|
|
|
|
// Get the color at index num (ESPColor instance)
|
|
|
|
|
// it[num].get();
|
|
|
|
|
|
|
|
|
|
// Example: Simple color wipe
|
|
|
|
|
for (int i = 1; i < it.size(); i++) {
|
|
|
|
|
it[i] = it[i - 1].get();
|
|
|
|
|
}
|
2019-05-12 22:44:59 +02:00
|
|
|
|
it[0] = ESPColor::random_color();
|
2019-02-17 19:28:27 +01:00
|
|
|
|
|
2019-05-12 22:44:59 +02:00
|
|
|
|
// Bonus: use .range() and .all() to set many LEDs without having to write a loop.
|
|
|
|
|
it.range(0, 50) = ESPColor::BLACK;
|
|
|
|
|
it.all().fade_to_black(10);
|
2019-02-17 19:28:27 +01:00
|
|
|
|
|
|
|
|
|
Examples of this API can be found here:
|
2019-05-12 22:44:59 +02:00
|
|
|
|
https://github.com/esphome/esphome/blob/dev/esphome/components/light/addressable_light_effect.h
|
2019-02-17 19:28:27 +01:00
|
|
|
|
(the built-in addressable light effects).
|
|
|
|
|
|
2019-05-27 19:35:46 +02:00
|
|
|
|
Automation Light Effect
|
|
|
|
|
***********************
|
|
|
|
|
|
|
|
|
|
Additionally to the ``lambda`` and ``addressable_lambda`` light effects, effects can also
|
|
|
|
|
be written through ESPHome's :ref:`Automation <automation>` system with the ``automation``
|
|
|
|
|
effect type.
|
|
|
|
|
|
|
|
|
|
The automation given in the ``sequence`` block will be repeatedly executed until the effect
|
|
|
|
|
is stopped by the user.
|
|
|
|
|
|
|
|
|
|
.. code-block:: yaml
|
|
|
|
|
|
|
|
|
|
light:
|
|
|
|
|
- platform: ...
|
|
|
|
|
id: my_light
|
|
|
|
|
effects:
|
|
|
|
|
- automation:
|
|
|
|
|
name: Custom Automation Effect
|
|
|
|
|
sequence:
|
|
|
|
|
- light.addressable_set:
|
|
|
|
|
id: my_light
|
|
|
|
|
red: 100%
|
|
|
|
|
green: 100%
|
|
|
|
|
blue: 100%
|
|
|
|
|
- delay: 100ms
|
|
|
|
|
- light.addressable_set:
|
|
|
|
|
id: my_light
|
|
|
|
|
range_from: 0
|
|
|
|
|
range_to: 20
|
|
|
|
|
red: 100%
|
|
|
|
|
green: 0%
|
|
|
|
|
blue: 0%
|
|
|
|
|
|
|
|
|
|
Configuration variables:
|
|
|
|
|
|
|
|
|
|
- **name** (*Optional*, string): The name of the effect.
|
|
|
|
|
- **sequence** (*Optional*, :ref:`Action <config-action>`): The actions to perform in sequence
|
|
|
|
|
until the effect is stopped.
|
|
|
|
|
|
2018-06-01 18:10:00 +02:00
|
|
|
|
See Also
|
2018-08-22 22:05:28 +02:00
|
|
|
|
--------
|
2018-06-01 18:10:00 +02:00
|
|
|
|
|
2019-02-07 13:54:45 +01:00
|
|
|
|
- :apiref:`light/light_state.h`
|
2018-08-24 22:44:01 +02:00
|
|
|
|
- `WS2812FX library <https://github.com/kitesurfer1404/WS2812FX>`__ by `@kitesurfer1404 <https://github.com/kitesurfer1404>`__
|
2019-02-07 13:54:45 +01:00
|
|
|
|
- :ghedit:`Edit`
|
2018-06-01 18:10:00 +02:00
|
|
|
|
|
|
|
|
|
.. toctree::
|
|
|
|
|
:maxdepth: 1
|
2018-10-20 14:53:27 +02:00
|
|
|
|
:glob:
|
2018-06-01 18:10:00 +02:00
|
|
|
|
|
2018-10-20 14:53:27 +02:00
|
|
|
|
*
|