From 991700af2a323c91bc0d848abf1556a719bdc218 Mon Sep 17 00:00:00 2001 From: clydebarrow <2366188+clydebarrow@users.noreply.github.com> Date: Sat, 23 Nov 2024 18:20:07 +1100 Subject: [PATCH] Generalise image requirements --- esphome/components/lvgl/lv_validation.py | 3 ++- esphome/components/lvgl/schemas.py | 7 +------ 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/esphome/components/lvgl/lv_validation.py b/esphome/components/lvgl/lv_validation.py index b91b0905df..766c010244 100644 --- a/esphome/components/lvgl/lv_validation.py +++ b/esphome/components/lvgl/lv_validation.py @@ -30,7 +30,7 @@ from .defines import ( call_lambda, literal, ) -from .helpers import esphome_fonts_used, lv_fonts_used, requires_component +from .helpers import add_lv_use, esphome_fonts_used, lv_fonts_used, requires_component from .types import lv_font_t, lv_gradient_t, lv_img_t opacity_consts = LvConstant("LV_OPA_", "TRANSP", "COVER") @@ -326,6 +326,7 @@ def image_validator(value): value = requires_component("image")(value) value = cv.use_id(Image_)(value) lv_images_used.add(value) + add_lv_use("img", "label") return value diff --git a/esphome/components/lvgl/schemas.py b/esphome/components/lvgl/schemas.py index 1b78be8ad5..3f56b3345f 100644 --- a/esphome/components/lvgl/schemas.py +++ b/esphome/components/lvgl/schemas.py @@ -342,14 +342,9 @@ FLEX_OBJ_SCHEMA = { } -def bg_image_validator(value): - add_lv_use("img", "label") - return lv_image(value) - - DISP_BG_SCHEMA = cv.Schema( { - cv.Optional(df.CONF_DISP_BG_IMAGE): bg_image_validator, + cv.Optional(df.CONF_DISP_BG_IMAGE): lv_image, cv.Optional(df.CONF_DISP_BG_COLOR): lv_color, } )