mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 11:17:21 +00:00
Remove unneeded check for Bang & Olufsen events and device update (#124363)
Remove unneeded check for device and HomeAssistant availability
This commit is contained in:
parent
e56c235424
commit
88b95c1236
@ -9,11 +9,8 @@ from homeassistant.helpers.device_registry import DeviceEntry
|
|||||||
from .const import DOMAIN
|
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."""
|
"""Get the device."""
|
||||||
if not isinstance(hass, HomeAssistant):
|
|
||||||
return None
|
|
||||||
|
|
||||||
device_registry = dr.async_get(hass)
|
device_registry = dr.async_get(hass)
|
||||||
device = device_registry.async_get_device({(DOMAIN, unique_id)})
|
device = device_registry.async_get_device({(DOMAIN, unique_id)})
|
||||||
assert device
|
assert device
|
||||||
|
@ -157,11 +157,6 @@ class BangOlufsenWebsocket(BangOlufsenBase):
|
|||||||
software_status = await self._client.get_softwareupdate_status()
|
software_status = await self._client.get_softwareupdate_status()
|
||||||
|
|
||||||
# Update the HA device if the sw version does not match
|
# 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:
|
if software_status.software_version != self._device.sw_version:
|
||||||
device_registry = dr.async_get(self.hass)
|
device_registry = dr.async_get(self.hass)
|
||||||
|
|
||||||
@ -172,10 +167,6 @@ class BangOlufsenWebsocket(BangOlufsenBase):
|
|||||||
|
|
||||||
def on_all_notifications_raw(self, notification: dict) -> None:
|
def on_all_notifications_raw(self, notification: dict) -> None:
|
||||||
"""Receive all notifications."""
|
"""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
|
# Add the device_id and serial_number to the notification
|
||||||
notification["device_id"] = self._device.id
|
notification["device_id"] = self._device.id
|
||||||
|
Loading…
x
Reference in New Issue
Block a user