Allow [##:##:##] type keypad address in homeworks (#115762)

Allow [##:##:##] type keypad address
This commit is contained in:
Erik Montnemery 2024-04-17 15:04:37 +02:00 committed by GitHub
parent e45583b83b
commit 764a0f29cc
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 10 additions and 6 deletions

View File

@ -93,7 +93,7 @@ BUTTON_EDIT = {
}
validate_addr = cv.matches_regex(r"\[\d\d:\d\d:\d\d:\d\d\]")
validate_addr = cv.matches_regex(r"\[(?:\d\d:)?\d\d:\d\d:\d\d\]")
async def validate_add_controller(

View File

@ -544,8 +544,12 @@ async def test_options_add_remove_light_flow(
)
@pytest.mark.parametrize("keypad_address", ["[02:08:03:01]", "[02:08:03]"])
async def test_options_add_remove_keypad_flow(
hass: HomeAssistant, mock_config_entry: MockConfigEntry, mock_homeworks: MagicMock
hass: HomeAssistant,
mock_config_entry: MockConfigEntry,
mock_homeworks: MagicMock,
keypad_address: str,
) -> None:
"""Test options flow to add and remove a keypad."""
mock_config_entry.add_to_hass(hass)
@ -566,7 +570,7 @@ async def test_options_add_remove_keypad_flow(
result = await hass.config_entries.options.async_configure(
result["flow_id"],
user_input={
CONF_ADDR: "[02:08:03:01]",
CONF_ADDR: keypad_address,
CONF_NAME: "Hall Keypad",
},
)
@ -592,7 +596,7 @@ async def test_options_add_remove_keypad_flow(
],
"name": "Foyer Keypad",
},
{"addr": "[02:08:03:01]", "buttons": [], "name": "Hall Keypad"},
{"addr": keypad_address, "buttons": [], "name": "Hall Keypad"},
],
"port": 1234,
}
@ -612,7 +616,7 @@ async def test_options_add_remove_keypad_flow(
assert result["step_id"] == "remove_keypad"
assert result["data_schema"].schema["index"].options == {
"0": "Foyer Keypad ([02:08:02:01])",
"1": "Hall Keypad ([02:08:03:01])",
"1": f"Hall Keypad ({keypad_address})",
}
result = await hass.config_entries.options.async_configure(
@ -625,7 +629,7 @@ async def test_options_add_remove_keypad_flow(
{"addr": "[02:08:01:01]", "name": "Foyer Sconces", "rate": 1.0},
],
"host": "192.168.0.1",
"keypads": [{"addr": "[02:08:03:01]", "buttons": [], "name": "Hall Keypad"}],
"keypads": [{"addr": keypad_address, "buttons": [], "name": "Hall Keypad"}],
"port": 1234,
}
await hass.async_block_till_done()