* 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>
9 lines
319 B
Python
9 lines
319 B
Python
"""Utilities for deCONZ integration."""
|
|
from __future__ import annotations
|
|
|
|
|
|
def serial_from_unique_id(unique_id: str | None) -> str | None:
|
|
"""Get a device serial number from a unique ID, if possible."""
|
|
if not unique_id or unique_id.count(":") != 7:
|
|
return None
|
|
return unique_id.partition("-")[0]
|