2024-04-26 19:02:48 +00:00
|
|
|
import esphome.codegen as cg
|
|
|
|
import esphome.config_validation as cv
|
2024-04-29 11:49:12 +00:00
|
|
|
from esphome.components import output, light
|
2024-04-26 19:02:48 +00:00
|
|
|
from esphome.const import CONF_ID
|
|
|
|
|
|
|
|
hoermann_cover_ns = cg.esphome_ns.namespace('hoermann_door')
|
|
|
|
HoermannCoverLight = hoermann_cover_ns.class_('NbsLightOutput', output.BinaryOutput, cg.Component)
|
2024-04-29 11:49:12 +00:00
|
|
|
CONF_STATE_CALLBACK = "state_callback"
|
2024-04-26 19:02:48 +00:00
|
|
|
|
|
|
|
CONFIG_SCHEMA = output.BINARY_OUTPUT_SCHEMA.extend({
|
2024-04-29 11:49:12 +00:00
|
|
|
cv.GenerateID(CONF_ID): cv.declare_id(HoermannCoverLight),
|
|
|
|
cv.Required(CONF_STATE_CALLBACK): cv.use_id(light.LightState)
|
2024-04-26 19:02:48 +00:00
|
|
|
}).extend(cv.COMPONENT_SCHEMA)
|
|
|
|
|
|
|
|
|
|
|
|
def to_code(config):
|
|
|
|
var = cg.new_Pvariable(config[CONF_ID])
|
|
|
|
yield cg.register_component(var, config)
|
2024-04-29 11:49:12 +00:00
|
|
|
yield output.register_output(var, config)
|
|
|
|
|
|
|
|
callback = yield cg.get_variable(config[CONF_STATE_CALLBACK])
|
|
|
|
cg.add(var.set_state_callback(callback))
|