mirror of
https://github.com/esphome/esphome.git
synced 2024-11-10 09:17:46 +01:00
Add test for automation light effect
This commit is contained in:
parent
4bc3067725
commit
4323ca88c3
3 changed files with 19 additions and 4 deletions
|
@ -4,7 +4,7 @@ from esphome import automation
|
||||||
from esphome.const import CONF_NAME, CONF_LAMBDA, CONF_UPDATE_INTERVAL, CONF_TRANSITION_LENGTH, \
|
from esphome.const import CONF_NAME, CONF_LAMBDA, CONF_UPDATE_INTERVAL, CONF_TRANSITION_LENGTH, \
|
||||||
CONF_COLORS, CONF_STATE, CONF_DURATION, CONF_BRIGHTNESS, CONF_RED, CONF_GREEN, CONF_BLUE, \
|
CONF_COLORS, CONF_STATE, CONF_DURATION, CONF_BRIGHTNESS, CONF_RED, CONF_GREEN, CONF_BLUE, \
|
||||||
CONF_WHITE, CONF_ALPHA, CONF_INTENSITY, CONF_SPEED, CONF_WIDTH, CONF_NUM_LEDS, CONF_RANDOM, \
|
CONF_WHITE, CONF_ALPHA, CONF_INTENSITY, CONF_SPEED, CONF_WIDTH, CONF_NUM_LEDS, CONF_RANDOM, \
|
||||||
CONF_THEN
|
CONF_THEN, CONF_SEQUENCE
|
||||||
from esphome.util import Registry
|
from esphome.util import Registry
|
||||||
from .types import LambdaLightEffect, RandomLightEffect, StrobeLightEffect, \
|
from .types import LambdaLightEffect, RandomLightEffect, StrobeLightEffect, \
|
||||||
StrobeLightEffectColor, LightColorValues, AddressableLightRef, AddressableLambdaLightEffect, \
|
StrobeLightEffectColor, LightColorValues, AddressableLightRef, AddressableLambdaLightEffect, \
|
||||||
|
@ -63,11 +63,11 @@ def lambda_effect_to_code(config, effect_id):
|
||||||
|
|
||||||
|
|
||||||
@register_effect('automation', AutomationLightEffect, "Automation", {
|
@register_effect('automation', AutomationLightEffect, "Automation", {
|
||||||
cv.Required(CONF_THEN): automation.validate_automation(single=True),
|
cv.Required(CONF_SEQUENCE): automation.validate_automation(single=True),
|
||||||
})
|
})
|
||||||
def automation_effect_to_code(config, effect_id):
|
def automation_effect_to_code(config, effect_id):
|
||||||
var = yield cg.new_Pvariable(effect_id, config[CONF_NAME])
|
var = yield cg.new_Pvariable(effect_id, config[CONF_NAME])
|
||||||
yield automation.build_automation(var.get_trig(), [], config[CONF_THEN])
|
yield automation.build_automation(var.get_trig(), [], config[CONF_SEQUENCE])
|
||||||
yield var
|
yield var
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -366,6 +366,7 @@ CONF_SERVICE = 'service'
|
||||||
CONF_SERVICES = 'services'
|
CONF_SERVICES = 'services'
|
||||||
CONF_SETUP_MODE = 'setup_mode'
|
CONF_SETUP_MODE = 'setup_mode'
|
||||||
CONF_SETUP_PRIORITY = 'setup_priority'
|
CONF_SETUP_PRIORITY = 'setup_priority'
|
||||||
|
CONF_SEQUENCE = 'sequence'
|
||||||
CONF_SHUNT_RESISTANCE = 'shunt_resistance'
|
CONF_SHUNT_RESISTANCE = 'shunt_resistance'
|
||||||
CONF_SHUNT_VOLTAGE = 'shunt_voltage'
|
CONF_SHUNT_VOLTAGE = 'shunt_voltage'
|
||||||
CONF_SHUTDOWN_MESSAGE = 'shutdown_message'
|
CONF_SHUTDOWN_MESSAGE = 'shutdown_message'
|
||||||
|
|
|
@ -17,7 +17,7 @@ esphome:
|
||||||
ESP_LOGV("main", "ON LOOP!");
|
ESP_LOGV("main", "ON LOOP!");
|
||||||
- light.addressable_set:
|
- light.addressable_set:
|
||||||
id: addr1
|
id: addr1
|
||||||
range_from: 1
|
range_from: 0
|
||||||
range_to: 100
|
range_to: 100
|
||||||
red: 100%
|
red: 100%
|
||||||
green: !lambda 'return 255;'
|
green: !lambda 'return 255;'
|
||||||
|
@ -839,6 +839,20 @@ light:
|
||||||
name: Flicker Effect With Custom Values
|
name: Flicker Effect With Custom Values
|
||||||
update_interval: 16ms
|
update_interval: 16ms
|
||||||
intensity: 5%
|
intensity: 5%
|
||||||
|
- automation:
|
||||||
|
name: Custom Effect
|
||||||
|
sequence:
|
||||||
|
- light.addressable_set:
|
||||||
|
id: addr1
|
||||||
|
red: 100%
|
||||||
|
green: 100%
|
||||||
|
blue: 0%
|
||||||
|
- delay: 100ms
|
||||||
|
- light.addressable_set:
|
||||||
|
id: addr1
|
||||||
|
red: 0%
|
||||||
|
green: 100%
|
||||||
|
blue: 0%
|
||||||
- platform: fastled_spi
|
- platform: fastled_spi
|
||||||
id: addr2
|
id: addr2
|
||||||
chipset: WS2801
|
chipset: WS2801
|
||||||
|
|
Loading…
Reference in a new issue