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
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
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),
)

View file

@ -28,6 +28,24 @@ display:
full_update_every: 30
lambda: |-
it.rectangle(0, 0, it.get_width(), it.get_height());
- platform: waveshare_epaper
model: 2.13in-ttgo-b74
spi_id: spi_id_1
cs_pin:
allow_other_uses: true
number: GPIO25
dc_pin:
allow_other_uses: true
number: GPIO26
busy_pin:
allow_other_uses: true
number: GPIO27
reset_pin:
allow_other_uses: true
number: GPIO32
full_update_every: 30
lambda: |-
it.rectangle(0, 0, it.get_width(), it.get_height());
- platform: waveshare_epaper
model: 2.90in
spi_id: spi_id_1