mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 11:17:21 +00:00
Fix bug in rainbird device ids that are int serial numbers (#104768)
This commit is contained in:
parent
9fa163c107
commit
c72e4e8b5c
@ -183,7 +183,7 @@ def _async_fix_device_id(
|
|||||||
device_entry_map = {}
|
device_entry_map = {}
|
||||||
migrations = {}
|
migrations = {}
|
||||||
for device_entry in device_entries:
|
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
|
device_entry_map[unique_id] = device_entry
|
||||||
if (suffix := unique_id.removeprefix(str(serial_number))) != unique_id:
|
if (suffix := unique_id.removeprefix(str(serial_number))) != unique_id:
|
||||||
migrations[unique_id] = f"{mac_address}{suffix}"
|
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}-rain-delay",
|
||||||
f"{MAC_ADDRESS_UNIQUE_ID}-1",
|
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", 0, "0", "0", MAC_ADDRESS_UNIQUE_ID, MAC_ADDRESS_UNIQUE_ID),
|
||||||
(
|
(
|
||||||
"0",
|
"0",
|
||||||
@ -268,6 +276,7 @@ async def test_fix_unique_id_duplicate(
|
|||||||
ids=(
|
ids=(
|
||||||
"serial-number",
|
"serial-number",
|
||||||
"serial-number-with-suffix",
|
"serial-number-with-suffix",
|
||||||
|
"serial-number-int",
|
||||||
"zero-serial",
|
"zero-serial",
|
||||||
"zero-serial-suffix",
|
"zero-serial-suffix",
|
||||||
"new-format",
|
"new-format",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user