Decode DP127 as 48 bytes (4 alarms), plus DP128, DP107 and DP126, from Tuya's data model. Add day switches, alarm and sunset controls, a knock sensor on PA18, display schedule, bedtime fade, radio timer and grouped web UI. Pin LibreTiny v1.14.0 for the OTA restart fix. Ship the patched UART as an external component so a server needs only a short YAML. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
37 lines
906 B
Python
37 lines
906 B
Python
import esphome.codegen as cg
|
|
from esphome.components import button, uart
|
|
import esphome.config_validation as cv
|
|
from esphome.const import CONF_DATA
|
|
from esphome.core import HexInt
|
|
|
|
from .. import uart_ns, validate_raw_data
|
|
|
|
CODEOWNERS = ["@ssieb"]
|
|
|
|
DEPENDENCIES = ["uart"]
|
|
|
|
UARTButton = uart_ns.class_("UARTButton", button.Button, uart.UARTDevice, cg.Component)
|
|
|
|
|
|
CONFIG_SCHEMA = (
|
|
button.button_schema(UARTButton)
|
|
.extend(
|
|
{
|
|
cv.Required(CONF_DATA): validate_raw_data,
|
|
}
|
|
)
|
|
.extend(uart.UART_DEVICE_SCHEMA)
|
|
.extend(cv.COMPONENT_SCHEMA)
|
|
)
|
|
|
|
|
|
async def to_code(config):
|
|
var = await button.new_button(config)
|
|
await cg.register_component(var, config)
|
|
await uart.register_uart_device(var, config)
|
|
|
|
data = config[CONF_DATA]
|
|
if isinstance(data, bytes):
|
|
data = [HexInt(x) for x in data]
|
|
cg.add(var.set_data(cg.ArrayInitializer(*data)))
|