Fit this lamp: 4 alarms, full data model, knock snooze, server use

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>
This commit is contained in:
mangavalkandClaude Opus 5.5 committed 2026-11-05 12:27:54 +01:00
1 parent 3e3358af08
commit a8f6bb3ca5
36 files changed
+5132 -214

No files matched your search

+36
View File
@@ -0,0 +1,36 @@
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)))
+15
View File
@@ -0,0 +1,15 @@
#include "uart_button.h"
#include "esphome/core/log.h"
namespace esphome::uart {
static const char *const TAG = "uart.button";
void UARTButton::press_action() {
ESP_LOGD(TAG, "'%s': Sending data", this->get_name().c_str());
this->write_array(this->data_.data(), this->data_.size());
}
void UARTButton::dump_config() { LOG_BUTTON("", "UART Button", this); }
} // namespace esphome::uart
+23
View File
@@ -0,0 +1,23 @@
#pragma once
#include "esphome/core/component.h"
#include "esphome/components/uart/uart.h"
#include "esphome/components/button/button.h"
#include <vector>
namespace esphome::uart {
class UARTButton final : public button::Button, public UARTDevice, public Component {
public:
void set_data(std::vector<uint8_t> &&data) { this->data_ = std::move(data); }
void set_data(std::initializer_list<uint8_t> data) { this->data_ = std::vector<uint8_t>(data); }
void dump_config() override;
protected:
void press_action() override;
std::vector<uint8_t> data_;
};
} // namespace esphome::uart