mirror of
https://github.com/home-assistant/core.git
synced 2025-11-16 06:20:07 +00:00
deconz: Use partition instead of split where possible (#81804)
* deconz: Use partition instead of split where possible With a smattering of code deduplication Split out of #81493 * Update homeassistant/components/deconz/util.py Co-authored-by: Robert Svensson <Kane610@users.noreply.github.com> Co-authored-by: Robert Svensson <Kane610@users.noreply.github.com>
This commit is contained in:
@@ -33,6 +33,7 @@ import homeassistant.helpers.entity_registry as er
|
||||
from .const import ATTR_DARK, ATTR_ON, DOMAIN as DECONZ_DOMAIN
|
||||
from .deconz_device import DeconzDevice
|
||||
from .gateway import DeconzGateway, get_gateway_from_config_entry
|
||||
from .util import serial_from_unique_id
|
||||
|
||||
_SensorDeviceT = TypeVar("_SensorDeviceT", bound=PydeconzSensorBase)
|
||||
|
||||
@@ -187,7 +188,9 @@ def async_update_unique_id(
|
||||
return
|
||||
|
||||
if description.old_unique_id_suffix:
|
||||
unique_id = f'{unique_id.split("-", 1)[0]}-{description.old_unique_id_suffix}'
|
||||
unique_id = (
|
||||
f"{serial_from_unique_id(unique_id)}-{description.old_unique_id_suffix}"
|
||||
)
|
||||
|
||||
if entity_id := ent_reg.async_get_entity_id(DOMAIN, DECONZ_DOMAIN, unique_id):
|
||||
ent_reg.async_update_entity(entity_id, new_unique_id=new_unique_id)
|
||||
|
||||
Reference in New Issue
Block a user