[light] Add `initial_state` configuration (#7577)
Some checks failed
YAML lint / yamllint (push) Has been cancelled
CI / Create common environment (push) Has been cancelled
CI / Check flake8 (push) Has been cancelled
CI / Check pylint (push) Has been cancelled
CI / Check pyupgrade (push) Has been cancelled
CI / CI Status (push) Has been cancelled
CI / Check black (push) Has been cancelled
CI / Run script/ci-custom (push) Has been cancelled
CI / Run pytest (push) Has been cancelled
CI / Check clang-format (push) Has been cancelled
CI / Run script/clang-tidy for ESP32 Arduino 1/4 (push) Has been cancelled
CI / Run script/clang-tidy for ESP32 Arduino 2/4 (push) Has been cancelled
CI / Run script/clang-tidy for ESP32 Arduino 3/4 (push) Has been cancelled
CI / Run script/clang-tidy for ESP32 Arduino 4/4 (push) Has been cancelled
CI / Run script/clang-tidy for ESP32 IDF (push) Has been cancelled
CI / Run script/clang-tidy for ESP8266 (push) Has been cancelled
CI / list-components (push) Has been cancelled
CI / Component test (push) Has been cancelled
CI / Split components for testing into 20 groups maximum (push) Has been cancelled
CI / Test split components (push) Has been cancelled

This commit is contained in:
Jesse Hills 2024-10-12 06:13:32 +13:00 committed by GitHub
parent cedb671f07
commit efe4c5e3bc
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
14 changed files with 287 additions and 775 deletions

View file

@ -3,27 +3,39 @@ import esphome.codegen as cg
from esphome.components import mqtt, power_supply, web_server from esphome.components import mqtt, power_supply, web_server
import esphome.config_validation as cv import esphome.config_validation as cv
from esphome.const import ( from esphome.const import (
CONF_BLUE,
CONF_BRIGHTNESS,
CONF_COLD_WHITE,
CONF_COLD_WHITE_COLOR_TEMPERATURE, CONF_COLD_WHITE_COLOR_TEMPERATURE,
CONF_COLOR_BRIGHTNESS,
CONF_COLOR_CORRECT, CONF_COLOR_CORRECT,
CONF_COLOR_MODE,
CONF_COLOR_TEMPERATURE,
CONF_DEFAULT_TRANSITION_LENGTH, CONF_DEFAULT_TRANSITION_LENGTH,
CONF_EFFECTS, CONF_EFFECTS,
CONF_FLASH_TRANSITION_LENGTH, CONF_FLASH_TRANSITION_LENGTH,
CONF_GAMMA_CORRECT, CONF_GAMMA_CORRECT,
CONF_GREEN,
CONF_ID, CONF_ID,
CONF_INITIAL_STATE,
CONF_MQTT_ID, CONF_MQTT_ID,
CONF_ON_STATE, CONF_ON_STATE,
CONF_ON_TURN_OFF, CONF_ON_TURN_OFF,
CONF_ON_TURN_ON, CONF_ON_TURN_ON,
CONF_POWER_SUPPLY, CONF_POWER_SUPPLY,
CONF_RED,
CONF_RESTORE_MODE, CONF_RESTORE_MODE,
CONF_STATE,
CONF_TRIGGER_ID, CONF_TRIGGER_ID,
CONF_WARM_WHITE,
CONF_WARM_WHITE_COLOR_TEMPERATURE, CONF_WARM_WHITE_COLOR_TEMPERATURE,
CONF_WEB_SERVER, CONF_WEB_SERVER,
CONF_WHITE,
) )
from esphome.core import coroutine_with_priority from esphome.core import coroutine_with_priority
from esphome.cpp_helpers import setup_entity from esphome.cpp_helpers import setup_entity
from .automation import light_control_to_code # noqa from .automation import LIGHT_STATE_SCHEMA
from .effects import ( from .effects import (
ADDRESSABLE_EFFECTS, ADDRESSABLE_EFFECTS,
BINARY_EFFECTS, BINARY_EFFECTS,
@ -35,8 +47,10 @@ from .effects import (
from .types import ( # noqa from .types import ( # noqa
AddressableLight, AddressableLight,
AddressableLightState, AddressableLightState,
ColorMode,
LightOutput, LightOutput,
LightState, LightState,
LightStateRTCState,
LightStateTrigger, LightStateTrigger,
LightTurnOffTrigger, LightTurnOffTrigger,
LightTurnOnTrigger, LightTurnOnTrigger,
@ -85,6 +99,7 @@ LIGHT_SCHEMA = (
cv.GenerateID(CONF_TRIGGER_ID): cv.declare_id(LightStateTrigger), cv.GenerateID(CONF_TRIGGER_ID): cv.declare_id(LightStateTrigger),
} }
), ),
cv.Optional(CONF_INITIAL_STATE): LIGHT_STATE_SCHEMA,
} }
) )
) )
@ -145,6 +160,22 @@ async def setup_light_core_(light_var, output_var, config):
cg.add(light_var.set_restore_mode(config[CONF_RESTORE_MODE])) cg.add(light_var.set_restore_mode(config[CONF_RESTORE_MODE]))
if (initial_state_config := config.get(CONF_INITIAL_STATE)) is not None:
initial_state = LightStateRTCState(
initial_state_config.get(CONF_COLOR_MODE, ColorMode.UNKNOWN),
initial_state_config.get(CONF_STATE, False),
initial_state_config.get(CONF_BRIGHTNESS, 1.0),
initial_state_config.get(CONF_COLOR_BRIGHTNESS, 1.0),
initial_state_config.get(CONF_RED, 1.0),
initial_state_config.get(CONF_GREEN, 1.0),
initial_state_config.get(CONF_BLUE, 1.0),
initial_state_config.get(CONF_WHITE, 1.0),
initial_state_config.get(CONF_COLOR_TEMPERATURE, 1.0),
initial_state_config.get(CONF_COLD_WHITE, 1.0),
initial_state_config.get(CONF_WARM_WHITE, 1.0),
)
cg.add(light_var.set_initial_state(initial_state))
if ( if (
default_transition_length := config.get(CONF_DEFAULT_TRANSITION_LENGTH) default_transition_length := config.get(CONF_DEFAULT_TRANSITION_LENGTH)
) is not None: ) is not None:

View file

@ -1,41 +1,42 @@
from esphome import automation
import esphome.codegen as cg import esphome.codegen as cg
import esphome.config_validation as cv import esphome.config_validation as cv
from esphome import automation
from esphome.const import ( from esphome.const import (
CONF_ID,
CONF_COLOR_MODE,
CONF_TRANSITION_LENGTH,
CONF_STATE,
CONF_FLASH_LENGTH,
CONF_EFFECT,
CONF_BRIGHTNESS,
CONF_COLOR_BRIGHTNESS,
CONF_RED,
CONF_GREEN,
CONF_BLUE, CONF_BLUE,
CONF_WHITE, CONF_BRIGHTNESS,
CONF_COLOR_TEMPERATURE, CONF_BRIGHTNESS_LIMITS,
CONF_COLD_WHITE, CONF_COLD_WHITE,
CONF_WARM_WHITE, CONF_COLOR_BRIGHTNESS,
CONF_COLOR_MODE,
CONF_COLOR_TEMPERATURE,
CONF_EFFECT,
CONF_FLASH_LENGTH,
CONF_GREEN,
CONF_ID,
CONF_LIMIT_MODE,
CONF_MAX_BRIGHTNESS,
CONF_MIN_BRIGHTNESS,
CONF_RANGE_FROM, CONF_RANGE_FROM,
CONF_RANGE_TO, CONF_RANGE_TO,
CONF_BRIGHTNESS_LIMITS, CONF_RED,
CONF_LIMIT_MODE, CONF_STATE,
CONF_MIN_BRIGHTNESS, CONF_TRANSITION_LENGTH,
CONF_MAX_BRIGHTNESS, CONF_WARM_WHITE,
CONF_WHITE,
) )
from .types import ( from .types import (
ColorMode,
COLOR_MODES, COLOR_MODES,
LIMIT_MODES, LIMIT_MODES,
DimRelativeAction,
ToggleAction,
LightState,
LightControlAction,
AddressableLightState, AddressableLightState,
AddressableSet, AddressableSet,
LightIsOnCondition, ColorMode,
DimRelativeAction,
LightControlAction,
LightIsOffCondition, LightIsOffCondition,
LightIsOnCondition,
LightState,
ToggleAction,
) )
@ -62,18 +63,10 @@ async def light_toggle_to_code(config, action_id, template_arg, args):
return var return var
LIGHT_CONTROL_ACTION_SCHEMA = cv.Schema( LIGHT_STATE_SCHEMA = cv.Schema(
{ {
cv.Required(CONF_ID): cv.use_id(LightState),
cv.Optional(CONF_COLOR_MODE): cv.enum(COLOR_MODES, upper=True, space="_"), cv.Optional(CONF_COLOR_MODE): cv.enum(COLOR_MODES, upper=True, space="_"),
cv.Optional(CONF_STATE): cv.templatable(cv.boolean), cv.Optional(CONF_STATE): cv.templatable(cv.boolean),
cv.Exclusive(CONF_TRANSITION_LENGTH, "transformer"): cv.templatable(
cv.positive_time_period_milliseconds
),
cv.Exclusive(CONF_FLASH_LENGTH, "transformer"): cv.templatable(
cv.positive_time_period_milliseconds
),
cv.Exclusive(CONF_EFFECT, "transformer"): cv.templatable(cv.string),
cv.Optional(CONF_BRIGHTNESS): cv.templatable(cv.percentage), cv.Optional(CONF_BRIGHTNESS): cv.templatable(cv.percentage),
cv.Optional(CONF_COLOR_BRIGHTNESS): cv.templatable(cv.percentage), cv.Optional(CONF_COLOR_BRIGHTNESS): cv.templatable(cv.percentage),
cv.Optional(CONF_RED): cv.templatable(cv.percentage), cv.Optional(CONF_RED): cv.templatable(cv.percentage),
@ -85,6 +78,20 @@ LIGHT_CONTROL_ACTION_SCHEMA = cv.Schema(
cv.Optional(CONF_WARM_WHITE): cv.templatable(cv.percentage), cv.Optional(CONF_WARM_WHITE): cv.templatable(cv.percentage),
} }
) )
LIGHT_CONTROL_ACTION_SCHEMA = LIGHT_STATE_SCHEMA.extend(
{
cv.Required(CONF_ID): cv.use_id(LightState),
cv.Exclusive(CONF_TRANSITION_LENGTH, "transformer"): cv.templatable(
cv.positive_time_period_milliseconds
),
cv.Exclusive(CONF_FLASH_LENGTH, "transformer"): cv.templatable(
cv.positive_time_period_milliseconds
),
cv.Exclusive(CONF_EFFECT, "transformer"): cv.templatable(cv.string),
}
)
LIGHT_TURN_OFF_ACTION_SCHEMA = automation.maybe_simple_id( LIGHT_TURN_OFF_ACTION_SCHEMA = automation.maybe_simple_id(
{ {
cv.Required(CONF_ID): cv.use_id(LightState), cv.Required(CONF_ID): cv.use_id(LightState),

View file

@ -1,59 +1,59 @@
from esphome.schema_extractors import SCHEMA_EXTRACT, schema_extractor from esphome import automation
import esphome.codegen as cg import esphome.codegen as cg
import esphome.config_validation as cv import esphome.config_validation as cv
from esphome import automation
from esphome.const import ( from esphome.const import (
CONF_NAME,
CONF_LAMBDA,
CONF_UPDATE_INTERVAL,
CONF_TRANSITION_LENGTH,
CONF_COLORS,
CONF_STATE,
CONF_DURATION,
CONF_BRIGHTNESS,
CONF_COLOR_MODE,
CONF_COLOR_BRIGHTNESS,
CONF_RED,
CONF_GREEN,
CONF_BLUE,
CONF_WHITE,
CONF_COLOR_TEMPERATURE,
CONF_COLD_WHITE,
CONF_WARM_WHITE,
CONF_ALPHA, CONF_ALPHA,
CONF_BLUE,
CONF_BRIGHTNESS,
CONF_COLD_WHITE,
CONF_COLOR_BRIGHTNESS,
CONF_COLOR_MODE,
CONF_COLOR_TEMPERATURE,
CONF_COLORS,
CONF_DURATION,
CONF_GREEN,
CONF_INTENSITY, CONF_INTENSITY,
CONF_SPEED, CONF_LAMBDA,
CONF_WIDTH,
CONF_NUM_LEDS,
CONF_RANDOM,
CONF_SEQUENCE,
CONF_MAX_BRIGHTNESS, CONF_MAX_BRIGHTNESS,
CONF_MIN_BRIGHTNESS, CONF_MIN_BRIGHTNESS,
CONF_NAME,
CONF_NUM_LEDS,
CONF_RANDOM,
CONF_RED,
CONF_SEQUENCE,
CONF_SPEED,
CONF_STATE,
CONF_TRANSITION_LENGTH,
CONF_UPDATE_INTERVAL,
CONF_WARM_WHITE,
CONF_WHITE,
CONF_WIDTH,
) )
from esphome.schema_extractors import SCHEMA_EXTRACT, schema_extractor
from esphome.util import Registry from esphome.util import Registry
from .types import ( from .types import (
ColorMode,
COLOR_MODES, COLOR_MODES,
AddressableColorWipeEffect,
AddressableColorWipeEffectColor,
AddressableFireworksEffect,
AddressableFlickerEffect,
AddressableLambdaLightEffect,
AddressableLightRef,
AddressableRainbowLightEffect,
AddressableRandomTwinkleEffect,
AddressableScanEffect,
AddressableTwinkleEffect,
AutomationLightEffect,
Color,
ColorMode,
FlickerLightEffect,
LambdaLightEffect, LambdaLightEffect,
LightColorValues,
PulseLightEffect, PulseLightEffect,
RandomLightEffect, RandomLightEffect,
StrobeLightEffect, StrobeLightEffect,
StrobeLightEffectColor, StrobeLightEffectColor,
LightColorValues,
AddressableLightRef,
AddressableLambdaLightEffect,
FlickerLightEffect,
AddressableRainbowLightEffect,
AddressableColorWipeEffect,
AddressableColorWipeEffectColor,
AddressableScanEffect,
AddressableTwinkleEffect,
AddressableRandomTwinkleEffect,
AddressableFireworksEffect,
AddressableFlickerEffect,
AutomationLightEffect,
Color,
) )
CONF_ADD_LED_INTERVAL = "add_led_interval" CONF_ADD_LED_INTERVAL = "add_led_interval"

View file

@ -1,6 +1,7 @@
#include "esphome/core/log.h" #include "esphome/core/log.h"
#include "light_state.h"
#include "light_output.h" #include "light_output.h"
#include "light_state.h"
#include "transformers.h" #include "transformers.h"
namespace esphome { namespace esphome {
@ -16,21 +17,6 @@ LightCall LightState::turn_off() { return this->make_call().set_state(false); }
LightCall LightState::toggle() { return this->make_call().set_state(!this->remote_values.is_on()); } LightCall LightState::toggle() { return this->make_call().set_state(!this->remote_values.is_on()); }
LightCall LightState::make_call() { return LightCall(this); } LightCall LightState::make_call() { return LightCall(this); }
struct LightStateRTCState {
ColorMode color_mode{ColorMode::UNKNOWN};
bool state{false};
float brightness{1.0f};
float color_brightness{1.0f};
float red{1.0f};
float green{1.0f};
float blue{1.0f};
float white{1.0f};
float color_temp{1.0f};
float cold_white{1.0f};
float warm_white{1.0f};
uint32_t effect{0};
};
void LightState::setup() { void LightState::setup() {
ESP_LOGCONFIG(TAG, "Setting up light '%s'...", this->get_name().c_str()); ESP_LOGCONFIG(TAG, "Setting up light '%s'...", this->get_name().c_str());
@ -48,6 +34,9 @@ void LightState::setup() {
auto call = this->make_call(); auto call = this->make_call();
LightStateRTCState recovered{}; LightStateRTCState recovered{};
if (this->initial_state_.has_value()) {
recovered = *this->initial_state_;
}
switch (this->restore_mode_) { switch (this->restore_mode_) {
case LIGHT_RESTORE_DEFAULT_OFF: case LIGHT_RESTORE_DEFAULT_OFF:
case LIGHT_RESTORE_DEFAULT_ON: case LIGHT_RESTORE_DEFAULT_ON:
@ -175,6 +164,7 @@ void LightState::set_flash_transition_length(uint32_t flash_transition_length) {
uint32_t LightState::get_flash_transition_length() const { return this->flash_transition_length_; } uint32_t LightState::get_flash_transition_length() const { return this->flash_transition_length_; }
void LightState::set_gamma_correct(float gamma_correct) { this->gamma_correct_ = gamma_correct; } void LightState::set_gamma_correct(float gamma_correct) { this->gamma_correct_ = gamma_correct; }
void LightState::set_restore_mode(LightRestoreMode restore_mode) { this->restore_mode_ = restore_mode; } void LightState::set_restore_mode(LightRestoreMode restore_mode) { this->restore_mode_ = restore_mode; }
void LightState::set_initial_state(const LightStateRTCState &initial_state) { this->initial_state_ = initial_state; }
bool LightState::supports_effects() { return !this->effects_.empty(); } bool LightState::supports_effects() { return !this->effects_.empty(); }
const std::vector<LightEffect *> &LightState::get_effects() const { return this->effects_; } const std::vector<LightEffect *> &LightState::get_effects() const { return this->effects_; }
void LightState::add_effects(const std::vector<LightEffect *> &effects) { void LightState::add_effects(const std::vector<LightEffect *> &effects) {

View file

@ -28,6 +28,35 @@ enum LightRestoreMode {
LIGHT_RESTORE_AND_ON, LIGHT_RESTORE_AND_ON,
}; };
struct LightStateRTCState {
LightStateRTCState(ColorMode color_mode, bool state, float brightness, float color_brightness, float red, float green,
float blue, float white, float color_temp, float cold_white, float warm_white)
: color_mode(color_mode),
state(state),
brightness(brightness),
color_brightness(color_brightness),
red(red),
green(green),
blue(blue),
white(white),
color_temp(color_temp),
cold_white(cold_white),
warm_white(warm_white) {}
LightStateRTCState() = default;
ColorMode color_mode{ColorMode::UNKNOWN};
bool state{false};
float brightness{1.0f};
float color_brightness{1.0f};
float red{1.0f};
float green{1.0f};
float blue{1.0f};
float white{1.0f};
float color_temp{1.0f};
float cold_white{1.0f};
float warm_white{1.0f};
uint32_t effect{0};
};
/** This class represents the communication layer between the front-end MQTT layer and the /** This class represents the communication layer between the front-end MQTT layer and the
* hardware output layer. * hardware output layer.
*/ */
@ -116,6 +145,9 @@ class LightState : public EntityBase, public Component {
/// Set the restore mode of this light /// Set the restore mode of this light
void set_restore_mode(LightRestoreMode restore_mode); void set_restore_mode(LightRestoreMode restore_mode);
/// Set the initial state of this light
void set_initial_state(const LightStateRTCState &initial_state);
/// Return whether the light has any effects that meet the trait requirements. /// Return whether the light has any effects that meet the trait requirements.
bool supports_effects(); bool supports_effects();
@ -212,6 +244,8 @@ class LightState : public EntityBase, public Component {
float gamma_correct_{}; float gamma_correct_{};
/// Restore mode of the light. /// Restore mode of the light.
LightRestoreMode restore_mode_; LightRestoreMode restore_mode_;
/// Initial state of the light.
optional<LightStateRTCState> initial_state_{};
/// List of effects for this light. /// List of effects for this light.
std::vector<LightEffect *> effects_; std::vector<LightEffect *> effects_;

View file

@ -1,5 +1,5 @@
import esphome.codegen as cg
from esphome import automation from esphome import automation
import esphome.codegen as cg
# Base # Base
light_ns = cg.esphome_ns.namespace("light") light_ns = cg.esphome_ns.namespace("light")
@ -12,6 +12,8 @@ AddressableLightRef = AddressableLight.operator("ref")
Color = cg.esphome_ns.class_("Color") Color = cg.esphome_ns.class_("Color")
LightColorValues = light_ns.class_("LightColorValues") LightColorValues = light_ns.class_("LightColorValues")
LightStateRTCState = light_ns.struct("LightStateRTCState")
# Color modes # Color modes
ColorMode = light_ns.enum("ColorMode", is_class=True) ColorMode = light_ns.enum("ColorMode", is_class=True)
COLOR_MODES = { COLOR_MODES = {

View file

@ -398,6 +398,7 @@ CONF_INDOOR = "indoor"
CONF_INFRARED = "infrared" CONF_INFRARED = "infrared"
CONF_INITIAL_MODE = "initial_mode" CONF_INITIAL_MODE = "initial_mode"
CONF_INITIAL_OPTION = "initial_option" CONF_INITIAL_OPTION = "initial_option"
CONF_INITIAL_STATE = "initial_state"
CONF_INITIAL_VALUE = "initial_value" CONF_INITIAL_VALUE = "initial_value"
CONF_INPUT = "input" CONF_INPUT = "input"
CONF_INTEGRATION_TIME = "integration_time" CONF_INTEGRATION_TIME = "integration_time"

View file

@ -0,0 +1,125 @@
esphome:
on_boot:
then:
- light.toggle: test_binary_light
- light.turn_off: test_rgb_light
- light.turn_on:
id: test_rgb_light
brightness: 100%
red: 100%
green: 100%
blue: 1.0
- light.control:
id: test_monochromatic_light
state: on
- light.dim_relative:
id: test_monochromatic_light
relative_brightness: 5%
brightness_limits:
max_brightness: 90%
light:
- platform: binary
id: test_binary_light
name: Binary Light
output: test_binary
effects:
- strobe:
on_state:
- logger.log: Binary light state changed
- platform: monochromatic
id: test_monochromatic_light
name: Monochromatic Light
output: test_ledc_1
gamma_correct: 2.8
default_transition_length: 2s
effects:
- strobe:
- flicker:
- flicker:
name: My Flicker
alpha: 98%
intensity: 1.5%
- lambda:
name: My Custom Effect
update_interval: 1s
lambda: |-
static int state = 0;
state += 1;
if (state == 4)
state = 0;
- pulse:
transition_length: 10s
update_interval: 20s
min_brightness: 10%
max_brightness: 90%
- pulse:
name: pulse2
transition_length:
on_length: 10s
off_length: 5s
update_interval: 15s
min_brightness: 10%
max_brightness: 90%
- platform: rgb
id: test_rgb_light
name: RGB Light
red: test_ledc_1
green: test_ledc_2
blue: test_ledc_3
- platform: rgbw
id: test_rgbw_light
name: RGBW Light
red: test_ledc_1
green: test_ledc_2
blue: test_ledc_3
white: test_ledc_4
color_interlock: true
- platform: rgbww
id: test_rgbww_light
name: RGBWW Light
red: test_ledc_1
green: test_ledc_2
blue: test_ledc_3
cold_white: test_ledc_4
warm_white: test_ledc_5
cold_white_color_temperature: 153 mireds
warm_white_color_temperature: 500 mireds
color_interlock: true
- platform: rgbct
id: test_rgbct_light
name: RGBCT Light
red: test_ledc_1
green: test_ledc_2
blue: test_ledc_3
color_temperature: test_ledc_4
white_brightness: test_ledc_5
cold_white_color_temperature: 153 mireds
warm_white_color_temperature: 500 mireds
color_interlock: true
- platform: cwww
id: test_cwww_light
name: CWWW Light
cold_white: test_ledc_1
warm_white: test_ledc_2
cold_white_color_temperature: 153 mireds
warm_white_color_temperature: 500 mireds
constant_brightness: true
- platform: color_temperature
id: test_color_temperature_light
name: CT Light
color_temperature: test_ledc_1
brightness: test_ledc_2
cold_white_color_temperature: 153 mireds
warm_white_color_temperature: 500 mireds
- platform: rgb
id: test_rgb_light_initial_state
name: RGB Light
red: test_ledc_1
green: test_ledc_2
blue: test_ledc_3
initial_state:
color_mode: rgb
red: 100%
green: 50%
blue: 50%

View file

@ -1,23 +1,3 @@
esphome:
on_boot:
then:
- light.toggle: test_binary_light
- light.turn_off: test_rgb_light
- light.turn_on:
id: test_rgb_light
brightness: 100%
red: 100%
green: 100%
blue: 1.0
- light.control:
id: test_monochromatic_light
state: on
- light.dim_relative:
id: test_monochromatic_light
relative_brightness: 5%
brightness_limits:
max_brightness: 90%
output: output:
- platform: gpio - platform: gpio
id: test_binary id: test_binary
@ -38,97 +18,4 @@ output:
id: test_ledc_5 id: test_ledc_5
pin: 17 pin: 17
light: <<: !include common.yaml
- platform: binary
id: test_binary_light
name: Binary Light
output: test_binary
effects:
- strobe:
on_state:
- logger.log: Binary light state changed
- platform: monochromatic
id: test_monochromatic_light
name: Monochromatic Light
output: test_ledc_1
gamma_correct: 2.8
default_transition_length: 2s
effects:
- strobe:
- flicker:
- flicker:
name: My Flicker
alpha: 98%
intensity: 1.5%
- lambda:
name: My Custom Effect
update_interval: 1s
lambda: |-
static int state = 0;
state += 1;
if (state == 4)
state = 0;
- pulse:
transition_length: 10s
update_interval: 20s
min_brightness: 10%
max_brightness: 90%
- pulse:
name: pulse2
transition_length:
on_length: 10s
off_length: 5s
update_interval: 15s
min_brightness: 10%
max_brightness: 90%
- platform: rgb
id: test_rgb_light
name: RGB Light
red: test_ledc_1
green: test_ledc_2
blue: test_ledc_3
- platform: rgbw
id: test_rgbw_light
name: RGBW Light
red: test_ledc_1
green: test_ledc_2
blue: test_ledc_3
white: test_ledc_4
color_interlock: true
- platform: rgbww
id: test_rgbww_light
name: RGBWW Light
red: test_ledc_1
green: test_ledc_2
blue: test_ledc_3
cold_white: test_ledc_4
warm_white: test_ledc_5
cold_white_color_temperature: 153 mireds
warm_white_color_temperature: 500 mireds
color_interlock: true
- platform: rgbct
id: test_rgbct_light
name: RGBCT Light
red: test_ledc_1
green: test_ledc_2
blue: test_ledc_3
color_temperature: test_ledc_4
white_brightness: test_ledc_5
cold_white_color_temperature: 153 mireds
warm_white_color_temperature: 500 mireds
color_interlock: true
- platform: cwww
id: test_cwww_light
name: CWWW Light
cold_white: test_ledc_1
warm_white: test_ledc_2
cold_white_color_temperature: 153 mireds
warm_white_color_temperature: 500 mireds
constant_brightness: true
- platform: color_temperature
id: test_color_temperature_light
name: CT Light
color_temperature: test_ledc_1
brightness: test_ledc_2
cold_white_color_temperature: 153 mireds
warm_white_color_temperature: 500 mireds

View file

@ -1,23 +1,3 @@
esphome:
on_boot:
then:
- light.toggle: test_binary_light
- light.turn_off: test_rgb_light
- light.turn_on:
id: test_rgb_light
brightness: 100%
red: 100%
green: 100%
blue: 1.0
- light.control:
id: test_monochromatic_light
state: on
- light.dim_relative:
id: test_monochromatic_light
relative_brightness: 5%
brightness_limits:
max_brightness: 90%
output: output:
- platform: gpio - platform: gpio
id: test_binary id: test_binary
@ -38,97 +18,4 @@ output:
id: test_ledc_5 id: test_ledc_5
pin: 5 pin: 5
light: <<: !include common.yaml
- platform: binary
id: test_binary_light
name: Binary Light
output: test_binary
effects:
- strobe:
on_state:
- logger.log: Binary light state changed
- platform: monochromatic
id: test_monochromatic_light
name: Monochromatic Light
output: test_ledc_1
gamma_correct: 2.8
default_transition_length: 2s
effects:
- strobe:
- flicker:
- flicker:
name: My Flicker
alpha: 98%
intensity: 1.5%
- lambda:
name: My Custom Effect
update_interval: 1s
lambda: |-
static int state = 0;
state += 1;
if (state == 4)
state = 0;
- pulse:
transition_length: 10s
update_interval: 20s
min_brightness: 10%
max_brightness: 90%
- pulse:
name: pulse2
transition_length:
on_length: 10s
off_length: 5s
update_interval: 15s
min_brightness: 10%
max_brightness: 90%
- platform: rgb
id: test_rgb_light
name: RGB Light
red: test_ledc_1
green: test_ledc_2
blue: test_ledc_3
- platform: rgbw
id: test_rgbw_light
name: RGBW Light
red: test_ledc_1
green: test_ledc_2
blue: test_ledc_3
white: test_ledc_4
color_interlock: true
- platform: rgbww
id: test_rgbww_light
name: RGBWW Light
red: test_ledc_1
green: test_ledc_2
blue: test_ledc_3
cold_white: test_ledc_4
warm_white: test_ledc_5
cold_white_color_temperature: 153 mireds
warm_white_color_temperature: 500 mireds
color_interlock: true
- platform: rgbct
id: test_rgbct_light
name: RGBCT Light
red: test_ledc_1
green: test_ledc_2
blue: test_ledc_3
color_temperature: test_ledc_4
white_brightness: test_ledc_5
cold_white_color_temperature: 153 mireds
warm_white_color_temperature: 500 mireds
color_interlock: true
- platform: cwww
id: test_cwww_light
name: CWWW Light
cold_white: test_ledc_1
warm_white: test_ledc_2
cold_white_color_temperature: 153 mireds
warm_white_color_temperature: 500 mireds
constant_brightness: true
- platform: color_temperature
id: test_color_temperature_light
name: CT Light
color_temperature: test_ledc_1
brightness: test_ledc_2
cold_white_color_temperature: 153 mireds
warm_white_color_temperature: 500 mireds

View file

@ -1,23 +1,3 @@
esphome:
on_boot:
then:
- light.toggle: test_binary_light
- light.turn_off: test_rgb_light
- light.turn_on:
id: test_rgb_light
brightness: 100%
red: 100%
green: 100%
blue: 1.0
- light.control:
id: test_monochromatic_light
state: on
- light.dim_relative:
id: test_monochromatic_light
relative_brightness: 5%
brightness_limits:
max_brightness: 90%
output: output:
- platform: gpio - platform: gpio
id: test_binary id: test_binary
@ -38,97 +18,4 @@ output:
id: test_ledc_5 id: test_ledc_5
pin: 5 pin: 5
light: <<: !include common.yaml
- platform: binary
id: test_binary_light
name: Binary Light
output: test_binary
effects:
- strobe:
on_state:
- logger.log: Binary light state changed
- platform: monochromatic
id: test_monochromatic_light
name: Monochromatic Light
output: test_ledc_1
gamma_correct: 2.8
default_transition_length: 2s
effects:
- strobe:
- flicker:
- flicker:
name: My Flicker
alpha: 98%
intensity: 1.5%
- lambda:
name: My Custom Effect
update_interval: 1s
lambda: |-
static int state = 0;
state += 1;
if (state == 4)
state = 0;
- pulse:
transition_length: 10s
update_interval: 20s
min_brightness: 10%
max_brightness: 90%
- pulse:
name: pulse2
transition_length:
on_length: 10s
off_length: 5s
update_interval: 15s
min_brightness: 10%
max_brightness: 90%
- platform: rgb
id: test_rgb_light
name: RGB Light
red: test_ledc_1
green: test_ledc_2
blue: test_ledc_3
- platform: rgbw
id: test_rgbw_light
name: RGBW Light
red: test_ledc_1
green: test_ledc_2
blue: test_ledc_3
white: test_ledc_4
color_interlock: true
- platform: rgbww
id: test_rgbww_light
name: RGBWW Light
red: test_ledc_1
green: test_ledc_2
blue: test_ledc_3
cold_white: test_ledc_4
warm_white: test_ledc_5
cold_white_color_temperature: 153 mireds
warm_white_color_temperature: 500 mireds
color_interlock: true
- platform: rgbct
id: test_rgbct_light
name: RGBCT Light
red: test_ledc_1
green: test_ledc_2
blue: test_ledc_3
color_temperature: test_ledc_4
white_brightness: test_ledc_5
cold_white_color_temperature: 153 mireds
warm_white_color_temperature: 500 mireds
color_interlock: true
- platform: cwww
id: test_cwww_light
name: CWWW Light
cold_white: test_ledc_1
warm_white: test_ledc_2
cold_white_color_temperature: 153 mireds
warm_white_color_temperature: 500 mireds
constant_brightness: true
- platform: color_temperature
id: test_color_temperature_light
name: CT Light
color_temperature: test_ledc_1
brightness: test_ledc_2
cold_white_color_temperature: 153 mireds
warm_white_color_temperature: 500 mireds

View file

@ -1,23 +1,3 @@
esphome:
on_boot:
then:
- light.toggle: test_binary_light
- light.turn_off: test_rgb_light
- light.turn_on:
id: test_rgb_light
brightness: 100%
red: 100%
green: 100%
blue: 1.0
- light.control:
id: test_monochromatic_light
state: on
- light.dim_relative:
id: test_monochromatic_light
relative_brightness: 5%
brightness_limits:
max_brightness: 90%
output: output:
- platform: gpio - platform: gpio
id: test_binary id: test_binary
@ -38,97 +18,4 @@ output:
id: test_ledc_5 id: test_ledc_5
pin: 17 pin: 17
light: <<: !include common.yaml
- platform: binary
id: test_binary_light
name: Binary Light
output: test_binary
effects:
- strobe:
on_state:
- logger.log: Binary light state changed
- platform: monochromatic
id: test_monochromatic_light
name: Monochromatic Light
output: test_ledc_1
gamma_correct: 2.8
default_transition_length: 2s
effects:
- strobe:
- flicker:
- flicker:
name: My Flicker
alpha: 98%
intensity: 1.5%
- lambda:
name: My Custom Effect
update_interval: 1s
lambda: |-
static int state = 0;
state += 1;
if (state == 4)
state = 0;
- pulse:
transition_length: 10s
update_interval: 20s
min_brightness: 10%
max_brightness: 90%
- pulse:
name: pulse2
transition_length:
on_length: 10s
off_length: 5s
update_interval: 15s
min_brightness: 10%
max_brightness: 90%
- platform: rgb
id: test_rgb_light
name: RGB Light
red: test_ledc_1
green: test_ledc_2
blue: test_ledc_3
- platform: rgbw
id: test_rgbw_light
name: RGBW Light
red: test_ledc_1
green: test_ledc_2
blue: test_ledc_3
white: test_ledc_4
color_interlock: true
- platform: rgbww
id: test_rgbww_light
name: RGBWW Light
red: test_ledc_1
green: test_ledc_2
blue: test_ledc_3
cold_white: test_ledc_4
warm_white: test_ledc_5
cold_white_color_temperature: 153 mireds
warm_white_color_temperature: 500 mireds
color_interlock: true
- platform: rgbct
id: test_rgbct_light
name: RGBCT Light
red: test_ledc_1
green: test_ledc_2
blue: test_ledc_3
color_temperature: test_ledc_4
white_brightness: test_ledc_5
cold_white_color_temperature: 153 mireds
warm_white_color_temperature: 500 mireds
color_interlock: true
- platform: cwww
id: test_cwww_light
name: CWWW Light
cold_white: test_ledc_1
warm_white: test_ledc_2
cold_white_color_temperature: 153 mireds
warm_white_color_temperature: 500 mireds
constant_brightness: true
- platform: color_temperature
id: test_color_temperature_light
name: CT Light
color_temperature: test_ledc_1
brightness: test_ledc_2
cold_white_color_temperature: 153 mireds
warm_white_color_temperature: 500 mireds

View file

@ -1,23 +1,3 @@
esphome:
on_boot:
then:
- light.toggle: test_binary_light
- light.turn_off: test_rgb_light
- light.turn_on:
id: test_rgb_light
brightness: 100%
red: 100%
green: 100%
blue: 1.0
- light.control:
id: test_monochromatic_light
state: on
- light.dim_relative:
id: test_monochromatic_light
relative_brightness: 5%
brightness_limits:
max_brightness: 90%
output: output:
- platform: gpio - platform: gpio
id: test_binary id: test_binary
@ -38,97 +18,4 @@ output:
id: test_ledc_5 id: test_ledc_5
pin: 16 pin: 16
light: <<: !include common.yaml
- platform: binary
id: test_binary_light
name: Binary Light
output: test_binary
effects:
- strobe:
on_state:
- logger.log: Binary light state changed
- platform: monochromatic
id: test_monochromatic_light
name: Monochromatic Light
output: test_ledc_1
gamma_correct: 2.8
default_transition_length: 2s
effects:
- strobe:
- flicker:
- flicker:
name: My Flicker
alpha: 98%
intensity: 1.5%
- lambda:
name: My Custom Effect
update_interval: 1s
lambda: |-
static int state = 0;
state += 1;
if (state == 4)
state = 0;
- pulse:
transition_length: 10s
update_interval: 20s
min_brightness: 10%
max_brightness: 90%
- pulse:
name: pulse2
transition_length:
on_length: 10s
off_length: 5s
update_interval: 15s
min_brightness: 10%
max_brightness: 90%
- platform: rgb
id: test_rgb_light
name: RGB Light
red: test_ledc_1
green: test_ledc_2
blue: test_ledc_3
- platform: rgbw
id: test_rgbw_light
name: RGBW Light
red: test_ledc_1
green: test_ledc_2
blue: test_ledc_3
white: test_ledc_4
color_interlock: true
- platform: rgbww
id: test_rgbww_light
name: RGBWW Light
red: test_ledc_1
green: test_ledc_2
blue: test_ledc_3
cold_white: test_ledc_4
warm_white: test_ledc_5
cold_white_color_temperature: 153 mireds
warm_white_color_temperature: 500 mireds
color_interlock: true
- platform: rgbct
id: test_rgbct_light
name: RGBCT Light
red: test_ledc_1
green: test_ledc_2
blue: test_ledc_3
color_temperature: test_ledc_4
white_brightness: test_ledc_5
cold_white_color_temperature: 153 mireds
warm_white_color_temperature: 500 mireds
color_interlock: true
- platform: cwww
id: test_cwww_light
name: CWWW Light
cold_white: test_ledc_1
warm_white: test_ledc_2
cold_white_color_temperature: 153 mireds
warm_white_color_temperature: 500 mireds
constant_brightness: true
- platform: color_temperature
id: test_color_temperature_light
name: CT Light
color_temperature: test_ledc_1
brightness: test_ledc_2
cold_white_color_temperature: 153 mireds
warm_white_color_temperature: 500 mireds

View file

@ -1,23 +1,3 @@
esphome:
on_boot:
then:
- light.toggle: test_binary_light
- light.turn_off: test_rgb_light
- light.turn_on:
id: test_rgb_light
brightness: 100%
red: 100%
green: 100%
blue: 1.0
- light.control:
id: test_monochromatic_light
state: on
- light.dim_relative:
id: test_monochromatic_light
relative_brightness: 5%
brightness_limits:
max_brightness: 90%
output: output:
- platform: gpio - platform: gpio
id: test_binary id: test_binary
@ -38,97 +18,4 @@ output:
id: test_ledc_5 id: test_ledc_5
pin: 5 pin: 5
light: <<: !include common.yaml
- platform: binary
id: test_binary_light
name: Binary Light
output: test_binary
effects:
- strobe:
on_state:
- logger.log: Binary light state changed
- platform: monochromatic
id: test_monochromatic_light
name: Monochromatic Light
output: test_ledc_1
gamma_correct: 2.8
default_transition_length: 2s
effects:
- strobe:
- flicker:
- flicker:
name: My Flicker
alpha: 98%
intensity: 1.5%
- lambda:
name: My Custom Effect
update_interval: 1s
lambda: |-
static int state = 0;
state += 1;
if (state == 4)
state = 0;
- pulse:
transition_length: 10s
update_interval: 20s
min_brightness: 10%
max_brightness: 90%
- pulse:
name: pulse2
transition_length:
on_length: 10s
off_length: 5s
update_interval: 15s
min_brightness: 10%
max_brightness: 90%
- platform: rgb
id: test_rgb_light
name: RGB Light
red: test_ledc_1
green: test_ledc_2
blue: test_ledc_3
- platform: rgbw
id: test_rgbw_light
name: RGBW Light
red: test_ledc_1
green: test_ledc_2
blue: test_ledc_3
white: test_ledc_4
color_interlock: true
- platform: rgbww
id: test_rgbww_light
name: RGBWW Light
red: test_ledc_1
green: test_ledc_2
blue: test_ledc_3
cold_white: test_ledc_4
warm_white: test_ledc_5
cold_white_color_temperature: 153 mireds
warm_white_color_temperature: 500 mireds
color_interlock: true
- platform: rgbct
id: test_rgbct_light
name: RGBCT Light
red: test_ledc_1
green: test_ledc_2
blue: test_ledc_3
color_temperature: test_ledc_4
white_brightness: test_ledc_5
cold_white_color_temperature: 153 mireds
warm_white_color_temperature: 500 mireds
color_interlock: true
- platform: cwww
id: test_cwww_light
name: CWWW Light
cold_white: test_ledc_1
warm_white: test_ledc_2
cold_white_color_temperature: 153 mireds
warm_white_color_temperature: 500 mireds
constant_brightness: true
- platform: color_temperature
id: test_color_temperature_light
name: CT Light
color_temperature: test_ledc_1
brightness: test_ledc_2
cold_white_color_temperature: 153 mireds
warm_white_color_temperature: 500 mireds