mirror of
https://github.com/esphome/esphome.git
synced 2024-11-14 19:18:09 +01:00
Fix clang-format and python lint
This commit is contained in:
parent
d59c40a32c
commit
2d10ad7bff
5 changed files with 22 additions and 34 deletions
|
@ -7,7 +7,7 @@ CODEOWNERS = ["@s1lvi0"]
|
|||
DEPENDENCIES = ["uart"]
|
||||
AUTO_LOAD = ["sensor", "text_sensor", "binary_sensor"]
|
||||
|
||||
CONF_BSM_DALY_ID = "bms_daly_id"
|
||||
BSM_DALY_ID = "bms_daly_id"
|
||||
|
||||
daly_bms = cg.esphome_ns.namespace("daly_bms")
|
||||
DalyBmsComponent = daly_bms.class_("DalyBmsComponent", uart.UARTDevice, cg.Component)
|
||||
|
|
|
@ -2,7 +2,7 @@ import esphome.codegen as cg
|
|||
import esphome.config_validation as cv
|
||||
from esphome.components import binary_sensor
|
||||
from esphome.const import CONF_ID
|
||||
from . import DalyBmsComponent, CONF_BSM_DALY_ID
|
||||
from . import DalyBmsComponent, BSM_DALY_ID
|
||||
|
||||
CONF_CHARGING_MOS_ENABLED = "charging_mos_enabled"
|
||||
CONF_DISCHARGING_MOS_ENABLED = "discharging_mos_enabled"
|
||||
|
@ -15,20 +15,23 @@ TYPES = [
|
|||
CONFIG_SCHEMA = cv.All(
|
||||
cv.Schema(
|
||||
{
|
||||
cv.GenerateID(CONF_BSM_DALY_ID): cv.use_id(DalyBmsComponent),
|
||||
cv.Optional(CONF_CHARGING_MOS_ENABLED): binary_sensor.BINARY_SENSOR_SCHEMA.extend(
|
||||
cv.GenerateID(BSM_DALY_ID): cv.use_id(DalyBmsComponent),
|
||||
cv.Optional(
|
||||
CONF_CHARGING_MOS_ENABLED
|
||||
): binary_sensor.BINARY_SENSOR_SCHEMA.extend(
|
||||
{
|
||||
cv.GenerateID(): cv.declare_id(binary_sensor.BinarySensor),
|
||||
}
|
||||
),
|
||||
cv.Optional(CONF_DISCHARGING_MOS_ENABLED): binary_sensor.BINARY_SENSOR_SCHEMA.extend(
|
||||
cv.Optional(
|
||||
CONF_DISCHARGING_MOS_ENABLED
|
||||
): binary_sensor.BINARY_SENSOR_SCHEMA.extend(
|
||||
{
|
||||
cv.GenerateID(): cv.declare_id(binary_sensor.BinarySensor),
|
||||
}
|
||||
),
|
||||
}
|
||||
)
|
||||
.extend(cv.COMPONENT_SCHEMA)
|
||||
).extend(cv.COMPONENT_SCHEMA)
|
||||
)
|
||||
|
||||
|
||||
|
@ -41,6 +44,6 @@ async def setup_conf(config, key, hub):
|
|||
|
||||
|
||||
async def to_code(config):
|
||||
hub = await cg.get_variable(config[CONF_BSM_DALY_ID])
|
||||
hub = await cg.get_variable(config[BSM_DALY_ID])
|
||||
for key in TYPES:
|
||||
await setup_conf(config, key, hub)
|
||||
|
|
|
@ -74,7 +74,6 @@ void DalyBmsComponent::decode_data(unsigned char *data, int length) {
|
|||
data = start_flag_position;
|
||||
|
||||
if (length >= 13 && data[1] == 0x01) {
|
||||
|
||||
unsigned char checksum;
|
||||
int sum = 0;
|
||||
for (int i = 0; i < 12; i++) {
|
||||
|
|
|
@ -5,6 +5,8 @@ from esphome.const import (
|
|||
CONF_VOLTAGE,
|
||||
CONF_CURRENT,
|
||||
CONF_BATTERY_LEVEL,
|
||||
CONF_MAX_TEMPERATURE,
|
||||
CONF_MIN_TEMPERATURE,
|
||||
DEVICE_CLASS_VOLTAGE,
|
||||
DEVICE_CLASS_CURRENT,
|
||||
DEVICE_CLASS_BATTERY,
|
||||
|
@ -23,19 +25,15 @@ from esphome.const import (
|
|||
ICON_THERMOMETER,
|
||||
ICON_GAUGE,
|
||||
)
|
||||
from . import DalyBmsComponent, CONF_BSM_DALY_ID
|
||||
from . import DalyBmsComponent, BSM_DALY_ID
|
||||
|
||||
CONF_MAX_CELL_VOLTAGE = "max_cell_voltage"
|
||||
CONF_MAX_CELL_VOLTAGE_NUMBER = "max_cell_voltage_number"
|
||||
CONF_MIN_CELL_VOLTAGE = "min_cell_voltage"
|
||||
CONF_MIN_CELL_VOLTAGE_NUMBER = "min_cell_voltage_number"
|
||||
CONF_MAX_TEMPERATURE = "max_temperature"
|
||||
CONF_MAX_TEMPERATURE_PROBE_NUMBER = "max_temperature_probe_number"
|
||||
CONF_MIN_TEMPERATURE = "min_temperature"
|
||||
CONF_MIN_TEMPERATURE_PROBE_NUMBER = "min_temperature_probe_number"
|
||||
CONF_STATUS = "status"
|
||||
CONF_CELLS_NUMBER = "cells_number"
|
||||
CONF_TEMPERATURE_PROBES_NUMBER = "temperature_probe_number"
|
||||
|
||||
CONF_REMAINING_CAPACITY = "remaining_capacity"
|
||||
CONF_TEMPERATURE_1 = "temperature_1"
|
||||
|
@ -62,7 +60,6 @@ TYPES = [
|
|||
CONF_MIN_TEMPERATURE,
|
||||
CONF_MIN_TEMPERATURE_PROBE_NUMBER,
|
||||
CONF_CELLS_NUMBER,
|
||||
CONF_TEMPERATURE_PROBES_NUMBER,
|
||||
CONF_REMAINING_CAPACITY,
|
||||
CONF_TEMPERATURE_1,
|
||||
CONF_TEMPERATURE_2,
|
||||
|
@ -71,7 +68,7 @@ TYPES = [
|
|||
CONFIG_SCHEMA = cv.All(
|
||||
cv.Schema(
|
||||
{
|
||||
cv.GenerateID(CONF_BSM_DALY_ID): cv.use_id(DalyBmsComponent),
|
||||
cv.GenerateID(BSM_DALY_ID): cv.use_id(DalyBmsComponent),
|
||||
cv.Optional(CONF_VOLTAGE): sensor.sensor_schema(
|
||||
UNIT_VOLT,
|
||||
ICON_FLASH,
|
||||
|
@ -163,13 +160,6 @@ CONFIG_SCHEMA = cv.All(
|
|||
DEVICE_CLASS_EMPTY,
|
||||
STATE_CLASS_NONE,
|
||||
),
|
||||
cv.Optional(CONF_TEMPERATURE_PROBES_NUMBER): sensor.sensor_schema(
|
||||
UNIT_EMPTY,
|
||||
ICON_COUNTER,
|
||||
0,
|
||||
DEVICE_CLASS_EMPTY,
|
||||
STATE_CLASS_NONE,
|
||||
),
|
||||
cv.Optional(CONF_TEMPERATURE_1): sensor.sensor_schema(
|
||||
UNIT_CELSIUS,
|
||||
ICON_THERMOMETER,
|
||||
|
@ -185,8 +175,7 @@ CONFIG_SCHEMA = cv.All(
|
|||
STATE_CLASS_MEASUREMENT,
|
||||
),
|
||||
}
|
||||
)
|
||||
.extend(cv.COMPONENT_SCHEMA)
|
||||
).extend(cv.COMPONENT_SCHEMA)
|
||||
)
|
||||
|
||||
|
||||
|
@ -198,6 +187,6 @@ async def setup_conf(config, key, hub):
|
|||
|
||||
|
||||
async def to_code(config):
|
||||
hub = await cg.get_variable(config[CONF_BSM_DALY_ID])
|
||||
hub = await cg.get_variable(config[BSM_DALY_ID])
|
||||
for key in TYPES:
|
||||
await setup_conf(config, key, hub)
|
||||
|
|
|
@ -1,10 +1,8 @@
|
|||
import esphome.codegen as cg
|
||||
import esphome.config_validation as cv
|
||||
from esphome.components import text_sensor
|
||||
from esphome.const import CONF_ICON, CONF_ID
|
||||
from . import DalyBmsComponent, CONF_BSM_DALY_ID
|
||||
|
||||
CONF_STATUS = "status"
|
||||
from esphome.const import CONF_ICON, CONF_ID, CONF_STATUS
|
||||
from . import DalyBmsComponent, BSM_DALY_ID
|
||||
|
||||
ICON_CAR_BATTERY = "mdi:car-battery"
|
||||
|
||||
|
@ -15,7 +13,7 @@ TYPES = [
|
|||
CONFIG_SCHEMA = cv.All(
|
||||
cv.Schema(
|
||||
{
|
||||
cv.GenerateID(CONF_BSM_DALY_ID): cv.use_id(DalyBmsComponent),
|
||||
cv.GenerateID(BSM_DALY_ID): cv.use_id(DalyBmsComponent),
|
||||
cv.Optional(CONF_STATUS): text_sensor.TEXT_SENSOR_SCHEMA.extend(
|
||||
{
|
||||
cv.GenerateID(): cv.declare_id(text_sensor.TextSensor),
|
||||
|
@ -23,8 +21,7 @@ CONFIG_SCHEMA = cv.All(
|
|||
}
|
||||
),
|
||||
}
|
||||
)
|
||||
.extend(cv.COMPONENT_SCHEMA)
|
||||
).extend(cv.COMPONENT_SCHEMA)
|
||||
)
|
||||
|
||||
|
||||
|
@ -37,6 +34,6 @@ async def setup_conf(config, key, hub):
|
|||
|
||||
|
||||
async def to_code(config):
|
||||
hub = await cg.get_variable(config[CONF_BSM_DALY_ID])
|
||||
hub = await cg.get_variable(config[BSM_DALY_ID])
|
||||
for key in TYPES:
|
||||
await setup_conf(config, key, hub)
|
||||
|
|
Loading…
Reference in a new issue