Remove unneeded check for Bang & Olufsen events and device update (#124363)

Remove unneeded check for device and HomeAssistant availability
pull/123075/head
Markus Jacobsen 2024-08-21 17:03:21 +02:00 committed by GitHub
parent e56c235424
commit 88b95c1236
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 1 additions and 13 deletions

View File

@ -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

View File

@ -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