mirror of
https://github.com/esphome/esphome.git
synced 2025-07-28 14:16:40 +00:00
Add support for LN882X Family (with LibreTiny) (#8954)
Co-authored-by: Jesse Hills <3060199+jesserockz@users.noreply.github.com>
This commit is contained in:
parent
9890659f61
commit
d86f319d66
@ -248,6 +248,7 @@ esphome/components/libretiny_pwm/* @kuba2k2
|
||||
esphome/components/light/* @esphome/core
|
||||
esphome/components/lightwaverf/* @max246
|
||||
esphome/components/lilygo_t5_47/touchscreen/* @jesserockz
|
||||
esphome/components/ln882x/* @lamauny
|
||||
esphome/components/lock/* @esphome/core
|
||||
esphome/components/logger/* @esphome/core
|
||||
esphome/components/logger/select/* @clydebarrow
|
||||
|
@ -34,11 +34,9 @@ from esphome.const import (
|
||||
CONF_PORT,
|
||||
CONF_SUBSTITUTIONS,
|
||||
CONF_TOPIC,
|
||||
PLATFORM_BK72XX,
|
||||
PLATFORM_ESP32,
|
||||
PLATFORM_ESP8266,
|
||||
PLATFORM_RP2040,
|
||||
PLATFORM_RTL87XX,
|
||||
SECRETS_FILES,
|
||||
)
|
||||
from esphome.core import CORE, EsphomeError, coroutine
|
||||
@ -354,7 +352,7 @@ def upload_program(config, args, host):
|
||||
if CORE.target_platform in (PLATFORM_RP2040):
|
||||
return upload_using_platformio(config, args.device)
|
||||
|
||||
if CORE.target_platform in (PLATFORM_BK72XX, PLATFORM_RTL87XX):
|
||||
if CORE.is_libretiny:
|
||||
return upload_using_platformio(config, host)
|
||||
|
||||
return 1 # Unknown target platform
|
||||
|
@ -1537,6 +1537,8 @@ DeviceInfoResponse APIConnection::device_info(const DeviceInfoRequest &msg) {
|
||||
resp.manufacturer = "Raspberry Pi";
|
||||
#elif defined(USE_BK72XX)
|
||||
resp.manufacturer = "Beken";
|
||||
#elif defined(USE_LN882X)
|
||||
resp.manufacturer = "Lightning";
|
||||
#elif defined(USE_RTL87XX)
|
||||
resp.manufacturer = "Realtek";
|
||||
#elif defined(USE_HOST)
|
||||
|
@ -5,6 +5,7 @@ from esphome.const import (
|
||||
PLATFORM_BK72XX,
|
||||
PLATFORM_ESP32,
|
||||
PLATFORM_ESP8266,
|
||||
PLATFORM_LN882X,
|
||||
PLATFORM_RTL87XX,
|
||||
)
|
||||
from esphome.core import CORE, coroutine_with_priority
|
||||
@ -14,7 +15,15 @@ CODEOWNERS = ["@OttoWinter"]
|
||||
CONFIG_SCHEMA = cv.All(
|
||||
cv.Schema({}),
|
||||
cv.only_with_arduino,
|
||||
cv.only_on([PLATFORM_ESP32, PLATFORM_ESP8266, PLATFORM_BK72XX, PLATFORM_RTL87XX]),
|
||||
cv.only_on(
|
||||
[
|
||||
PLATFORM_ESP32,
|
||||
PLATFORM_ESP8266,
|
||||
PLATFORM_BK72XX,
|
||||
PLATFORM_LN882X,
|
||||
PLATFORM_RTL87XX,
|
||||
]
|
||||
),
|
||||
)
|
||||
|
||||
|
||||
|
@ -7,6 +7,7 @@ from esphome.const import (
|
||||
PLATFORM_BK72XX,
|
||||
PLATFORM_ESP32,
|
||||
PLATFORM_ESP8266,
|
||||
PLATFORM_LN882X,
|
||||
PLATFORM_RTL87XX,
|
||||
)
|
||||
from esphome.core import CORE, coroutine_with_priority
|
||||
@ -27,7 +28,15 @@ CONFIG_SCHEMA = cv.All(
|
||||
),
|
||||
}
|
||||
).extend(cv.COMPONENT_SCHEMA),
|
||||
cv.only_on([PLATFORM_ESP32, PLATFORM_ESP8266, PLATFORM_BK72XX, PLATFORM_RTL87XX]),
|
||||
cv.only_on(
|
||||
[
|
||||
PLATFORM_ESP32,
|
||||
PLATFORM_ESP8266,
|
||||
PLATFORM_BK72XX,
|
||||
PLATFORM_LN882X,
|
||||
PLATFORM_RTL87XX,
|
||||
]
|
||||
),
|
||||
)
|
||||
|
||||
|
||||
|
@ -100,6 +100,7 @@ CONFIG_SCHEMA = (
|
||||
esp32=3232,
|
||||
rp2040=2040,
|
||||
bk72xx=8892,
|
||||
ln882x=8820,
|
||||
rtl87xx=8892,
|
||||
): cv.port,
|
||||
cv.Optional(CONF_PASSWORD): cv.string,
|
||||
|
@ -50,6 +50,7 @@ KEY_FAMILY = "family"
|
||||
|
||||
# COMPONENTS - auto-generated! Do not modify this block.
|
||||
COMPONENT_BK72XX = "bk72xx"
|
||||
COMPONENT_LN882X = "ln882x"
|
||||
COMPONENT_RTL87XX = "rtl87xx"
|
||||
# COMPONENTS - end
|
||||
|
||||
@ -58,6 +59,7 @@ FAMILY_BK7231N = "BK7231N"
|
||||
FAMILY_BK7231Q = "BK7231Q"
|
||||
FAMILY_BK7231T = "BK7231T"
|
||||
FAMILY_BK7251 = "BK7251"
|
||||
FAMILY_LN882H = "LN882H"
|
||||
FAMILY_RTL8710B = "RTL8710B"
|
||||
FAMILY_RTL8720C = "RTL8720C"
|
||||
FAMILIES = [
|
||||
@ -65,6 +67,7 @@ FAMILIES = [
|
||||
FAMILY_BK7231Q,
|
||||
FAMILY_BK7231T,
|
||||
FAMILY_BK7251,
|
||||
FAMILY_LN882H,
|
||||
FAMILY_RTL8710B,
|
||||
FAMILY_RTL8720C,
|
||||
]
|
||||
@ -73,6 +76,7 @@ FAMILY_FRIENDLY = {
|
||||
FAMILY_BK7231Q: "BK7231Q",
|
||||
FAMILY_BK7231T: "BK7231T",
|
||||
FAMILY_BK7251: "BK7251",
|
||||
FAMILY_LN882H: "LN882H",
|
||||
FAMILY_RTL8710B: "RTL8710B",
|
||||
FAMILY_RTL8720C: "RTL8720C",
|
||||
}
|
||||
@ -81,6 +85,7 @@ FAMILY_COMPONENT = {
|
||||
FAMILY_BK7231Q: COMPONENT_BK72XX,
|
||||
FAMILY_BK7231T: COMPONENT_BK72XX,
|
||||
FAMILY_BK7251: COMPONENT_BK72XX,
|
||||
FAMILY_LN882H: COMPONENT_LN882X,
|
||||
FAMILY_RTL8710B: COMPONENT_RTL87XX,
|
||||
FAMILY_RTL8720C: COMPONENT_RTL87XX,
|
||||
}
|
||||
|
@ -94,6 +94,7 @@ PIN_SCHEMA_EXTRA = f"libretiny.BASE_PIN_SCHEMA.extend({VAR_PIN_SCHEMA})"
|
||||
COMPONENT_MAP = {
|
||||
"rtl87xx": "realtek-amb",
|
||||
"bk72xx": "beken-72xx",
|
||||
"ln882x": "lightning-ln882x",
|
||||
}
|
||||
|
||||
|
||||
|
52
esphome/components/ln882x/__init__.py
Normal file
52
esphome/components/ln882x/__init__.py
Normal file
@ -0,0 +1,52 @@
|
||||
# This file was auto-generated by libretiny/generate_components.py
|
||||
# Do not modify its contents.
|
||||
# For custom pin validators, put validate_pin() or validate_usage()
|
||||
# in gpio.py file in this directory.
|
||||
# For changing schema/pin schema, put COMPONENT_SCHEMA or COMPONENT_PIN_SCHEMA
|
||||
# in schema.py file in this directory.
|
||||
|
||||
from esphome import pins
|
||||
from esphome.components import libretiny
|
||||
from esphome.components.libretiny.const import (
|
||||
COMPONENT_LN882X,
|
||||
KEY_COMPONENT_DATA,
|
||||
KEY_LIBRETINY,
|
||||
LibreTinyComponent,
|
||||
)
|
||||
from esphome.core import CORE
|
||||
|
||||
from .boards import LN882X_BOARD_PINS, LN882X_BOARDS
|
||||
|
||||
CODEOWNERS = ["@lamauny"]
|
||||
AUTO_LOAD = ["libretiny"]
|
||||
IS_TARGET_PLATFORM = True
|
||||
|
||||
COMPONENT_DATA = LibreTinyComponent(
|
||||
name=COMPONENT_LN882X,
|
||||
boards=LN882X_BOARDS,
|
||||
board_pins=LN882X_BOARD_PINS,
|
||||
pin_validation=None,
|
||||
usage_validation=None,
|
||||
)
|
||||
|
||||
|
||||
def _set_core_data(config):
|
||||
CORE.data[KEY_LIBRETINY] = {}
|
||||
CORE.data[KEY_LIBRETINY][KEY_COMPONENT_DATA] = COMPONENT_DATA
|
||||
return config
|
||||
|
||||
|
||||
CONFIG_SCHEMA = libretiny.BASE_SCHEMA
|
||||
|
||||
PIN_SCHEMA = libretiny.gpio.BASE_PIN_SCHEMA
|
||||
|
||||
CONFIG_SCHEMA.prepend_extra(_set_core_data)
|
||||
|
||||
|
||||
async def to_code(config):
|
||||
return await libretiny.component_to_code(config)
|
||||
|
||||
|
||||
@pins.PIN_SCHEMA_REGISTRY.register("ln882x", PIN_SCHEMA)
|
||||
async def pin_to_code(config):
|
||||
return await libretiny.gpio.component_pin_to_code(config)
|
285
esphome/components/ln882x/boards.py
Normal file
285
esphome/components/ln882x/boards.py
Normal file
@ -0,0 +1,285 @@
|
||||
# This file was auto-generated by libretiny/generate_components.py
|
||||
# Do not modify its contents.
|
||||
|
||||
from esphome.components.libretiny.const import FAMILY_LN882H
|
||||
|
||||
LN882X_BOARDS = {
|
||||
"wl2s": {
|
||||
"name": "WL2S Wi-Fi/BLE Module",
|
||||
"family": FAMILY_LN882H,
|
||||
},
|
||||
"ln-02": {
|
||||
"name": "LN-02 Wi-Fi/BLE Module",
|
||||
"family": FAMILY_LN882H,
|
||||
},
|
||||
"generic-ln882hki": {
|
||||
"name": "Generic - LN882HKI",
|
||||
"family": FAMILY_LN882H,
|
||||
},
|
||||
}
|
||||
|
||||
LN882X_BOARD_PINS = {
|
||||
"wl2s": {
|
||||
"WIRE0_SCL_0": 7,
|
||||
"WIRE0_SCL_1": 12,
|
||||
"WIRE0_SCL_2": 3,
|
||||
"WIRE0_SCL_3": 10,
|
||||
"WIRE0_SCL_4": 2,
|
||||
"WIRE0_SCL_5": 0,
|
||||
"WIRE0_SCL_6": 19,
|
||||
"WIRE0_SCL_7": 11,
|
||||
"WIRE0_SCL_8": 9,
|
||||
"WIRE0_SCL_9": 24,
|
||||
"WIRE0_SCL_10": 25,
|
||||
"WIRE0_SCL_11": 5,
|
||||
"WIRE0_SCL_12": 1,
|
||||
"WIRE0_SDA_0": 7,
|
||||
"WIRE0_SDA_1": 12,
|
||||
"WIRE0_SDA_2": 3,
|
||||
"WIRE0_SDA_3": 10,
|
||||
"WIRE0_SDA_4": 2,
|
||||
"WIRE0_SDA_5": 0,
|
||||
"WIRE0_SDA_6": 19,
|
||||
"WIRE0_SDA_7": 11,
|
||||
"WIRE0_SDA_8": 9,
|
||||
"WIRE0_SDA_9": 24,
|
||||
"WIRE0_SDA_10": 25,
|
||||
"WIRE0_SDA_11": 5,
|
||||
"WIRE0_SDA_12": 1,
|
||||
"SERIAL0_RX": 3,
|
||||
"SERIAL0_TX": 2,
|
||||
"SERIAL1_RX": 24,
|
||||
"SERIAL1_TX": 25,
|
||||
"ADC2": 0,
|
||||
"ADC3": 1,
|
||||
"ADC5": 19,
|
||||
"PA00": 0,
|
||||
"PA0": 0,
|
||||
"PA01": 1,
|
||||
"PA1": 1,
|
||||
"PA02": 2,
|
||||
"PA2": 2,
|
||||
"PA03": 3,
|
||||
"PA3": 3,
|
||||
"PA05": 5,
|
||||
"PA5": 5,
|
||||
"PA07": 7,
|
||||
"PA7": 7,
|
||||
"PA09": 9,
|
||||
"PA9": 9,
|
||||
"PA10": 10,
|
||||
"PA11": 11,
|
||||
"PA12": 12,
|
||||
"PB03": 19,
|
||||
"PB3": 19,
|
||||
"PB08": 24,
|
||||
"PB8": 24,
|
||||
"PB09": 25,
|
||||
"PB9": 25,
|
||||
"RX0": 3,
|
||||
"RX1": 24,
|
||||
"SCL0": 1,
|
||||
"SDA0": 1,
|
||||
"TX0": 2,
|
||||
"TX1": 25,
|
||||
"D0": 7,
|
||||
"D1": 12,
|
||||
"D2": 3,
|
||||
"D3": 10,
|
||||
"D4": 2,
|
||||
"D5": 0,
|
||||
"D6": 19,
|
||||
"D7": 11,
|
||||
"D8": 9,
|
||||
"D9": 24,
|
||||
"D10": 25,
|
||||
"D11": 5,
|
||||
"D12": 1,
|
||||
"A0": 0,
|
||||
"A1": 19,
|
||||
"A2": 1,
|
||||
},
|
||||
"ln-02": {
|
||||
"WIRE0_SCL_0": 11,
|
||||
"WIRE0_SCL_1": 19,
|
||||
"WIRE0_SCL_2": 3,
|
||||
"WIRE0_SCL_3": 24,
|
||||
"WIRE0_SCL_4": 2,
|
||||
"WIRE0_SCL_5": 25,
|
||||
"WIRE0_SCL_6": 1,
|
||||
"WIRE0_SCL_7": 0,
|
||||
"WIRE0_SCL_8": 9,
|
||||
"WIRE0_SDA_0": 11,
|
||||
"WIRE0_SDA_1": 19,
|
||||
"WIRE0_SDA_2": 3,
|
||||
"WIRE0_SDA_3": 24,
|
||||
"WIRE0_SDA_4": 2,
|
||||
"WIRE0_SDA_5": 25,
|
||||
"WIRE0_SDA_6": 1,
|
||||
"WIRE0_SDA_7": 0,
|
||||
"WIRE0_SDA_8": 9,
|
||||
"SERIAL0_RX": 3,
|
||||
"SERIAL0_TX": 2,
|
||||
"SERIAL1_RX": 24,
|
||||
"SERIAL1_TX": 25,
|
||||
"ADC2": 0,
|
||||
"ADC3": 1,
|
||||
"ADC5": 19,
|
||||
"PA00": 0,
|
||||
"PA0": 0,
|
||||
"PA01": 1,
|
||||
"PA1": 1,
|
||||
"PA02": 2,
|
||||
"PA2": 2,
|
||||
"PA03": 3,
|
||||
"PA3": 3,
|
||||
"PA09": 9,
|
||||
"PA9": 9,
|
||||
"PA11": 11,
|
||||
"PB03": 19,
|
||||
"PB3": 19,
|
||||
"PB08": 24,
|
||||
"PB8": 24,
|
||||
"PB09": 25,
|
||||
"PB9": 25,
|
||||
"RX0": 3,
|
||||
"RX1": 24,
|
||||
"SCL0": 9,
|
||||
"SDA0": 9,
|
||||
"TX0": 2,
|
||||
"TX1": 25,
|
||||
"D0": 11,
|
||||
"D1": 19,
|
||||
"D2": 3,
|
||||
"D3": 24,
|
||||
"D4": 2,
|
||||
"D5": 25,
|
||||
"D6": 1,
|
||||
"D7": 0,
|
||||
"D8": 9,
|
||||
"A0": 19,
|
||||
"A1": 1,
|
||||
"A2": 0,
|
||||
},
|
||||
"generic-ln882hki": {
|
||||
"WIRE0_SCL_0": 0,
|
||||
"WIRE0_SCL_1": 1,
|
||||
"WIRE0_SCL_2": 2,
|
||||
"WIRE0_SCL_3": 3,
|
||||
"WIRE0_SCL_4": 4,
|
||||
"WIRE0_SCL_5": 5,
|
||||
"WIRE0_SCL_6": 6,
|
||||
"WIRE0_SCL_7": 7,
|
||||
"WIRE0_SCL_8": 8,
|
||||
"WIRE0_SCL_9": 9,
|
||||
"WIRE0_SCL_10": 10,
|
||||
"WIRE0_SCL_11": 11,
|
||||
"WIRE0_SCL_12": 12,
|
||||
"WIRE0_SCL_13": 19,
|
||||
"WIRE0_SCL_14": 20,
|
||||
"WIRE0_SCL_15": 21,
|
||||
"WIRE0_SCL_16": 22,
|
||||
"WIRE0_SCL_17": 23,
|
||||
"WIRE0_SCL_18": 24,
|
||||
"WIRE0_SCL_19": 25,
|
||||
"WIRE0_SDA_0": 0,
|
||||
"WIRE0_SDA_1": 1,
|
||||
"WIRE0_SDA_2": 2,
|
||||
"WIRE0_SDA_3": 3,
|
||||
"WIRE0_SDA_4": 4,
|
||||
"WIRE0_SDA_5": 5,
|
||||
"WIRE0_SDA_6": 6,
|
||||
"WIRE0_SDA_7": 7,
|
||||
"WIRE0_SDA_8": 8,
|
||||
"WIRE0_SDA_9": 9,
|
||||
"WIRE0_SDA_10": 10,
|
||||
"WIRE0_SDA_11": 11,
|
||||
"WIRE0_SDA_12": 12,
|
||||
"WIRE0_SDA_13": 19,
|
||||
"WIRE0_SDA_14": 20,
|
||||
"WIRE0_SDA_15": 21,
|
||||
"WIRE0_SDA_16": 22,
|
||||
"WIRE0_SDA_17": 23,
|
||||
"WIRE0_SDA_18": 24,
|
||||
"WIRE0_SDA_19": 25,
|
||||
"SERIAL0_RX": 3,
|
||||
"SERIAL0_TX": 2,
|
||||
"SERIAL1_RX": 24,
|
||||
"SERIAL1_TX": 25,
|
||||
"ADC2": 0,
|
||||
"ADC3": 1,
|
||||
"ADC4": 4,
|
||||
"ADC5": 19,
|
||||
"ADC6": 20,
|
||||
"ADC7": 21,
|
||||
"PA00": 0,
|
||||
"PA0": 0,
|
||||
"PA01": 1,
|
||||
"PA1": 1,
|
||||
"PA02": 2,
|
||||
"PA2": 2,
|
||||
"PA03": 3,
|
||||
"PA3": 3,
|
||||
"PA04": 4,
|
||||
"PA4": 4,
|
||||
"PA05": 5,
|
||||
"PA5": 5,
|
||||
"PA06": 6,
|
||||
"PA6": 6,
|
||||
"PA07": 7,
|
||||
"PA7": 7,
|
||||
"PA08": 8,
|
||||
"PA8": 8,
|
||||
"PA09": 9,
|
||||
"PA9": 9,
|
||||
"PA10": 10,
|
||||
"PA11": 11,
|
||||
"PA12": 12,
|
||||
"PB03": 19,
|
||||
"PB3": 19,
|
||||
"PB04": 20,
|
||||
"PB4": 20,
|
||||
"PB05": 21,
|
||||
"PB5": 21,
|
||||
"PB06": 22,
|
||||
"PB6": 22,
|
||||
"PB07": 23,
|
||||
"PB7": 23,
|
||||
"PB08": 24,
|
||||
"PB8": 24,
|
||||
"PB09": 25,
|
||||
"PB9": 25,
|
||||
"RX0": 3,
|
||||
"RX1": 24,
|
||||
"TX0": 2,
|
||||
"TX1": 25,
|
||||
"D0": 0,
|
||||
"D1": 1,
|
||||
"D2": 2,
|
||||
"D3": 3,
|
||||
"D4": 4,
|
||||
"D5": 5,
|
||||
"D6": 6,
|
||||
"D7": 7,
|
||||
"D8": 8,
|
||||
"D9": 9,
|
||||
"D10": 10,
|
||||
"D11": 11,
|
||||
"D12": 12,
|
||||
"D13": 19,
|
||||
"D14": 20,
|
||||
"D15": 21,
|
||||
"D16": 22,
|
||||
"D17": 23,
|
||||
"D18": 24,
|
||||
"D19": 25,
|
||||
"A2": 0,
|
||||
"A3": 1,
|
||||
"A4": 4,
|
||||
"A5": 19,
|
||||
"A6": 20,
|
||||
"A7": 21,
|
||||
},
|
||||
}
|
||||
|
||||
BOARDS = LN882X_BOARDS
|
@ -16,7 +16,11 @@ from esphome.components.esp32.const import (
|
||||
VARIANT_ESP32S3,
|
||||
)
|
||||
from esphome.components.libretiny import get_libretiny_component, get_libretiny_family
|
||||
from esphome.components.libretiny.const import COMPONENT_BK72XX, COMPONENT_RTL87XX
|
||||
from esphome.components.libretiny.const import (
|
||||
COMPONENT_BK72XX,
|
||||
COMPONENT_LN882X,
|
||||
COMPONENT_RTL87XX,
|
||||
)
|
||||
import esphome.config_validation as cv
|
||||
from esphome.const import (
|
||||
CONF_ARGS,
|
||||
@ -35,6 +39,7 @@ from esphome.const import (
|
||||
PLATFORM_BK72XX,
|
||||
PLATFORM_ESP32,
|
||||
PLATFORM_ESP8266,
|
||||
PLATFORM_LN882X,
|
||||
PLATFORM_RP2040,
|
||||
PLATFORM_RTL87XX,
|
||||
)
|
||||
@ -100,6 +105,7 @@ UART_SELECTION_ESP8266 = [UART0, UART0_SWAP, UART1]
|
||||
|
||||
UART_SELECTION_LIBRETINY = {
|
||||
COMPONENT_BK72XX: [DEFAULT, UART1, UART2],
|
||||
COMPONENT_LN882X: [DEFAULT, UART0, UART1, UART2],
|
||||
COMPONENT_RTL87XX: [DEFAULT, UART0, UART1, UART2],
|
||||
}
|
||||
|
||||
@ -217,6 +223,7 @@ CONFIG_SCHEMA = cv.All(
|
||||
esp32_p4_idf=USB_SERIAL_JTAG,
|
||||
rp2040=USB_CDC,
|
||||
bk72xx=DEFAULT,
|
||||
ln882x=DEFAULT,
|
||||
rtl87xx=DEFAULT,
|
||||
): cv.All(
|
||||
cv.only_on(
|
||||
@ -225,6 +232,7 @@ CONFIG_SCHEMA = cv.All(
|
||||
PLATFORM_ESP32,
|
||||
PLATFORM_RP2040,
|
||||
PLATFORM_BK72XX,
|
||||
PLATFORM_LN882X,
|
||||
PLATFORM_RTL87XX,
|
||||
]
|
||||
),
|
||||
|
@ -94,6 +94,7 @@ CONFIG_SCHEMA = remote_base.validate_triggers(
|
||||
esp32="10000b",
|
||||
esp8266="1000b",
|
||||
bk72xx="1000b",
|
||||
ln882x="1000b",
|
||||
rtl87xx="1000b",
|
||||
): cv.validate_bytes,
|
||||
cv.Optional(CONF_FILTER, default="50us"): cv.All(
|
||||
|
@ -7,6 +7,7 @@ from esphome.const import (
|
||||
PLATFORM_BK72XX,
|
||||
PLATFORM_ESP32,
|
||||
PLATFORM_ESP8266,
|
||||
PLATFORM_LN882X,
|
||||
PLATFORM_RP2040,
|
||||
PLATFORM_RTL87XX,
|
||||
)
|
||||
@ -33,6 +34,7 @@ CONFIG_SCHEMA = cv.All(
|
||||
PLATFORM_ESP8266,
|
||||
PLATFORM_RP2040,
|
||||
PLATFORM_BK72XX,
|
||||
PLATFORM_LN882X,
|
||||
PLATFORM_RTL87XX,
|
||||
]
|
||||
),
|
||||
|
@ -16,6 +16,7 @@ CONFIG_SCHEMA = cv.Schema(
|
||||
esp32=IMPLEMENTATION_BSD_SOCKETS,
|
||||
rp2040=IMPLEMENTATION_LWIP_TCP,
|
||||
bk72xx=IMPLEMENTATION_LWIP_SOCKETS,
|
||||
ln882x=IMPLEMENTATION_LWIP_SOCKETS,
|
||||
rtl87xx=IMPLEMENTATION_LWIP_SOCKETS,
|
||||
host=IMPLEMENTATION_BSD_SOCKETS,
|
||||
): cv.one_of(
|
||||
|
@ -28,6 +28,7 @@ from esphome.const import (
|
||||
PLATFORM_BK72XX,
|
||||
PLATFORM_ESP32,
|
||||
PLATFORM_ESP8266,
|
||||
PLATFORM_LN882X,
|
||||
PLATFORM_RTL87XX,
|
||||
)
|
||||
from esphome.core import CORE, coroutine_with_priority
|
||||
@ -180,6 +181,7 @@ CONFIG_SCHEMA = cv.All(
|
||||
esp32_arduino=True,
|
||||
esp32_idf=False,
|
||||
bk72xx=True,
|
||||
ln882x=True,
|
||||
rtl87xx=True,
|
||||
): cv.boolean,
|
||||
cv.Optional(CONF_LOG, default=True): cv.boolean,
|
||||
@ -187,7 +189,15 @@ CONFIG_SCHEMA = cv.All(
|
||||
cv.Optional(CONF_SORTING_GROUPS): cv.ensure_list(sorting_group),
|
||||
}
|
||||
).extend(cv.COMPONENT_SCHEMA),
|
||||
cv.only_on([PLATFORM_ESP32, PLATFORM_ESP8266, PLATFORM_BK72XX, PLATFORM_RTL87XX]),
|
||||
cv.only_on(
|
||||
[
|
||||
PLATFORM_ESP32,
|
||||
PLATFORM_ESP8266,
|
||||
PLATFORM_BK72XX,
|
||||
PLATFORM_LN882X,
|
||||
PLATFORM_RTL87XX,
|
||||
]
|
||||
),
|
||||
default_url,
|
||||
validate_local,
|
||||
validate_ota,
|
||||
|
@ -309,6 +309,7 @@ CONFIG_SCHEMA = cv.All(
|
||||
rp2040="light",
|
||||
bk72xx="none",
|
||||
rtl87xx="none",
|
||||
ln882x="light",
|
||||
): cv.enum(WIFI_POWER_SAVE_MODES, upper=True),
|
||||
cv.Optional(CONF_FAST_CONNECT, default=False): cv.boolean,
|
||||
cv.Optional(CONF_USE_ADDRESS): cv.string_strict,
|
||||
|
@ -12,6 +12,7 @@ PLATFORM_ESP32 = "esp32"
|
||||
PLATFORM_ESP8266 = "esp8266"
|
||||
PLATFORM_HOST = "host"
|
||||
PLATFORM_LIBRETINY_OLDSTYLE = "libretiny"
|
||||
PLATFORM_LN882X = "ln882x"
|
||||
PLATFORM_RP2040 = "rp2040"
|
||||
PLATFORM_RTL87XX = "rtl87xx"
|
||||
|
||||
|
@ -20,6 +20,7 @@ from esphome.const import (
|
||||
PLATFORM_ESP32,
|
||||
PLATFORM_ESP8266,
|
||||
PLATFORM_HOST,
|
||||
PLATFORM_LN882X,
|
||||
PLATFORM_RP2040,
|
||||
PLATFORM_RTL87XX,
|
||||
)
|
||||
@ -661,9 +662,13 @@ class EsphomeCore:
|
||||
def is_rtl87xx(self):
|
||||
return self.target_platform == PLATFORM_RTL87XX
|
||||
|
||||
@property
|
||||
def is_ln882x(self):
|
||||
return self.target_platform == PLATFORM_LN882X
|
||||
|
||||
@property
|
||||
def is_libretiny(self):
|
||||
return self.is_bk72xx or self.is_rtl87xx
|
||||
return self.is_bk72xx or self.is_rtl87xx or self.is_ln882x
|
||||
|
||||
@property
|
||||
def is_host(self):
|
||||
|
@ -639,7 +639,11 @@ class DownloadListRequestHandler(BaseHandler):
|
||||
|
||||
if platform.upper() in ESP32_VARIANTS:
|
||||
platform = "esp32"
|
||||
elif platform in (const.PLATFORM_RTL87XX, const.PLATFORM_BK72XX):
|
||||
elif platform in (
|
||||
const.PLATFORM_RTL87XX,
|
||||
const.PLATFORM_BK72XX,
|
||||
const.PLATFORM_LN882X,
|
||||
):
|
||||
platform = "libretiny"
|
||||
|
||||
try:
|
||||
@ -837,6 +841,10 @@ class BoardsRequestHandler(BaseHandler):
|
||||
from esphome.components.bk72xx.boards import BOARDS as BK72XX_BOARDS
|
||||
|
||||
boards = BK72XX_BOARDS
|
||||
elif platform == const.PLATFORM_LN882X:
|
||||
from esphome.components.ln882x.boards import BOARDS as LN882X_BOARDS
|
||||
|
||||
boards = LN882X_BOARDS
|
||||
elif platform == const.PLATFORM_RTL87XX:
|
||||
from esphome.components.rtl87xx.boards import BOARDS as RTL87XX_BOARDS
|
||||
|
||||
|
@ -83,6 +83,11 @@ bk72xx:
|
||||
board: {board}
|
||||
"""
|
||||
|
||||
LN882X_CONFIG = """
|
||||
ln882x:
|
||||
board: {board}
|
||||
"""
|
||||
|
||||
RTL87XX_CONFIG = """
|
||||
rtl87xx:
|
||||
board: {board}
|
||||
@ -93,6 +98,7 @@ HARDWARE_BASE_CONFIGS = {
|
||||
"ESP32": ESP32_CONFIG,
|
||||
"RP2040": RP2040_CONFIG,
|
||||
"BK72XX": BK72XX_CONFIG,
|
||||
"LN882X": LN882X_CONFIG,
|
||||
"RTL87XX": RTL87XX_CONFIG,
|
||||
}
|
||||
|
||||
@ -157,7 +163,7 @@ def wizard_file(**kwargs):
|
||||
"""
|
||||
|
||||
# pylint: disable=consider-using-f-string
|
||||
if kwargs["platform"] in ["ESP8266", "ESP32", "BK72XX", "RTL87XX"]:
|
||||
if kwargs["platform"] in ["ESP8266", "ESP32", "BK72XX", "LN882X", "RTL87XX"]:
|
||||
config += """
|
||||
# Enable fallback hotspot (captive portal) in case wifi connection fails
|
||||
ap:
|
||||
@ -181,6 +187,7 @@ def wizard_write(path, **kwargs):
|
||||
from esphome.components.bk72xx import boards as bk72xx_boards
|
||||
from esphome.components.esp32 import boards as esp32_boards
|
||||
from esphome.components.esp8266 import boards as esp8266_boards
|
||||
from esphome.components.ln882x import boards as ln882x_boards
|
||||
from esphome.components.rp2040 import boards as rp2040_boards
|
||||
from esphome.components.rtl87xx import boards as rtl87xx_boards
|
||||
|
||||
@ -200,6 +207,8 @@ def wizard_write(path, **kwargs):
|
||||
platform = "RP2040"
|
||||
elif board in bk72xx_boards.BOARDS:
|
||||
platform = "BK72XX"
|
||||
elif board in ln882x_boards.BOARDS:
|
||||
platform = "LN882X"
|
||||
elif board in rtl87xx_boards.BOARDS:
|
||||
platform = "RTL87XX"
|
||||
else:
|
||||
@ -253,6 +262,7 @@ def wizard(path):
|
||||
from esphome.components.bk72xx import boards as bk72xx_boards
|
||||
from esphome.components.esp32 import boards as esp32_boards
|
||||
from esphome.components.esp8266 import boards as esp8266_boards
|
||||
from esphome.components.ln882x import boards as ln882x_boards
|
||||
from esphome.components.rp2040 import boards as rp2040_boards
|
||||
from esphome.components.rtl87xx import boards as rtl87xx_boards
|
||||
|
||||
@ -325,7 +335,7 @@ def wizard(path):
|
||||
"firmwares for it."
|
||||
)
|
||||
|
||||
wizard_platforms = ["ESP32", "ESP8266", "BK72XX", "RTL87XX", "RP2040"]
|
||||
wizard_platforms = ["ESP32", "ESP8266", "BK72XX", "LN882X", "RTL87XX", "RP2040"]
|
||||
safe_print(
|
||||
"Please choose one of the supported microcontrollers "
|
||||
"(Use ESP8266 for Sonoff devices)."
|
||||
@ -361,7 +371,7 @@ def wizard(path):
|
||||
board_link = (
|
||||
"https://www.raspberrypi.com/documentation/microcontrollers/rp2040.html"
|
||||
)
|
||||
elif platform in ["BK72XX", "RTL87XX"]:
|
||||
elif platform in ["BK72XX", "LN882X", "RTL87XX"]:
|
||||
board_link = "https://docs.libretiny.eu/docs/status/supported/"
|
||||
else:
|
||||
raise NotImplementedError("Unknown platform!")
|
||||
@ -384,6 +394,9 @@ def wizard(path):
|
||||
elif platform == "BK72XX":
|
||||
safe_print(f'For example "{color(AnsiFore.BOLD_WHITE, "cb2s")}".')
|
||||
boards_list = bk72xx_boards.BOARDS.items()
|
||||
elif platform == "LN882X":
|
||||
safe_print(f'For example "{color(AnsiFore.BOLD_WHITE, "wl2s")}".')
|
||||
boards_list = ln882x_boards.BOARDS.items()
|
||||
elif platform == "RTL87XX":
|
||||
safe_print(f'For example "{color(AnsiFore.BOLD_WHITE, "wr3")}".')
|
||||
boards_list = rtl87xx_boards.BOARDS.items()
|
||||
|
@ -4,7 +4,7 @@
|
||||
; It's *not* used during runtime.
|
||||
|
||||
[platformio]
|
||||
default_envs = esp8266-arduino, esp32-arduino, esp32-idf, bk72xx-arduino
|
||||
default_envs = esp8266-arduino, esp32-arduino, esp32-idf, bk72xx-arduino, ln882h-arduino
|
||||
; Ideally, we want src_dir to be the root directory of the repository, to mimic the runtime build
|
||||
; environment as best as possible. Unfortunately, the ESP-IDF toolchain really doesn't like this
|
||||
; being the root directory. Instead, set esphome/ as the source directory, all our sources are in
|
||||
@ -530,6 +530,17 @@ build_flags =
|
||||
build_unflags =
|
||||
${common.build_unflags}
|
||||
|
||||
[env:ln882h-arduino]
|
||||
extends = common:libretiny-arduino
|
||||
board = generic-ln882hki
|
||||
build_flags =
|
||||
${common:libretiny-arduino.build_flags}
|
||||
${flags:runtime.build_flags}
|
||||
-DUSE_LN882X
|
||||
-DUSE_LIBRETINY_VARIANT_LN882H
|
||||
build_unflags =
|
||||
${common.build_unflags}
|
||||
|
||||
[env:rtl87xxb-arduino]
|
||||
extends = common:libretiny-arduino
|
||||
board = generic-rtl8710bn-2mb-788k
|
||||
|
4
tests/components/adc/test.ln882x-ard.yaml
Normal file
4
tests/components/adc/test.ln882x-ard.yaml
Normal file
@ -0,0 +1,4 @@
|
||||
sensor:
|
||||
- platform: adc
|
||||
pin: PA0
|
||||
name: Basic ADC Test
|
2
tests/components/binary_sensor/test.ln882x-ard.yaml
Normal file
2
tests/components/binary_sensor/test.ln882x-ard.yaml
Normal file
@ -0,0 +1,2 @@
|
||||
packages:
|
||||
common: !include common.yaml
|
1
tests/components/debug/test.ln882x-ard.yaml
Normal file
1
tests/components/debug/test.ln882x-ard.yaml
Normal file
@ -0,0 +1 @@
|
||||
<<: !include common.yaml
|
2
tests/components/homeassistant/test.ln882x-ard.yaml
Normal file
2
tests/components/homeassistant/test.ln882x-ard.yaml
Normal file
@ -0,0 +1,2 @@
|
||||
packages:
|
||||
common: !include common.yaml
|
1
tests/components/script/test.ln882x-ard.yaml
Normal file
1
tests/components/script/test.ln882x-ard.yaml
Normal file
@ -0,0 +1 @@
|
||||
<<: !include common.yaml
|
1
tests/components/sntp/test.ln882x-ard.yaml
Normal file
1
tests/components/sntp/test.ln882x-ard.yaml
Normal file
@ -0,0 +1 @@
|
||||
<<: !include common.yaml
|
2
tests/components/switch/test.ln882x-ard.yaml
Normal file
2
tests/components/switch/test.ln882x-ard.yaml
Normal file
@ -0,0 +1,2 @@
|
||||
packages:
|
||||
common: !include common.yaml
|
1
tests/components/syslog/test.ln882x-ard.yaml
Normal file
1
tests/components/syslog/test.ln882x-ard.yaml
Normal file
@ -0,0 +1 @@
|
||||
<<: !include common.yaml
|
2
tests/components/template/test.ln882x-ard.yaml
Normal file
2
tests/components/template/test.ln882x-ard.yaml
Normal file
@ -0,0 +1,2 @@
|
||||
packages:
|
||||
common: !include common.yaml
|
@ -0,0 +1,15 @@
|
||||
esphome:
|
||||
name: componenttestespln882x
|
||||
friendly_name: $component_name
|
||||
|
||||
ln882x:
|
||||
board: generic-ln882hki
|
||||
|
||||
logger:
|
||||
level: VERY_VERBOSE
|
||||
|
||||
packages:
|
||||
component_under_test: !include
|
||||
file: $component_test_file
|
||||
vars:
|
||||
component_test_file: $component_test_file
|
@ -20,6 +20,7 @@ from esphome.const import (
|
||||
PLATFORM_ESP32,
|
||||
PLATFORM_ESP8266,
|
||||
PLATFORM_HOST,
|
||||
PLATFORM_LN882X,
|
||||
PLATFORM_RP2040,
|
||||
PLATFORM_RTL87XX,
|
||||
)
|
||||
@ -214,7 +215,8 @@ def hex_int__valid(value):
|
||||
("arduino", PLATFORM_RP2040, None, "20", "20", "20", "20"),
|
||||
("arduino", PLATFORM_BK72XX, None, "21", "21", "21", "21"),
|
||||
("arduino", PLATFORM_RTL87XX, None, "22", "22", "22", "22"),
|
||||
("host", PLATFORM_HOST, None, "23", "23", "23", "23"),
|
||||
("arduino", PLATFORM_LN882X, None, "23", "23", "23", "23"),
|
||||
("host", PLATFORM_HOST, None, "24", "24", "24", "24"),
|
||||
],
|
||||
)
|
||||
def test_split_default(framework, platform, variant, full, idf, arduino, simple):
|
||||
@ -244,7 +246,8 @@ def test_split_default(framework, platform, variant, full, idf, arduino, simple)
|
||||
"rp2040": "20",
|
||||
"bk72xx": "21",
|
||||
"rtl87xx": "22",
|
||||
"host": "23",
|
||||
"ln882x": "23",
|
||||
"host": "24",
|
||||
}
|
||||
|
||||
idf_mappings = {
|
||||
|
@ -8,6 +8,7 @@ import pytest
|
||||
from esphome.components.bk72xx.boards import BK72XX_BOARD_PINS
|
||||
from esphome.components.esp32.boards import ESP32_BOARD_PINS
|
||||
from esphome.components.esp8266.boards import ESP8266_BOARD_PINS
|
||||
from esphome.components.ln882x.boards import LN882X_BOARD_PINS
|
||||
from esphome.components.rtl87xx.boards import RTL87XX_BOARD_PINS
|
||||
from esphome.core import CORE
|
||||
import esphome.wizard as wz
|
||||
@ -187,6 +188,27 @@ def test_wizard_write_defaults_platform_from_board_bk72xx(
|
||||
assert "bk72xx:" in generated_config
|
||||
|
||||
|
||||
def test_wizard_write_defaults_platform_from_board_ln882x(
|
||||
default_config, tmp_path, monkeypatch
|
||||
):
|
||||
"""
|
||||
If the platform is not explicitly set, use "LN882X" if the board is one of LN882X boards
|
||||
"""
|
||||
# Given
|
||||
del default_config["platform"]
|
||||
default_config["board"] = [*LN882X_BOARD_PINS][0]
|
||||
|
||||
monkeypatch.setattr(wz, "write_file", MagicMock())
|
||||
monkeypatch.setattr(CORE, "config_path", os.path.dirname(tmp_path))
|
||||
|
||||
# When
|
||||
wz.wizard_write(tmp_path, **default_config)
|
||||
|
||||
# Then
|
||||
generated_config = wz.write_file.call_args.args[1]
|
||||
assert "ln882x:" in generated_config
|
||||
|
||||
|
||||
def test_wizard_write_defaults_platform_from_board_rtl87xx(
|
||||
default_config, tmp_path, monkeypatch
|
||||
):
|
||||
|
Loading…
x
Reference in New Issue
Block a user