This commit is contained in:
J. Nick Koston 2023-06-07 18:49:13 -05:00
parent c27337b8b0
commit 4f9bfae7b0
No known key found for this signature in database
6 changed files with 43 additions and 52 deletions

View File

@ -78,6 +78,7 @@ RATGDO_CLIENT_SCHMEA = cv.Schema(
} }
) )
async def register_ratgdo_child(var, config): async def register_ratgdo_child(var, config):
parent = await cg.get_variable(config[CONF_RATGDO_ID]) parent = await cg.get_variable(config[CONF_RATGDO_ID])
cg.add(parent.register_child(var)) cg.add(parent.register_child(var))

View File

@ -2,11 +2,7 @@ import esphome.codegen as cg
import esphome.config_validation as cv import esphome.config_validation as cv
from esphome.const import CONF_ID from esphome.const import CONF_ID
from esphome.components import binary_sensor from esphome.components import binary_sensor
from .. import ( from .. import ratgdo_ns, register_ratgdo_child, RATGDO_CLIENT_SCHMEA
ratgdo_ns,
register_ratgdo_child,
RATGDO_CLIENT_SCHMEA
)
DEPENDENCIES = ["ratgdo"] DEPENDENCIES = ["ratgdo"]
@ -22,11 +18,15 @@ TYPES = {
} }
CONFIG_SCHEMA = binary_sensor.binary_sensor_schema(RATGDOBinarySensor).extend( CONFIG_SCHEMA = (
{ binary_sensor.binary_sensor_schema(RATGDOBinarySensor)
cv.Required(CONF_TYPE): cv.enum(TYPES, lower=True), .extend(
} {
).extend(RATGDO_CLIENT_SCHMEA) cv.Required(CONF_TYPE): cv.enum(TYPES, lower=True),
}
)
.extend(RATGDO_CLIENT_SCHMEA)
)
async def to_code(config): async def to_code(config):

View File

@ -2,17 +2,11 @@ import esphome.codegen as cg
import esphome.config_validation as cv import esphome.config_validation as cv
from esphome.const import CONF_ID from esphome.const import CONF_ID
from esphome.components import button from esphome.components import button
from .. import ( from .. import ratgdo_ns, register_ratgdo_child, RATGDO_CLIENT_SCHMEA
ratgdo_ns,
register_ratgdo_child,
RATGDO_CLIENT_SCHMEA
)
DEPENDENCIES = ["ratgdo"] DEPENDENCIES = ["ratgdo"]
RATGDOButton = ratgdo_ns.class_( RATGDOButton = ratgdo_ns.class_("RATGDOButton", button.Button, cg.Component)
"RATGDOButton", button.Button, cg.Component
)
ButtonType = ratgdo_ns.enum("ButtonType") ButtonType = ratgdo_ns.enum("ButtonType")
CONF_TYPE = "type" CONF_TYPE = "type"
@ -21,11 +15,15 @@ TYPES = {
} }
CONFIG_SCHEMA = button.button_schema(RATGDOButton).extend( CONFIG_SCHEMA = (
{ button.button_schema(RATGDOButton)
cv.Required(CONF_TYPE): cv.enum(TYPES, lower=True), .extend(
} {
).extend(RATGDO_CLIENT_SCHMEA) cv.Required(CONF_TYPE): cv.enum(TYPES, lower=True),
}
)
.extend(RATGDO_CLIENT_SCHMEA)
)
async def to_code(config): async def to_code(config):

View File

@ -3,20 +3,16 @@ from esphome.const import CONF_ID
import esphome.config_validation as cv import esphome.config_validation as cv
from esphome.components import cover from esphome.components import cover
from .. import ( from .. import ratgdo_ns, register_ratgdo_child, RATGDO_CLIENT_SCHMEA
ratgdo_ns,
register_ratgdo_child,
RATGDO_CLIENT_SCHMEA
)
DEPENDENCIES = ["ratgdo"] DEPENDENCIES = ["ratgdo"]
RATGDOCover = ratgdo_ns.class_( RATGDOCover = ratgdo_ns.class_("RATGDOCover", cover.Cover, cg.Component)
"RATGDOCover", cover.Cover, cg.Component
)
CONFIG_SCHEMA = cover.COVER_SCHEMA.extend({cv.GenerateID(): cv.declare_id(RATGDOCover)}).extend(RATGDO_CLIENT_SCHMEA) CONFIG_SCHEMA = cover.COVER_SCHEMA.extend(
{cv.GenerateID(): cv.declare_id(RATGDOCover)}
).extend(RATGDO_CLIENT_SCHMEA)
async def to_code(config): async def to_code(config):

View File

@ -1,14 +1,10 @@
import esphome.codegen as cg import esphome.codegen as cg
import esphome.config_validation as cv import esphome.config_validation as cv
from esphome.const import ( from esphome.const import (
CONF_OUTPUT_ID, # New in 2023.5 CONF_OUTPUT_ID, # New in 2023.5
) )
from esphome.components import light from esphome.components import light
from .. import ( from .. import ratgdo_ns, register_ratgdo_child, RATGDO_CLIENT_SCHMEA
ratgdo_ns,
register_ratgdo_child,
RATGDO_CLIENT_SCHMEA
)
DEPENDENCIES = ["ratgdo"] DEPENDENCIES = ["ratgdo"]
@ -17,7 +13,9 @@ RATGDOLightOutput = ratgdo_ns.class_(
) )
CONFIG_SCHEMA = light.LIGHT_SCHEMA.extend({cv.GenerateID(CONF_OUTPUT_ID): cv.declare_id(RATGDOLightOutput)}).extend(RATGDO_CLIENT_SCHMEA) CONFIG_SCHEMA = light.LIGHT_SCHEMA.extend(
{cv.GenerateID(CONF_OUTPUT_ID): cv.declare_id(RATGDOLightOutput)}
).extend(RATGDO_CLIENT_SCHMEA)
async def to_code(config): async def to_code(config):

View File

@ -2,17 +2,11 @@ import esphome.codegen as cg
import esphome.config_validation as cv import esphome.config_validation as cv
from esphome.const import CONF_ID from esphome.const import CONF_ID
from esphome.components import number from esphome.components import number
from .. import ( from .. import ratgdo_ns, register_ratgdo_child, RATGDO_CLIENT_SCHMEA
ratgdo_ns,
register_ratgdo_child,
RATGDO_CLIENT_SCHMEA
)
DEPENDENCIES = ["ratgdo"] DEPENDENCIES = ["ratgdo"]
RATGDONumber = ratgdo_ns.class_( RATGDONumber = ratgdo_ns.class_("RATGDONumber", number.Number, cg.Component)
"RATGDONumber", number.Number, cg.Component
)
NumberType = ratgdo_ns.enum("NumberType") NumberType = ratgdo_ns.enum("NumberType")
CONF_TYPE = "type" CONF_TYPE = "type"
@ -21,11 +15,15 @@ TYPES = {
} }
CONFIG_SCHEMA = number.number_schema(RATGDONumber).extend( CONFIG_SCHEMA = (
{ number.number_schema(RATGDONumber)
cv.Required(CONF_TYPE): cv.enum(TYPES, lower=True), .extend(
} {
).extend(RATGDO_CLIENT_SCHMEA) cv.Required(CONF_TYPE): cv.enum(TYPES, lower=True),
}
)
.extend(RATGDO_CLIENT_SCHMEA)
)
async def to_code(config): async def to_code(config):