1
0
mirror of https://github.com/esphome/esphome.git synced 2025-09-13 08:42:18 +01:00

Add config to allow suppression of warnings about use of strapping pins (#5287)

Co-authored-by: Jesse Hills <3060199+jesserockz@users.noreply.github.com>
This commit is contained in:
Clyde Stubbs
2023-10-19 09:04:53 +09:00
committed by GitHub
parent 799c3cf439
commit a794836ebe
10 changed files with 38 additions and 45 deletions

View File

@@ -9,11 +9,11 @@ from esphome.const import (
CONF_OUTPUT,
CONF_PULLDOWN,
CONF_PULLUP,
CONF_IGNORE_STRAPPING_WARNING,
)
from esphome.util import SimpleRegistry
from esphome.core import CORE
PIN_SCHEMA_REGISTRY = SimpleRegistry()
@@ -146,3 +146,18 @@ internal_gpio_input_pullup_pin_number = _internal_number_creator(
CONF_PULLUP: True,
}
)
def check_strapping_pin(conf, strapping_pin_list, logger):
import esphome.config_validation as cv
num = conf[CONF_NUMBER]
if num in strapping_pin_list and not conf.get(CONF_IGNORE_STRAPPING_WARNING):
logger.warning(
f"GPIO{num} is a strapping PIN and should only be used for I/O with care.\n"
"Attaching external pullup/down resistors to strapping pins can cause unexpected failures.\n"
"See https://esphome.io/guides/faq.html#why-am-i-getting-a-warning-about-strapping-pins",
)
# mitigate undisciplined use of strapping:
if num not in strapping_pin_list and conf.get(CONF_IGNORE_STRAPPING_WARNING):
raise cv.Invalid(f"GPIO{num} is not a strapping pin")