You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

28 lines
892 B

  1. import esphome.codegen as cg
  2. import esphome.config_validation as cv
  3. from esphome.components import output
  4. from esphome.const import CONF_ID
  5. from .. import (
  6. bs2_ns, CODEOWNERS,
  7. CONF_FRONT_PANEL_HAL_ID, FrontPanelHAL
  8. )
  9. AUTO_LOAD = ["yeelight_bs2"]
  10. YeelightBS2FrontPanelLight = bs2_ns.class_(
  11. "YeelightBS2FrontPanelLight", output.FloatOutput, cg.Component)
  12. CONFIG_SCHEMA = output.FLOAT_OUTPUT_SCHEMA.extend(
  13. {
  14. cv.GenerateID(): cv.declare_id(YeelightBS2FrontPanelLight),
  15. cv.GenerateID(CONF_FRONT_PANEL_HAL_ID): cv.use_id(FrontPanelHAL),
  16. }
  17. ).extend(cv.COMPONENT_SCHEMA)
  18. def to_code(config):
  19. var = cg.new_Pvariable(config[CONF_ID])
  20. yield cg.register_component(var, config)
  21. yield output.register_output(var, config)
  22. front_panel_hal_var = yield cg.get_variable(config[CONF_FRONT_PANEL_HAL_ID])
  23. cg.add(var.set_parent(front_panel_hal_var))