From 4f9bfae7b0ff0495b4f5cfc290e78744891c5f1c Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Wed, 7 Jun 2023 18:49:13 -0500 Subject: [PATCH] cleanups --- components/ratgdo/__init__.py | 1 + components/ratgdo/binary_sensor/__init__.py | 20 ++++++++--------- components/ratgdo/button/__init__.py | 24 ++++++++++----------- components/ratgdo/cover/__init__.py | 14 +++++------- components/ratgdo/light/__init__.py | 12 +++++------ components/ratgdo/number/__init__.py | 24 ++++++++++----------- 6 files changed, 43 insertions(+), 52 deletions(-) diff --git a/components/ratgdo/__init__.py b/components/ratgdo/__init__.py index 915572e..dee5d21 100644 --- a/components/ratgdo/__init__.py +++ b/components/ratgdo/__init__.py @@ -78,6 +78,7 @@ RATGDO_CLIENT_SCHMEA = cv.Schema( } ) + async def register_ratgdo_child(var, config): parent = await cg.get_variable(config[CONF_RATGDO_ID]) cg.add(parent.register_child(var)) diff --git a/components/ratgdo/binary_sensor/__init__.py b/components/ratgdo/binary_sensor/__init__.py index a42c673..c6c102c 100644 --- a/components/ratgdo/binary_sensor/__init__.py +++ b/components/ratgdo/binary_sensor/__init__.py @@ -2,11 +2,7 @@ import esphome.codegen as cg import esphome.config_validation as cv from esphome.const import CONF_ID from esphome.components import binary_sensor -from .. import ( - ratgdo_ns, - register_ratgdo_child, - RATGDO_CLIENT_SCHMEA -) +from .. import ratgdo_ns, register_ratgdo_child, RATGDO_CLIENT_SCHMEA DEPENDENCIES = ["ratgdo"] @@ -22,11 +18,15 @@ TYPES = { } -CONFIG_SCHEMA = binary_sensor.binary_sensor_schema(RATGDOBinarySensor).extend( - { - cv.Required(CONF_TYPE): cv.enum(TYPES, lower=True), - } -).extend(RATGDO_CLIENT_SCHMEA) +CONFIG_SCHEMA = ( + binary_sensor.binary_sensor_schema(RATGDOBinarySensor) + .extend( + { + cv.Required(CONF_TYPE): cv.enum(TYPES, lower=True), + } + ) + .extend(RATGDO_CLIENT_SCHMEA) +) async def to_code(config): diff --git a/components/ratgdo/button/__init__.py b/components/ratgdo/button/__init__.py index 2989d39..a75b332 100644 --- a/components/ratgdo/button/__init__.py +++ b/components/ratgdo/button/__init__.py @@ -2,17 +2,11 @@ import esphome.codegen as cg import esphome.config_validation as cv from esphome.const import CONF_ID from esphome.components import button -from .. import ( - ratgdo_ns, - register_ratgdo_child, - RATGDO_CLIENT_SCHMEA -) +from .. import ratgdo_ns, register_ratgdo_child, RATGDO_CLIENT_SCHMEA DEPENDENCIES = ["ratgdo"] -RATGDOButton = ratgdo_ns.class_( - "RATGDOButton", button.Button, cg.Component -) +RATGDOButton = ratgdo_ns.class_("RATGDOButton", button.Button, cg.Component) ButtonType = ratgdo_ns.enum("ButtonType") CONF_TYPE = "type" @@ -21,11 +15,15 @@ TYPES = { } -CONFIG_SCHEMA = button.button_schema(RATGDOButton).extend( - { - cv.Required(CONF_TYPE): cv.enum(TYPES, lower=True), - } -).extend(RATGDO_CLIENT_SCHMEA) +CONFIG_SCHEMA = ( + button.button_schema(RATGDOButton) + .extend( + { + cv.Required(CONF_TYPE): cv.enum(TYPES, lower=True), + } + ) + .extend(RATGDO_CLIENT_SCHMEA) +) async def to_code(config): diff --git a/components/ratgdo/cover/__init__.py b/components/ratgdo/cover/__init__.py index a8141d3..57093a6 100644 --- a/components/ratgdo/cover/__init__.py +++ b/components/ratgdo/cover/__init__.py @@ -3,20 +3,16 @@ from esphome.const import CONF_ID import esphome.config_validation as cv from esphome.components import cover -from .. import ( - ratgdo_ns, - register_ratgdo_child, - RATGDO_CLIENT_SCHMEA -) +from .. import ratgdo_ns, register_ratgdo_child, RATGDO_CLIENT_SCHMEA DEPENDENCIES = ["ratgdo"] -RATGDOCover = ratgdo_ns.class_( - "RATGDOCover", cover.Cover, cg.Component -) +RATGDOCover = ratgdo_ns.class_("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): diff --git a/components/ratgdo/light/__init__.py b/components/ratgdo/light/__init__.py index b371a67..64ed48d 100644 --- a/components/ratgdo/light/__init__.py +++ b/components/ratgdo/light/__init__.py @@ -1,14 +1,10 @@ import esphome.codegen as cg import esphome.config_validation as cv from esphome.const import ( - CONF_OUTPUT_ID, # New in 2023.5 + CONF_OUTPUT_ID, # New in 2023.5 ) from esphome.components import light -from .. import ( - ratgdo_ns, - register_ratgdo_child, - RATGDO_CLIENT_SCHMEA -) +from .. import ratgdo_ns, register_ratgdo_child, RATGDO_CLIENT_SCHMEA 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): diff --git a/components/ratgdo/number/__init__.py b/components/ratgdo/number/__init__.py index 26aeeee..cf2e440 100644 --- a/components/ratgdo/number/__init__.py +++ b/components/ratgdo/number/__init__.py @@ -2,17 +2,11 @@ import esphome.codegen as cg import esphome.config_validation as cv from esphome.const import CONF_ID from esphome.components import number -from .. import ( - ratgdo_ns, - register_ratgdo_child, - RATGDO_CLIENT_SCHMEA -) +from .. import ratgdo_ns, register_ratgdo_child, RATGDO_CLIENT_SCHMEA DEPENDENCIES = ["ratgdo"] -RATGDONumber = ratgdo_ns.class_( - "RATGDONumber", number.Number, cg.Component -) +RATGDONumber = ratgdo_ns.class_("RATGDONumber", number.Number, cg.Component) NumberType = ratgdo_ns.enum("NumberType") CONF_TYPE = "type" @@ -21,11 +15,15 @@ TYPES = { } -CONFIG_SCHEMA = number.number_schema(RATGDONumber).extend( - { - cv.Required(CONF_TYPE): cv.enum(TYPES, lower=True), - } -).extend(RATGDO_CLIENT_SCHMEA) +CONFIG_SCHEMA = ( + number.number_schema(RATGDONumber) + .extend( + { + cv.Required(CONF_TYPE): cv.enum(TYPES, lower=True), + } + ) + .extend(RATGDO_CLIENT_SCHMEA) +) async def to_code(config):