From f8def4812ef97896c9a47fa9f3522dcdc4686108 Mon Sep 17 00:00:00 2001 From: DJGummikuh Date: Wed, 14 Aug 2024 12:56:54 +0000 Subject: [PATCH] Adding contingency to only allow num_segments to a whitelist of displays --- esphome/components/waveshare_epaper/display.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/esphome/components/waveshare_epaper/display.py b/esphome/components/waveshare_epaper/display.py index 5edd521c3e..913b7662c6 100644 --- a/esphome/components/waveshare_epaper/display.py +++ b/esphome/components/waveshare_epaper/display.py @@ -144,6 +144,7 @@ MODELS = { } RESET_PIN_REQUIRED_MODELS = ("2.13inv2", "2.13in-ttgo-b74") +SEGMENT_UPDATEABLE_MODELS = "7.5in-bgr-gd" def validate_full_update_every_only_types_ac(value): @@ -161,6 +162,16 @@ def validate_full_update_every_only_types_ac(value): return value +def validate_num_segments_supported(config): + if config[CONF_MODEL] not in SEGMENT_UPDATEABLE_MODELS and ( + CONF_NUM_SEGMENTS_X in config or CONF_NUM_SEGMENTS_Y in config + ): + raise cv.Invalid( + f"'num_segments_x' and num_segment_y' are not supported by {config[CONF_MODEL]}" + ) + return config + + def validate_reset_pin_required(config): if config[CONF_MODEL] in RESET_PIN_REQUIRED_MODELS and CONF_RESET_PIN not in config: raise cv.Invalid( @@ -190,6 +201,7 @@ CONFIG_SCHEMA = cv.All( .extend(spi.spi_device_schema()), validate_full_update_every_only_types_ac, validate_reset_pin_required, + validate_num_segments_supported, cv.has_at_most_one_key(CONF_PAGES, CONF_LAMBDA), )