Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Async serial handling #139

Draft
wants to merge 24 commits into
base: main
Choose a base branch
from
4 changes: 4 additions & 0 deletions components/victron/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@

MULTI_CONF = True

CONF_ASYNC_UART = "async_uart"

victron_ns = cg.esphome_ns.namespace("victron")
VictronComponent = victron_ns.class_("VictronComponent", uart.UARTDevice, cg.Component)

Expand All @@ -20,6 +22,7 @@
{
cv.GenerateID(): cv.declare_id(VictronComponent),
cv.Optional(CONF_THROTTLE, default="1s"): cv.positive_time_period_milliseconds,
cv.Optional(CONF_ASYNC_UART, default=False): cv.boolean,
}
)

Expand All @@ -30,3 +33,4 @@ def to_code(config):
yield uart.register_uart_device(var, config)

cg.add(var.set_throttle(config[CONF_THROTTLE]))
cg.add(var.set_async_uart(config[CONF_ASYNC_UART]))
6 changes: 3 additions & 3 deletions components/victron/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,21 +164,21 @@
unit_of_measurement=UNIT_WATT_HOURS,
icon=ICON_POWER,
accuracy_decimals=0,
device_class=DEVICE_CLASS_POWER,
device_class=DEVICE_CLASS_ENERGY,
state_class=STATE_CLASS_TOTAL_INCREASING,
),
cv.Optional(CONF_YIELD_YESTERDAY): sensor.sensor_schema(
unit_of_measurement=UNIT_WATT_HOURS,
icon=ICON_POWER,
accuracy_decimals=0,
device_class=DEVICE_CLASS_POWER,
device_class=DEVICE_CLASS_ENERGY,
state_class=STATE_CLASS_TOTAL_INCREASING,
),
cv.Optional(CONF_YIELD_TODAY): sensor.sensor_schema(
unit_of_measurement=UNIT_WATT_HOURS,
icon=ICON_POWER,
accuracy_decimals=0,
device_class=DEVICE_CLASS_POWER,
device_class=DEVICE_CLASS_ENERGY,
state_class=STATE_CLASS_TOTAL_INCREASING,
),
cv.Optional(CONF_PANEL_VOLTAGE): sensor.sensor_schema(
Expand Down
Loading
Loading