VictronMPPT-ESPHOME/components/victron/__init__.py

25 lines
652 B
Python
Raw Normal View History

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
DEPENDENCIES = ["uart"]
AUTO_LOAD = ["sensor", "text_sensor"]
2021-05-30 10:28:38 +00:00
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)