mirror of
https://github.com/esphome/esphome.git
synced 2024-11-21 22:48:10 +01:00
UART: ignore require_tx/rx if not a native uart implementation (#6504)
This commit is contained in:
parent
12aa272234
commit
0ba4e8c0ba
1 changed files with 11 additions and 2 deletions
|
@ -46,6 +46,14 @@ LibreTinyUARTComponent = uart_ns.class_(
|
|||
"LibreTinyUARTComponent", UARTComponent, cg.Component
|
||||
)
|
||||
|
||||
NATIVE_UART_CLASSES = (
|
||||
str(IDFUARTComponent),
|
||||
str(ESP32ArduinoUARTComponent),
|
||||
str(ESP8266UartComponent),
|
||||
str(RP2040UartComponent),
|
||||
str(LibreTinyUARTComponent),
|
||||
)
|
||||
|
||||
UARTDevice = uart_ns.class_("UARTDevice")
|
||||
UARTWriteAction = uart_ns.class_("UARTWriteAction", automation.Action)
|
||||
UARTDebugger = uart_ns.class_("UARTDebugger", cg.Component, automation.Action)
|
||||
|
@ -299,17 +307,18 @@ def final_validate_device_schema(
|
|||
def validate_hub(hub_config):
|
||||
hub_schema = {}
|
||||
uart_id = hub_config[CONF_ID]
|
||||
uart_id_type_str = str(uart_id.type)
|
||||
devices = fv.full_config.get().data.setdefault(KEY_UART_DEVICES, {})
|
||||
device = devices.setdefault(uart_id, {})
|
||||
|
||||
if require_tx:
|
||||
if require_tx and uart_id_type_str in NATIVE_UART_CLASSES:
|
||||
hub_schema[
|
||||
cv.Required(
|
||||
CONF_TX_PIN,
|
||||
msg=f"Component {name} requires this uart bus to declare a tx_pin",
|
||||
)
|
||||
] = validate_pin(CONF_TX_PIN, device)
|
||||
if require_rx:
|
||||
if require_rx and uart_id_type_str in NATIVE_UART_CLASSES:
|
||||
hub_schema[
|
||||
cv.Required(
|
||||
CONF_RX_PIN,
|
||||
|
|
Loading…
Reference in a new issue