dalybms: support changing the address (#3676)

This commit is contained in:
Samuel Sieb
2022-08-02 12:48:02 -07:00
committed by GitHub
parent 98aa3d51ed
commit ba7737e9f8
3 changed files with 12 additions and 3 deletions
+8 -2
View File
@@ -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]))