mirror of
https://github.com/home-assistant/core.git
synced 2026-09-13 04:01:03 +01:00
Fix Flexit unit ID range (#181788)
This commit is contained in:
@@ -34,7 +34,7 @@ from .const import (
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
UNIT_SELECTOR = vol.All(
|
||||
NumberSelector(NumberSelectorConfig(min=1, max=247, mode=NumberSelectorMode.BOX)),
|
||||
NumberSelector(NumberSelectorConfig(min=1, max=31, mode=NumberSelectorMode.BOX)),
|
||||
vol.Coerce(int),
|
||||
)
|
||||
|
||||
|
||||
@@ -84,7 +84,7 @@ async def test_tcp_host_is_normalized(hass: HomeAssistant) -> None:
|
||||
|
||||
|
||||
async def test_maximum_unit(hass: HomeAssistant) -> None:
|
||||
"""Test the maximum Modbus unit ID is accepted."""
|
||||
"""Test the maximum Flexit unit ID is accepted."""
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN, context={"source": SOURCE_USER}
|
||||
)
|
||||
@@ -93,16 +93,16 @@ async def test_maximum_unit(hass: HomeAssistant) -> None:
|
||||
)
|
||||
|
||||
result = await hass.config_entries.flow.async_configure(
|
||||
result["flow_id"], {**TCP_USER_INPUT, CONF_UNIT: 247}
|
||||
result["flow_id"], {**TCP_USER_INPUT, CONF_UNIT: 31}
|
||||
)
|
||||
|
||||
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result["data"][CONF_UNIT] == 247
|
||||
assert result["data"][CONF_UNIT] == 31
|
||||
|
||||
|
||||
@pytest.mark.parametrize("unit", [0, 248])
|
||||
@pytest.mark.parametrize("unit", [0, 32])
|
||||
async def test_unit_out_of_range(hass: HomeAssistant, unit: int) -> None:
|
||||
"""Test unit IDs outside the Modbus address range are rejected."""
|
||||
"""Test unit IDs outside the Flexit address range are rejected."""
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN, context={"source": SOURCE_USER}
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user