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

This commit is contained in:
Allen Porter
2023-11-30 19:44:12 +01:00
committed by Franck Nijhof
parent b4907800a9
commit 4b22551af1
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}"
+9
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",