espHome-NBS-files/external_components/hoermann_door/output.py

24 lines
887 B
Python
Raw Normal View History

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])
2024-05-02 10:17:43 +00:00
cg.add(var.set_state_callback(callback))
cg.add_library("plerup/EspSoftwareSerial", "8.2.0")