mirror of
https://github.com/esphome/esphome.git
synced 2024-12-22 13:34:54 +01:00
Validate sn74hc595 pin number are within range (#5655)
This commit is contained in:
parent
c3f7cae2b0
commit
29b1233609
1 changed files with 9 additions and 1 deletions
|
@ -75,7 +75,15 @@ SN74HC595_PIN_SCHEMA = cv.All(
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@pins.PIN_SCHEMA_REGISTRY.register(CONF_SN74HC595, SN74HC595_PIN_SCHEMA)
|
def sn74hc595_pin_final_validate(pin_config, parent_config):
|
||||||
|
max_pins = parent_config[CONF_SR_COUNT] * 8
|
||||||
|
if pin_config[CONF_NUMBER] >= max_pins:
|
||||||
|
raise cv.Invalid(f"Pin number must be less than {max_pins}")
|
||||||
|
|
||||||
|
|
||||||
|
@pins.PIN_SCHEMA_REGISTRY.register(
|
||||||
|
CONF_SN74HC595, SN74HC595_PIN_SCHEMA, sn74hc595_pin_final_validate
|
||||||
|
)
|
||||||
async def sn74hc595_pin_to_code(config):
|
async def sn74hc595_pin_to_code(config):
|
||||||
var = cg.new_Pvariable(config[CONF_ID])
|
var = cg.new_Pvariable(config[CONF_ID])
|
||||||
await cg.register_parented(var, config[CONF_SN74HC595])
|
await cg.register_parented(var, config[CONF_SN74HC595])
|
||||||
|
|
Loading…
Reference in a new issue