22 lines
834 B
Python
22 lines
834 B
Python
import esphome.codegen as cg
|
|
import esphome.config_validation as cv
|
|
from esphome.components import output, light
|
|
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)
|
|
CONF_STATE_CALLBACK = "state_callback"
|
|
|
|
CONFIG_SCHEMA = output.BINARY_OUTPUT_SCHEMA.extend({
|
|
cv.GenerateID(CONF_ID): cv.declare_id(HoermannCoverLight),
|
|
cv.Required(CONF_STATE_CALLBACK): cv.use_id(light.LightState)
|
|
}).extend(cv.COMPONENT_SCHEMA)
|
|
|
|
|
|
def to_code(config):
|
|
var = cg.new_Pvariable(config[CONF_ID])
|
|
yield cg.register_component(var, config)
|
|
yield output.register_output(var, config)
|
|
|
|
callback = yield cg.get_variable(config[CONF_STATE_CALLBACK])
|
|
cg.add(var.set_state_callback(callback)) |