mirror of
https://github.com/esphome/esphome.git
synced 2024-11-23 15:38:11 +01:00
Adding contingency to only allow num_segments to a whitelist of displays
This commit is contained in:
parent
32a6318362
commit
f8def4812e
1 changed files with 12 additions and 0 deletions
|
@ -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),
|
||||
)
|
||||
|
||||
|
|
Loading…
Reference in a new issue