2026-11-19 00:31:45 +01:00
|
|
|
from esphome import automation
|
2026-11-05 12:27:54 +01:00
|
|
|
from esphome.components import button, uart
|
|
|
|
|
import esphome.config_validation as cv
|
2026-11-19 00:31:45 +01:00
|
|
|
from esphome.const import CONF_DATA, CONF_UART_ID
|
|
|
|
|
from esphome.types import ConfigType
|
2026-11-05 12:27:54 +01:00
|
|
|
|
2026-11-19 00:31:45 +01:00
|
|
|
from .. import validate_raw_payload
|
2026-11-05 12:27:54 +01:00
|
|
|
|
|
|
|
|
CODEOWNERS = ["@ssieb"]
|
|
|
|
|
|
|
|
|
|
DEPENDENCIES = ["uart"]
|
|
|
|
|
|
|
|
|
|
CONFIG_SCHEMA = (
|
2026-11-19 00:31:45 +01:00
|
|
|
button.button_schema(button.ApplyButton)
|
2026-11-05 12:27:54 +01:00
|
|
|
.extend(
|
|
|
|
|
{
|
2026-11-19 00:31:45 +01:00
|
|
|
cv.Required(CONF_DATA): validate_raw_payload,
|
2026-11-05 12:27:54 +01:00
|
|
|
}
|
|
|
|
|
)
|
|
|
|
|
.extend(uart.UART_DEVICE_SCHEMA)
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
2026-11-19 00:31:45 +01:00
|
|
|
async def to_code(config: ConfigType) -> None:
|
2026-11-05 12:27:54 +01:00
|
|
|
data = config[CONF_DATA]
|
2026-11-19 00:31:45 +01:00
|
|
|
table = automation.progmem_bytes("uart_data", data)
|
|
|
|
|
await button.sub_buttons(config, parent=config[CONF_UART_ID]).create(
|
|
|
|
|
config, None, apply=f"write_array_progmem({table}, {len(data)})"
|
|
|
|
|
)
|