[modbus_controller] Fix linting and formatting issues (#7441)

This commit is contained in:
Jesse Hills 2024-09-16 13:43:45 +12:00 committed by GitHub
parent 3835ad8c1f
commit 73e469ae52
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 54 additions and 59 deletions

View file

@ -1,27 +1,29 @@
import binascii
import esphome.codegen as cg
import esphome.config_validation as cv
from esphome import automation
import esphome.codegen as cg
from esphome.components import modbus
import esphome.config_validation as cv
from esphome.const import (
CONF_ADDRESS,
CONF_ID,
CONF_NAME,
CONF_LAMBDA,
CONF_NAME,
CONF_OFFSET,
CONF_TRIGGER_ID,
)
from esphome.cpp_helpers import logging
from .const import (
CONF_ALLOW_DUPLICATE_COMMANDS,
CONF_BITMASK,
CONF_BYTE_OFFSET,
CONF_COMMAND_THROTTLE,
CONF_OFFLINE_SKIP_UPDATES,
CONF_CUSTOM_COMMAND,
CONF_FORCE_NEW_RANGE,
CONF_MODBUS_CONTROLLER_ID,
CONF_MAX_CMD_RETRIES,
CONF_MODBUS_CONTROLLER_ID,
CONF_OFFLINE_SKIP_UPDATES,
CONF_ON_COMMAND_SENT,
CONF_REGISTER_COUNT,
CONF_REGISTER_TYPE,

View file

@ -1,16 +1,16 @@
import esphome.codegen as cg
from esphome.components import binary_sensor
import esphome.config_validation as cv
import esphome.codegen as cg
from esphome.const import CONF_ADDRESS, CONF_ID
from .. import (
add_modbus_base_properties,
modbus_controller_ns,
modbus_calc_properties,
validate_modbus_register,
MODBUS_REGISTER_TYPE,
ModbusItemBaseSchema,
SensorItem,
MODBUS_REGISTER_TYPE,
add_modbus_base_properties,
modbus_calc_properties,
modbus_controller_ns,
validate_modbus_register,
)
from ..const import (
CONF_BITMASK,

View file

@ -1,6 +1,6 @@
import esphome.codegen as cg
import esphome.config_validation as cv
from esphome.components import number
import esphome.config_validation as cv
from esphome.const import (
CONF_ADDRESS,
CONF_ID,
@ -12,14 +12,13 @@ from esphome.const import (
from .. import (
MODBUS_WRITE_REGISTER_TYPE,
add_modbus_base_properties,
modbus_controller_ns,
modbus_calc_properties,
SENSOR_VALUE_TYPE,
ModbusItemBaseSchema,
SensorItem,
SENSOR_VALUE_TYPE,
add_modbus_base_properties,
modbus_calc_properties,
modbus_controller_ns,
)
from ..const import (
CONF_BITMASK,
CONF_CUSTOM_COMMAND,

View file

@ -1,20 +1,15 @@
import esphome.codegen as cg
import esphome.config_validation as cv
from esphome.components import output
from esphome.const import (
CONF_ADDRESS,
CONF_ID,
CONF_MULTIPLY,
)
import esphome.config_validation as cv
from esphome.const import CONF_ADDRESS, CONF_ID, CONF_MULTIPLY
from .. import (
modbus_controller_ns,
modbus_calc_properties,
SENSOR_VALUE_TYPE,
ModbusItemBaseSchema,
SensorItem,
SENSOR_VALUE_TYPE,
modbus_calc_properties,
modbus_controller_ns,
)
from ..const import (
CONF_MODBUS_CONTROLLER_ID,
CONF_REGISTER_TYPE,
@ -65,6 +60,7 @@ CONFIG_SCHEMA = cv.typed_schema(
async def to_code(config):
byte_offset, reg_count = modbus_calc_properties(config)
# Binary Output
write_template = None
if config[CONF_REGISTER_TYPE] == "coil":
var = cg.new_Pvariable(
config[CONF_ID],
@ -72,7 +68,7 @@ async def to_code(config):
byte_offset,
)
if CONF_WRITE_LAMBDA in config:
template_ = await cg.process_lambda(
write_template = await cg.process_lambda(
config[CONF_WRITE_LAMBDA],
[
(ModbusBinaryOutput.operator("ptr"), "item"),
@ -92,7 +88,7 @@ async def to_code(config):
)
cg.add(var.set_write_multiply(config[CONF_MULTIPLY]))
if CONF_WRITE_LAMBDA in config:
template_ = await cg.process_lambda(
write_template = await cg.process_lambda(
config[CONF_WRITE_LAMBDA],
[
(ModbusFloatOutput.operator("ptr"), "item"),
@ -105,5 +101,5 @@ async def to_code(config):
parent = await cg.get_variable(config[CONF_MODBUS_CONTROLLER_ID])
cg.add(var.set_use_write_mutiple(config[CONF_USE_WRITE_MULTIPLE]))
cg.add(var.set_parent(parent))
if CONF_WRITE_LAMBDA in config:
cg.add(var.set_write_template(template_))
if write_template:
cg.add(var.set_write_template(write_template))

View file

@ -1,6 +1,6 @@
import esphome.codegen as cg
import esphome.config_validation as cv
from esphome.components import select
import esphome.config_validation as cv
from esphome.const import CONF_ADDRESS, CONF_ID, CONF_LAMBDA, CONF_OPTIMISTIC
from .. import (

View file

@ -1,17 +1,17 @@
import esphome.codegen as cg
from esphome.components import sensor
import esphome.config_validation as cv
import esphome.codegen as cg
from esphome.const import CONF_ADDRESS, CONF_ID
from esphome.const import CONF_ID, CONF_ADDRESS
from .. import (
add_modbus_base_properties,
modbus_controller_ns,
modbus_calc_properties,
validate_modbus_register,
ModbusItemBaseSchema,
SensorItem,
MODBUS_REGISTER_TYPE,
SENSOR_VALUE_TYPE,
ModbusItemBaseSchema,
SensorItem,
add_modbus_base_properties,
modbus_calc_properties,
modbus_controller_ns,
validate_modbus_register,
)
from ..const import (
CONF_BITMASK,

View file

@ -1,17 +1,16 @@
import esphome.codegen as cg
from esphome.components import switch
import esphome.config_validation as cv
import esphome.codegen as cg
from esphome.const import CONF_ADDRESS, CONF_ID
from esphome.const import CONF_ID, CONF_ADDRESS
from .. import (
add_modbus_base_properties,
modbus_controller_ns,
modbus_calc_properties,
validate_modbus_register,
MODBUS_REGISTER_TYPE,
ModbusItemBaseSchema,
SensorItem,
MODBUS_REGISTER_TYPE,
add_modbus_base_properties,
modbus_calc_properties,
modbus_controller_ns,
validate_modbus_register,
)
from ..const import (
CONF_BITMASK,

View file

@ -1,26 +1,25 @@
import esphome.codegen as cg
from esphome.components import text_sensor
import esphome.config_validation as cv
import esphome.codegen as cg
from esphome.const import CONF_ADDRESS, CONF_ID
from .. import (
add_modbus_base_properties,
modbus_controller_ns,
modbus_calc_properties,
validate_modbus_register,
MODBUS_REGISTER_TYPE,
ModbusItemBaseSchema,
SensorItem,
MODBUS_REGISTER_TYPE,
add_modbus_base_properties,
modbus_calc_properties,
modbus_controller_ns,
validate_modbus_register,
)
from ..const import (
CONF_FORCE_NEW_RANGE,
CONF_MODBUS_CONTROLLER_ID,
CONF_RAW_ENCODE,
CONF_REGISTER_COUNT,
CONF_REGISTER_TYPE,
CONF_RESPONSE_SIZE,
CONF_SKIP_UPDATES,
CONF_RAW_ENCODE,
CONF_REGISTER_TYPE,
)
DEPENDENCIES = ["modbus_controller"]