Fix bug in rainbird device ids that are int serial numbers (#104768)

This commit is contained in:
Allen Porter 2023-11-29 21:11:38 -08:00 committed by GitHub
parent 9fa163c107
commit c72e4e8b5c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 1 deletions

View file

@ -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}"

View file

@ -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",