mirror of
				https://github.com/esphome/esphome.git
				synced 2025-10-31 07:03:55 +00:00 
			
		
		
		
	Require reset_pin for certain waveshare_epaper models in YAML validation (#6357)
This commit is contained in:
		| @@ -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), | ||||
| ) | ||||
|  | ||||
|   | ||||
| @@ -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 | ||||
|   | ||||
		Reference in New Issue
	
	Block a user