1
0
mirror of https://github.com/esphome/esphome.git synced 2025-09-29 00:22:21 +01:00

Require reset_pin for certain waveshare_epaper models in YAML validation (#6357)

This commit is contained in:
Manuel Kasper
2024-03-12 11:35:29 +01:00
committed by GitHub
parent b0a192d6a5
commit f5b02056b9
2 changed files with 29 additions and 0 deletions

View File

@@ -131,6 +131,8 @@ MODELS = {
"1.54in-m5coreink-m09": ("c", GDEW0154M09),
}
RESET_PIN_REQUIRED_MODELS = ("2.13inv2", "2.13in-ttgo-b74")
def validate_full_update_every_only_types_ac(value):
if CONF_FULL_UPDATE_EVERY not in value:
@@ -147,6 +149,14 @@ def validate_full_update_every_only_types_ac(value):
return value
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(
f"'{CONF_RESET_PIN}' is required for model {config[CONF_MODEL]}"
)
return config
CONFIG_SCHEMA = cv.All(
display.FULL_DISPLAY_SCHEMA.extend(
{
@@ -165,6 +175,7 @@ CONFIG_SCHEMA = cv.All(
.extend(cv.polling_component_schema("1s"))
.extend(spi.spi_device_schema()),
validate_full_update_every_only_types_ac,
validate_reset_pin_required,
cv.has_at_most_one_key(CONF_PAGES, CONF_LAMBDA),
)