diff --git a/esphome/components/graphical_layout/__init__.py b/esphome/components/graphical_layout/__init__.py index 30cd3f0b72..12c0797fab 100644 --- a/esphome/components/graphical_layout/__init__.py +++ b/esphome/components/graphical_layout/__init__.py @@ -28,26 +28,26 @@ def item_type_schema(value): ITEM_TYPE_SCHEMA = cv.typed_schema( { - text_panel.CONF_TYPE: text_panel.get_config_schema( + text_panel.CONF_TEXT_PANEL: text_panel.get_config_schema( BASE_ITEM_SCHEMA, item_type_schema ), - horizontal_stack.CONF_TYPE: horizontal_stack.get_config_schema( + horizontal_stack.CONF_HORIZONTAL_STACK: horizontal_stack.get_config_schema( BASE_ITEM_SCHEMA, item_type_schema ), - vertical_stack.CONF_TYPE: vertical_stack.get_config_schema( + vertical_stack.CONF_VERTICAL_STACK: vertical_stack.get_config_schema( BASE_ITEM_SCHEMA, item_type_schema ), - display_rendering_panel.CONF_TYPE: display_rendering_panel.get_config_schema( + display_rendering_panel.CONF_DISPLAY_RENDERING_PANEL: display_rendering_panel.get_config_schema( BASE_ITEM_SCHEMA, item_type_schema ), } ) CODE_GENERATORS = { - text_panel.CONF_TYPE: text_panel.config_to_layout_item, - horizontal_stack.CONF_TYPE: horizontal_stack.config_to_layout_item, - vertical_stack.CONF_TYPE: vertical_stack.config_to_layout_item, - display_rendering_panel.CONF_TYPE: display_rendering_panel.config_to_layout_item, + text_panel.CONF_TEXT_PANEL: text_panel.config_to_layout_item, + horizontal_stack.CONF_HORIZONTAL_STACK: horizontal_stack.config_to_layout_item, + vertical_stack.CONF_VERTICAL_STACK: vertical_stack.config_to_layout_item, + display_rendering_panel.CONF_DISPLAY_RENDERING_PANEL: display_rendering_panel.config_to_layout_item, } CONFIG_SCHEMA = cv.Schema( diff --git a/esphome/components/graphical_layout/display_rendering_panel.py b/esphome/components/graphical_layout/display_rendering_panel.py index 1ec4dba884..c44c154888 100644 --- a/esphome/components/graphical_layout/display_rendering_panel.py +++ b/esphome/components/graphical_layout/display_rendering_panel.py @@ -6,7 +6,7 @@ from esphome.components.display import DisplayRef graphical_layout_ns = cg.esphome_ns.namespace("graphical_layout") DisplayRenderingPanel = graphical_layout_ns.class_("DisplayRenderingPanel") -CONF_TYPE = "display_rendering_panel" +CONF_DISPLAY_RENDERING_PANEL = "display_rendering_panel" def get_config_schema(base_item_schema, item_type_schema): diff --git a/esphome/components/graphical_layout/horizontal_stack.py b/esphome/components/graphical_layout/horizontal_stack.py index 584ce640f8..3b755073f5 100644 --- a/esphome/components/graphical_layout/horizontal_stack.py +++ b/esphome/components/graphical_layout/horizontal_stack.py @@ -1,14 +1,13 @@ import esphome.codegen as cg import esphome.config_validation as cv -from esphome.const import CONF_ID +from esphome.const import CONF_ID, CONF_TYPE graphical_layout_ns = cg.esphome_ns.namespace("graphical_layout") HorizontalStack = graphical_layout_ns.class_("HorizontalStack") CONF_ITEM_PADDING = "item_padding" -CONF_TYPE = "horizontal_stack" +CONF_HORIZONTAL_STACK = "horizontal_stack" CONF_ITEMS = "items" -CONF_TYPE_KEY = "type" def get_config_schema(base_item_schema, item_type_schema): @@ -30,7 +29,7 @@ async def config_to_layout_item(item_config, child_item_builder): cg.add(var.set_item_padding(item_padding_config)) for child_item_config in item_config[CONF_ITEMS]: - child_item_type = child_item_config[CONF_TYPE_KEY] + child_item_type = child_item_config[CONF_TYPE] if child_item_type in child_item_builder: child_item_var = await child_item_builder[child_item_type]( child_item_config, child_item_builder diff --git a/esphome/components/graphical_layout/text_panel.py b/esphome/components/graphical_layout/text_panel.py index e2b9ffd85d..88709424e2 100644 --- a/esphome/components/graphical_layout/text_panel.py +++ b/esphome/components/graphical_layout/text_panel.py @@ -7,7 +7,7 @@ graphical_layout_ns = cg.esphome_ns.namespace("graphical_layout") TextPanel = graphical_layout_ns.class_("TextPanel") CONF_ITEM_PADDING = "item_padding" -CONF_TYPE = "text_panel" +CONF_TEXT_PANEL = "text_panel" CONF_FONT = "font" CONF_FOREGROUND_COLOR = "foreground_color" CONF_BACKGROUND_COLOR = "background_color" @@ -18,9 +18,7 @@ def get_config_schema(base_item_schema, item_type_schema): return base_item_schema.extend( { cv.GenerateID(): cv.declare_id(TextPanel), - cv.Optional(CONF_ITEM_PADDING, default=0): cv.templatable( - cv.int_ - ), + cv.Optional(CONF_ITEM_PADDING, default=0): cv.templatable(cv.int_), cv.Required(CONF_FONT): cv.use_id(font.Font), cv.Optional(CONF_FOREGROUND_COLOR): cv.use_id(color.ColorStruct), cv.Optional(CONF_BACKGROUND_COLOR): cv.use_id(color.ColorStruct), diff --git a/esphome/components/graphical_layout/vertical_stack.py b/esphome/components/graphical_layout/vertical_stack.py index 1406269a4f..1ea566f16b 100644 --- a/esphome/components/graphical_layout/vertical_stack.py +++ b/esphome/components/graphical_layout/vertical_stack.py @@ -1,14 +1,13 @@ import esphome.codegen as cg import esphome.config_validation as cv -from esphome.const import CONF_ID +from esphome.const import CONF_ID, CONF_TYPE graphical_layout_ns = cg.esphome_ns.namespace("graphical_layout") VerticalStack = graphical_layout_ns.class_("VerticalStack") CONF_ITEM_PADDING = "item_padding" -CONF_TYPE = "vertical_stack" +CONF_VERTICAL_STACK = "vertical_stack" CONF_ITEMS = "items" -CONF_TYPE_KEY = "type" def get_config_schema(base_item_schema, item_type_schema): @@ -30,7 +29,7 @@ async def config_to_layout_item(item_config, child_item_builder): cg.add(var.set_item_padding(item_padding_config)) for child_item_config in item_config[CONF_ITEMS]: - child_item_type = child_item_config[CONF_TYPE_KEY] + child_item_type = child_item_config[CONF_TYPE] if child_item_type in child_item_builder: child_item_var = await child_item_builder[child_item_type]( child_item_config, child_item_builder