import esphome.codegen as cg import esphome.config_validation as cv from esphome.components import output from esphome.const import CONF_CHANNEL, CONF_ID from . import TLC5947 DEPENDENCIES = ["tlc5947"] CODEOWNERS = ["@rnauber"] Channel = TLC5947.class_("Channel", output.FloatOutput) CONF_TLC5947_ID = "tlc5947_id" CONFIG_SCHEMA = output.FLOAT_OUTPUT_SCHEMA.extend({ cv.GenerateID(CONF_TLC5947_ID): cv.use_id(TLC5947), cv.Required(CONF_ID): cv.declare_id(Channel), cv.Required(CONF_CHANNEL): cv.int_range(min=0, max=65535), }).extend(cv.COMPONENT_SCHEMA) async def to_code(config): var = cg.new_Pvariable(config[CONF_ID]) await output.register_output(var, config) parent = await cg.get_variable(config[CONF_TLC5947_ID]) cg.add(var.set_parent(parent)) cg.add(var.set_channel(config[CONF_CHANNEL]))
from esphome.const import CONF_ID, CONF_INTENSITY, CONF_LAMBDA, CONF_NUM_CHIPS DEPENDENCIES = ["spi"] max7219_ns = cg.esphome_ns.namespace("max7219") MAX7219Component = max7219_ns.class_("MAX7219Component", cg.PollingComponent, spi.SPIDevice) MAX7219ComponentRef = MAX7219Component.operator("ref") CONF_REVERSE_ENABLE = "reverse_enable" CONFIG_SCHEMA = (display.BASIC_DISPLAY_SCHEMA.extend({ cv.GenerateID(): cv.declare_id(MAX7219Component), cv.Optional(CONF_NUM_CHIPS, default=1): cv.int_range(min=1, max=255), cv.Optional(CONF_INTENSITY, default=15): cv.int_range(min=0, max=15), cv.Optional(CONF_REVERSE_ENABLE, default=False): cv.boolean, }).extend(cv.polling_component_schema("1s")).extend(spi.spi_device_schema())) def to_code(config): var = cg.new_Pvariable(config[CONF_ID]) yield cg.register_component(var, config) yield spi.register_spi_device(var, config) yield display.register_display(var, config) cg.add(var.set_num_chips(config[CONF_NUM_CHIPS])) cg.add(var.set_intensity(config[CONF_INTENSITY]))
DEFAULT_GLYPHS = ( ' !"%()+=,-.:/0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz°' ) CONF_RAW_GLYPH_ID = "raw_glyph_id" FONT_SCHEMA = cv.Schema({ cv.Required(CONF_ID): cv.declare_id(Font), cv.Required(CONF_FILE): validate_truetype_file, cv.Optional(CONF_GLYPHS, default=DEFAULT_GLYPHS): validate_glyphs, cv.Optional(CONF_SIZE, default=20): cv.int_range(min=1), cv.GenerateID(CONF_RAW_DATA_ID): cv.declare_id(cg.uint8), cv.GenerateID(CONF_RAW_GLYPH_ID): cv.declare_id(GlyphData), }) CONFIG_SCHEMA = cv.All(validate_pillow_installed, FONT_SCHEMA) async def to_code(config): from PIL import ImageFont path = CORE.relative_config_path(config[CONF_FILE]) try: font = ImageFont.truetype(path, config[CONF_SIZE])
} ), cv.only_with_arduino, ) async def to_code(config): var = cg.new_Pvariable(config[CONF_ID]) await cg.register_component(var, config) cg.add(var.set_method(METHODS[config[CONF_METHOD]])) @register_addressable_effect( "e131", E131AddressableLightEffect, "E1.31", { cv.GenerateID(CONF_E131_ID): cv.use_id(E131Component), cv.Required(CONF_UNIVERSE): cv.int_range(min=1, max=512), cv.Optional(CONF_CHANNELS, default="RGB"): cv.one_of(*CHANNELS, upper=True), }, ) async def e131_light_effect_to_code(config, effect_id): parent = await cg.get_variable(config[CONF_E131_ID]) effect = cg.new_Pvariable(effect_id, config[CONF_NAME]) cg.add(effect.set_first_universe(config[CONF_UNIVERSE])) cg.add(effect.set_channels(CHANNELS[config[CONF_CHANNELS]])) cg.add(effect.set_e131(parent)) return effect
AUTO_LOAD = ['sensor'] CONF_CURRENT_TEMP = "current_temp" CONF_STATE_CLASS = "measurement" WavinAhc9000Climate = wavinAhc9000_ns.class_('WavinAhc9000Climate', climate.Climate, cg.Component) CONFIG_SCHEMA = climate.CLIMATE_SCHEMA.extend({ cv.GenerateID(): cv.declare_id(WavinAhc9000Climate), cv.GenerateID(CONF_WAVINAHC9000_ID): cv.use_id(WavinAhc9000), cv.Required(CONF_CHANNEL): cv.int_range(min=1, max=16), cv.Optional(CONF_BATTERY_LEVEL): sensor.sensor_schema(unit_of_measurement=UNIT_PERCENT, icon=ICON_PERCENT, device_class=DEVICE_CLASS_BATTERY), cv.Optional(CONF_CURRENT_TEMP): sensor.sensor_schema(unit_of_measurement=UNIT_CELSIUS, icon=ICON_THERMOMETER, device_class=DEVICE_CLASS_TEMPERATURE), }).extend(cv.COMPONENT_SCHEMA) def to_code(config): wavin = yield cg.get_variable(config[CONF_WAVINAHC9000_ID]) var = cg.new_Pvariable(config[CONF_ID], wavin) yield cg.register_component(var, config)