Home Assistant Unofficial Reference 2024.12.1
util.py
Go to the documentation of this file.
1 """Various utilities for the Bang & Olufsen integration."""
2 
3 from __future__ import annotations
4 
5 from homeassistant.core import HomeAssistant
6 from homeassistant.helpers import device_registry as dr
7 from homeassistant.helpers.device_registry import DeviceEntry
8 
9 from .const import DOMAIN
10 
11 
12 def get_device(hass: HomeAssistant, unique_id: str) -> DeviceEntry:
13  """Get the device."""
14  device_registry = dr.async_get(hass)
15  device = device_registry.async_get_device({(DOMAIN, unique_id)})
16  assert device
17 
18  return device
19 
20 
21 def get_serial_number_from_jid(jid: str) -> str:
22  """Get serial number from Beolink JID."""
23  return jid.split(".")[2].split("@")[0]
DeviceEntry get_device(HomeAssistant hass, str unique_id)
Definition: util.py:12