mirror of
https://github.com/esphome/esphome.git
synced 2024-11-12 18:27:46 +01:00
handle bad pin schemas (#7711)
Some checks failed
CI / Create common environment (push) Has been cancelled
CI / Check black (push) Has been cancelled
CI / Check flake8 (push) Has been cancelled
CI / Check pylint (push) Has been cancelled
CI / Check pyupgrade (push) Has been cancelled
CI / Run script/ci-custom (push) Has been cancelled
CI / Run pytest (push) Has been cancelled
CI / Check clang-format (push) Has been cancelled
CI / Run script/clang-tidy for ESP32 Arduino 1/4 (push) Has been cancelled
CI / Run script/clang-tidy for ESP32 Arduino 2/4 (push) Has been cancelled
CI / Run script/clang-tidy for ESP32 Arduino 3/4 (push) Has been cancelled
CI / Run script/clang-tidy for ESP32 Arduino 4/4 (push) Has been cancelled
CI / Run script/clang-tidy for ESP32 IDF (push) Has been cancelled
CI / Run script/clang-tidy for ESP8266 (push) Has been cancelled
CI / list-components (push) Has been cancelled
CI / Component test (push) Has been cancelled
CI / Split components for testing into 20 groups maximum (push) Has been cancelled
CI / Test split components (push) Has been cancelled
CI / CI Status (push) Has been cancelled
Some checks failed
CI / Create common environment (push) Has been cancelled
CI / Check black (push) Has been cancelled
CI / Check flake8 (push) Has been cancelled
CI / Check pylint (push) Has been cancelled
CI / Check pyupgrade (push) Has been cancelled
CI / Run script/ci-custom (push) Has been cancelled
CI / Run pytest (push) Has been cancelled
CI / Check clang-format (push) Has been cancelled
CI / Run script/clang-tidy for ESP32 Arduino 1/4 (push) Has been cancelled
CI / Run script/clang-tidy for ESP32 Arduino 2/4 (push) Has been cancelled
CI / Run script/clang-tidy for ESP32 Arduino 3/4 (push) Has been cancelled
CI / Run script/clang-tidy for ESP32 Arduino 4/4 (push) Has been cancelled
CI / Run script/clang-tidy for ESP32 IDF (push) Has been cancelled
CI / Run script/clang-tidy for ESP8266 (push) Has been cancelled
CI / list-components (push) Has been cancelled
CI / Component test (push) Has been cancelled
CI / Split components for testing into 20 groups maximum (push) Has been cancelled
CI / Test split components (push) Has been cancelled
CI / CI Status (push) Has been cancelled
Co-authored-by: Samuel Sieb <samuel@sieb.net>
This commit is contained in:
parent
cefbfb75bd
commit
77bb46ff3b
5 changed files with 25 additions and 15 deletions
|
@ -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 a new issue