Add virtual_count == slave_count in modbus configuration (#100398)
* Add virtual_count as config parameter. * Review (other PR) comments. * Review. * Review comment.
This commit is contained in:
parent
c173ebd11a
commit
ec2364ef43
6 changed files with 29 additions and 8 deletions
|
@ -24,7 +24,12 @@ from homeassistant.helpers.update_coordinator import (
|
|||
|
||||
from . import get_hub
|
||||
from .base_platform import BasePlatform
|
||||
from .const import CALL_TYPE_COIL, CALL_TYPE_DISCRETE, CONF_SLAVE_COUNT
|
||||
from .const import (
|
||||
CALL_TYPE_COIL,
|
||||
CALL_TYPE_DISCRETE,
|
||||
CONF_SLAVE_COUNT,
|
||||
CONF_VIRTUAL_COUNT,
|
||||
)
|
||||
from .modbus import ModbusHub
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
@ -46,7 +51,9 @@ async def async_setup_platform(
|
|||
sensors: list[ModbusBinarySensor | SlaveSensor] = []
|
||||
hub = get_hub(hass, discovery_info[CONF_NAME])
|
||||
for entry in discovery_info[CONF_BINARY_SENSORS]:
|
||||
slave_count = entry.get(CONF_SLAVE_COUNT, 0)
|
||||
slave_count = entry.get(CONF_SLAVE_COUNT, None) or entry.get(
|
||||
CONF_VIRTUAL_COUNT, 0
|
||||
)
|
||||
sensor = ModbusBinarySensor(hub, entry, slave_count)
|
||||
if slave_count > 0:
|
||||
sensors.extend(await sensor.async_setup_slaves(hass, slave_count, entry))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue