mirror of
https://github.com/Threnklyn/esphome-dev.git
synced 2026-06-01 18:48:28 +02:00
dalybms: support changing the address (#3676)
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import esphome.codegen as cg
|
||||
import esphome.config_validation as cv
|
||||
from esphome.components import uart
|
||||
from esphome.const import CONF_ID
|
||||
from esphome.const import CONF_ID, CONF_ADDRESS
|
||||
|
||||
CODEOWNERS = ["@s1lvi0"]
|
||||
DEPENDENCIES = ["uart"]
|
||||
@@ -15,7 +15,12 @@ DalyBmsComponent = daly_bms.class_(
|
||||
)
|
||||
|
||||
CONFIG_SCHEMA = (
|
||||
cv.Schema({cv.GenerateID(): cv.declare_id(DalyBmsComponent)})
|
||||
cv.Schema(
|
||||
{
|
||||
cv.GenerateID(): cv.declare_id(DalyBmsComponent),
|
||||
cv.Optional(CONF_ADDRESS, default=0x80): cv.positive_int,
|
||||
}
|
||||
)
|
||||
.extend(uart.UART_DEVICE_SCHEMA)
|
||||
.extend(cv.polling_component_schema("30s"))
|
||||
)
|
||||
@@ -25,3 +30,4 @@ async def to_code(config):
|
||||
var = cg.new_Pvariable(config[CONF_ID])
|
||||
await cg.register_component(var, config)
|
||||
await uart.register_uart_device(var, config)
|
||||
cg.add(var.set_address(config[CONF_ADDRESS]))
|
||||
|
||||
Reference in New Issue
Block a user