Add test for automation light effect

This commit is contained in:
Otto Winter 2019-05-27 19:35:36 +02:00
parent 4bc3067725
commit 4323ca88c3
No known key found for this signature in database
GPG key ID: DB66C0BE6013F97E
3 changed files with 19 additions and 4 deletions

View file

@ -4,7 +4,7 @@ from esphome import automation
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_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 .types import LambdaLightEffect, RandomLightEffect, StrobeLightEffect, \
StrobeLightEffectColor, LightColorValues, AddressableLightRef, AddressableLambdaLightEffect, \
@ -63,11 +63,11 @@ def lambda_effect_to_code(config, effect_id):
@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):
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

View file

@ -366,6 +366,7 @@ CONF_SERVICE = 'service'
CONF_SERVICES = 'services'
CONF_SETUP_MODE = 'setup_mode'
CONF_SETUP_PRIORITY = 'setup_priority'
CONF_SEQUENCE = 'sequence'
CONF_SHUNT_RESISTANCE = 'shunt_resistance'
CONF_SHUNT_VOLTAGE = 'shunt_voltage'
CONF_SHUTDOWN_MESSAGE = 'shutdown_message'

View file

@ -17,7 +17,7 @@ esphome:
ESP_LOGV("main", "ON LOOP!");
- light.addressable_set:
id: addr1
range_from: 1
range_from: 0
range_to: 100
red: 100%
green: !lambda 'return 255;'
@ -839,6 +839,20 @@ light:
name: Flicker Effect With Custom Values
update_interval: 16ms
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
id: addr2
chipset: WS2801