diff --git a/homeassistant/components/bang_olufsen/util.py b/homeassistant/components/bang_olufsen/util.py index 617eb4b1df6..c54b3059ee4 100644 --- a/homeassistant/components/bang_olufsen/util.py +++ b/homeassistant/components/bang_olufsen/util.py @@ -9,11 +9,8 @@ from homeassistant.helpers.device_registry import DeviceEntry from .const import DOMAIN -def get_device(hass: HomeAssistant | None, unique_id: str) -> DeviceEntry | None: +def get_device(hass: HomeAssistant, unique_id: str) -> DeviceEntry: """Get the device.""" - if not isinstance(hass, HomeAssistant): - return None - device_registry = dr.async_get(hass) device = device_registry.async_get_device({(DOMAIN, unique_id)}) assert device diff --git a/homeassistant/components/bang_olufsen/websocket.py b/homeassistant/components/bang_olufsen/websocket.py index dc505ddf3c4..0c0a5096d91 100644 --- a/homeassistant/components/bang_olufsen/websocket.py +++ b/homeassistant/components/bang_olufsen/websocket.py @@ -157,11 +157,6 @@ class BangOlufsenWebsocket(BangOlufsenBase): software_status = await self._client.get_softwareupdate_status() # Update the HA device if the sw version does not match - if not self._device: - self._device = get_device(self.hass, self._unique_id) - - assert self._device - if software_status.software_version != self._device.sw_version: device_registry = dr.async_get(self.hass) @@ -172,10 +167,6 @@ class BangOlufsenWebsocket(BangOlufsenBase): def on_all_notifications_raw(self, notification: dict) -> None: """Receive all notifications.""" - if not self._device: - self._device = get_device(self.hass, self._unique_id) - - assert self._device # Add the device_id and serial_number to the notification notification["device_id"] = self._device.id