2021-05-30 10:28:38 +00:00
|
|
|
import esphome.codegen as cg
|
|
|
|
import esphome.config_validation as cv
|
|
|
|
from esphome.components import uart
|
|
|
|
from esphome.const import CONF_ID
|
|
|
|
|
2021-08-29 07:04:25 +00:00
|
|
|
AUTO_LOAD = ["sensor", "text_sensor"]
|
2021-05-30 10:28:38 +00:00
|
|
|
|
2021-09-01 09:56:00 +00:00
|
|
|
DEPENDENCIES = ["uart"]
|
|
|
|
|
|
|
|
CODEOWNERS = ["@KinDR007"]
|
|
|
|
|
|
|
|
MULTI_CONF = True
|
|
|
|
|
2021-08-29 07:04:25 +00:00
|
|
|
victron_ns = cg.esphome_ns.namespace("victron")
|
|
|
|
VictronComponent = victron_ns.class_("VictronComponent", uart.UARTDevice, cg.Component)
|
2021-05-30 10:28:38 +00:00
|
|
|
|
|
|
|
CONF_VICTRON_ID = "victron_id"
|
|
|
|
|
2021-08-29 07:04:25 +00:00
|
|
|
CONFIG_SCHEMA = uart.UART_DEVICE_SCHEMA.extend(
|
|
|
|
{
|
|
|
|
cv.GenerateID(): cv.declare_id(VictronComponent),
|
|
|
|
}
|
|
|
|
)
|
|
|
|
|
2021-05-30 10:28:38 +00:00
|
|
|
|
|
|
|
def to_code(config):
|
|
|
|
var = cg.new_Pvariable(config[CONF_ID])
|
|
|
|
yield cg.register_component(var, config)
|
|
|
|
yield uart.register_uart_device(var, config)
|