Compare commits

...

3 Commits

Author SHA1 Message Date
epenet
de25f214c7 Use a default constant 2025-09-24 06:07:02 +00:00
epenet
6ea4bb9f9c Reduce 2025-09-24 06:07:02 +00:00
epenet
ff1e822d5d Simplify access to device address in modbus 2025-09-24 06:07:01 +00:00
2 changed files with 5 additions and 5 deletions

View File

@@ -153,7 +153,7 @@ SIGNAL_START_ENTITY = "modbus.start"
# integration names
DEFAULT_HUB = "modbus_hub"
DEFAULT_SCAN_INTERVAL = 15 # seconds
DEFAULT_SLAVE = 1
DEFAULT_DEVICE_ADDRESS = 1
DEFAULT_STRUCTURE_PREFIX = ">f"
DEFAULT_TEMP_UNIT = "C"
DEFAULT_HVAC_ON_VALUE = 1

View File

@@ -62,6 +62,7 @@ from .const import (
CONF_VIRTUAL_COUNT,
CONF_WRITE_TYPE,
CONF_ZERO_SUPPRESS,
DEFAULT_DEVICE_ADDRESS,
SIGNAL_STOP_ENTITY,
DataType,
)
@@ -82,10 +83,9 @@ class ModbusBaseEntity(Entity):
"""Initialize the Modbus binary sensor."""
self._hub = hub
if (conf_slave := entry.get(CONF_SLAVE)) is not None:
self._device_address = conf_slave
else:
self._device_address = entry.get(CONF_DEVICE_ADDRESS, 1)
self._device_address = entry.get(
CONF_DEVICE_ADDRESS, entry.get(CONF_SLAVE, DEFAULT_DEVICE_ADDRESS)
)
self._address = int(entry[CONF_ADDRESS])
self._input_type = entry[CONF_INPUT_TYPE]
self._scan_interval = int(entry[CONF_SCAN_INTERVAL])