Fix bug in rainbird device ids that are int serial numbers (#104768)
This commit is contained in:
parent
9fa163c107
commit
c72e4e8b5c
2 changed files with 10 additions and 1 deletions
|
@ -183,7 +183,7 @@ def _async_fix_device_id(
|
|||
device_entry_map = {}
|
||||
migrations = {}
|
||||
for device_entry in device_entries:
|
||||
unique_id = next(iter(device_entry.identifiers))[1]
|
||||
unique_id = str(next(iter(device_entry.identifiers))[1])
|
||||
device_entry_map[unique_id] = device_entry
|
||||
if (suffix := unique_id.removeprefix(str(serial_number))) != unique_id:
|
||||
migrations[unique_id] = f"{mac_address}{suffix}"
|
||||
|
|
|
@ -239,6 +239,14 @@ async def test_fix_unique_id_duplicate(
|
|||
f"{MAC_ADDRESS_UNIQUE_ID}-rain-delay",
|
||||
f"{MAC_ADDRESS_UNIQUE_ID}-1",
|
||||
),
|
||||
(
|
||||
SERIAL_NUMBER,
|
||||
SERIAL_NUMBER,
|
||||
SERIAL_NUMBER,
|
||||
SERIAL_NUMBER,
|
||||
MAC_ADDRESS_UNIQUE_ID,
|
||||
MAC_ADDRESS_UNIQUE_ID,
|
||||
),
|
||||
("0", 0, "0", "0", MAC_ADDRESS_UNIQUE_ID, MAC_ADDRESS_UNIQUE_ID),
|
||||
(
|
||||
"0",
|
||||
|
@ -268,6 +276,7 @@ async def test_fix_unique_id_duplicate(
|
|||
ids=(
|
||||
"serial-number",
|
||||
"serial-number-with-suffix",
|
||||
"serial-number-int",
|
||||
"zero-serial",
|
||||
"zero-serial-suffix",
|
||||
"new-format",
|
||||
|
|
Loading…
Add table
Reference in a new issue