2020-06-13 01:34:38 +02:00
|
|
|
import esphome.codegen as cg
|
|
|
|
import esphome.config_validation as cv
|
|
|
|
from esphome.components import uart
|
|
|
|
from esphome.components.light.types import AddressableLightEffect
|
|
|
|
from esphome.components.light.effects import register_addressable_effect
|
|
|
|
from esphome.const import CONF_NAME, CONF_UART_ID
|
|
|
|
|
2021-03-07 20:03:16 +01:00
|
|
|
DEPENDENCIES = ["uart"]
|
2020-06-13 01:34:38 +02:00
|
|
|
|
2021-03-07 20:03:16 +01:00
|
|
|
adalight_ns = cg.esphome_ns.namespace("adalight")
|
2020-06-13 01:34:38 +02:00
|
|
|
AdalightLightEffect = adalight_ns.class_(
|
2021-03-07 20:03:16 +01:00
|
|
|
"AdalightLightEffect", uart.UARTDevice, AddressableLightEffect
|
|
|
|
)
|
2020-06-13 01:34:38 +02:00
|
|
|
|
|
|
|
CONFIG_SCHEMA = cv.Schema({})
|
|
|
|
|
|
|
|
|
2021-03-07 20:03:16 +01:00
|
|
|
@register_addressable_effect(
|
|
|
|
"adalight",
|
|
|
|
AdalightLightEffect,
|
|
|
|
"Adalight",
|
|
|
|
{cv.GenerateID(CONF_UART_ID): cv.use_id(uart.UARTComponent)},
|
|
|
|
)
|
2021-05-24 21:45:31 +02:00
|
|
|
async def adalight_light_effect_to_code(config, effect_id):
|
2020-06-13 01:34:38 +02:00
|
|
|
effect = cg.new_Pvariable(effect_id, config[CONF_NAME])
|
2021-05-24 21:45:31 +02:00
|
|
|
await uart.register_uart_device(effect, config)
|
|
|
|
return effect
|