mirror of
https://github.com/esphome/esphome.git
synced 2024-11-21 11:37:27 +01:00
handle bad pin schemas (#7711)
Co-authored-by: Samuel Sieb <samuel@sieb.net>
This commit is contained in:
parent
cefbfb75bd
commit
77bb46ff3b
@ -67,8 +67,10 @@ def _translate_pin(value):
|
||||
"This variable only supports pin numbers, not full pin schemas "
|
||||
"(with inverted and mode)."
|
||||
)
|
||||
if isinstance(value, int):
|
||||
if isinstance(value, int) and not isinstance(value, bool):
|
||||
return value
|
||||
if not isinstance(value, str):
|
||||
raise cv.Invalid(f"Invalid pin number: {value}")
|
||||
try:
|
||||
return int(value)
|
||||
except ValueError:
|
||||
|
@ -1,6 +1,9 @@
|
||||
import logging
|
||||
from dataclasses import dataclass
|
||||
import logging
|
||||
|
||||
from esphome import pins
|
||||
import esphome.codegen as cg
|
||||
import esphome.config_validation as cv
|
||||
from esphome.const import (
|
||||
CONF_ANALOG,
|
||||
CONF_ID,
|
||||
@ -14,10 +17,7 @@ from esphome.const import (
|
||||
CONF_PULLUP,
|
||||
PLATFORM_ESP8266,
|
||||
)
|
||||
from esphome import pins
|
||||
from esphome.core import CORE, coroutine_with_priority
|
||||
import esphome.config_validation as cv
|
||||
import esphome.codegen as cg
|
||||
|
||||
from . import boards
|
||||
from .const import KEY_BOARD, KEY_ESP8266, KEY_PIN_INITIAL_STATES, esp8266_ns
|
||||
@ -48,8 +48,10 @@ def _translate_pin(value):
|
||||
"This variable only supports pin numbers, not full pin schemas "
|
||||
"(with inverted and mode)."
|
||||
)
|
||||
if isinstance(value, int):
|
||||
if isinstance(value, int) and not isinstance(value, bool):
|
||||
return value
|
||||
if not isinstance(value, str):
|
||||
raise cv.Invalid(f"Invalid pin number: {value}")
|
||||
try:
|
||||
return int(value)
|
||||
except ValueError:
|
||||
|
@ -1,5 +1,8 @@
|
||||
import logging
|
||||
|
||||
from esphome import pins
|
||||
import esphome.codegen as cg
|
||||
import esphome.config_validation as cv
|
||||
from esphome.const import (
|
||||
CONF_ID,
|
||||
CONF_INPUT,
|
||||
@ -11,9 +14,6 @@ from esphome.const import (
|
||||
CONF_PULLDOWN,
|
||||
CONF_PULLUP,
|
||||
)
|
||||
from esphome import pins
|
||||
import esphome.config_validation as cv
|
||||
import esphome.codegen as cg
|
||||
|
||||
from .const import host_ns
|
||||
|
||||
@ -28,8 +28,10 @@ def _translate_pin(value):
|
||||
"This variable only supports pin numbers, not full pin schemas "
|
||||
"(with inverted and mode)."
|
||||
)
|
||||
if isinstance(value, int):
|
||||
if isinstance(value, int) and not isinstance(value, bool):
|
||||
return value
|
||||
if not isinstance(value, str):
|
||||
raise cv.Invalid(f"Invalid pin number: {value}")
|
||||
try:
|
||||
return int(value)
|
||||
except ValueError:
|
||||
|
@ -1,8 +1,8 @@
|
||||
import logging
|
||||
|
||||
from esphome import pins
|
||||
import esphome.codegen as cg
|
||||
import esphome.config_validation as cv
|
||||
from esphome import pins
|
||||
from esphome.const import (
|
||||
CONF_ANALOG,
|
||||
CONF_ID,
|
||||
@ -103,8 +103,10 @@ def _translate_pin(value):
|
||||
"This variable only supports pin numbers, not full pin schemas "
|
||||
"(with inverted and mode)."
|
||||
)
|
||||
if isinstance(value, int):
|
||||
if isinstance(value, int) and not isinstance(value, bool):
|
||||
return value
|
||||
if not isinstance(value, str):
|
||||
raise cv.Invalid(f"Invalid pin number: {value}")
|
||||
try:
|
||||
return int(value)
|
||||
except ValueError:
|
||||
|
@ -1,6 +1,8 @@
|
||||
from esphome import pins
|
||||
import esphome.codegen as cg
|
||||
import esphome.config_validation as cv
|
||||
from esphome.const import (
|
||||
CONF_ANALOG,
|
||||
CONF_ID,
|
||||
CONF_INPUT,
|
||||
CONF_INVERTED,
|
||||
@ -10,10 +12,8 @@ from esphome.const import (
|
||||
CONF_OUTPUT,
|
||||
CONF_PULLDOWN,
|
||||
CONF_PULLUP,
|
||||
CONF_ANALOG,
|
||||
)
|
||||
from esphome.core import CORE
|
||||
from esphome import pins
|
||||
|
||||
from . import boards
|
||||
from .const import KEY_BOARD, KEY_RP2040, rp2040_ns
|
||||
@ -41,8 +41,10 @@ def _translate_pin(value):
|
||||
"This variable only supports pin numbers, not full pin schemas "
|
||||
"(with inverted and mode)."
|
||||
)
|
||||
if isinstance(value, int):
|
||||
if isinstance(value, int) and not isinstance(value, bool):
|
||||
return value
|
||||
if not isinstance(value, str):
|
||||
raise cv.Invalid(f"Invalid pin number: {value}")
|
||||
try:
|
||||
return int(value)
|
||||
except ValueError:
|
||||
|
Loading…
Reference in New Issue
Block a user