Add monochromatic effects: Pulse, Random (#1616)

This commit is contained in:
Christian Ferbar
2021-04-28 05:05:04 +02:00
committed by GitHub
parent 6d3ccf4df5
commit cc43e01e34
3 changed files with 65 additions and 5 deletions
+22 -1
View File
@@ -26,6 +26,7 @@ from esphome.const import (
from esphome.util import Registry
from .types import (
LambdaLightEffect,
PulseLightEffect,
RandomLightEffect,
StrobeLightEffect,
StrobeLightEffectColor,
@@ -152,7 +153,27 @@ def automation_effect_to_code(config, effect_id):
yield var
@register_rgb_effect(
@register_monochromatic_effect(
"pulse",
PulseLightEffect,
"Pulse",
{
cv.Optional(
CONF_TRANSITION_LENGTH, default="1s"
): cv.positive_time_period_milliseconds,
cv.Optional(
CONF_UPDATE_INTERVAL, default="1s"
): cv.positive_time_period_milliseconds,
},
)
def pulse_effect_to_code(config, effect_id):
effect = cg.new_Pvariable(effect_id, config[CONF_NAME])
cg.add(effect.set_transition_length(config[CONF_TRANSITION_LENGTH]))
cg.add(effect.set_update_interval(config[CONF_UPDATE_INTERVAL]))
yield effect
@register_monochromatic_effect(
"random",
RandomLightEffect,
"Random",