mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 21:27:38 +00:00
Improve Bang & Olufsen notification type comparison (#123067)
* Change notification comparison * Use try_parse_enum to determine notification type
This commit is contained in:
parent
1d1a6ee52f
commit
f33328308c
@ -20,6 +20,7 @@ from homeassistant.config_entries import ConfigEntry
|
|||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.helpers import device_registry as dr
|
from homeassistant.helpers import device_registry as dr
|
||||||
from homeassistant.helpers.dispatcher import async_dispatcher_send
|
from homeassistant.helpers.dispatcher import async_dispatcher_send
|
||||||
|
from homeassistant.util.enum import try_parse_enum
|
||||||
|
|
||||||
from .const import (
|
from .const import (
|
||||||
BANG_OLUFSEN_WEBSOCKET_EVENT,
|
BANG_OLUFSEN_WEBSOCKET_EVENT,
|
||||||
@ -92,12 +93,14 @@ class BangOlufsenWebsocket(BangOlufsenBase):
|
|||||||
self, notification: WebsocketNotificationTag
|
self, notification: WebsocketNotificationTag
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Send notification dispatch."""
|
"""Send notification dispatch."""
|
||||||
if notification.value:
|
# Try to match the notification type with available WebsocketNotification members
|
||||||
if WebsocketNotification.REMOTE_MENU_CHANGED in notification.value:
|
notification_type = try_parse_enum(WebsocketNotification, notification.value)
|
||||||
async_dispatcher_send(
|
|
||||||
self.hass,
|
if notification_type is WebsocketNotification.REMOTE_MENU_CHANGED:
|
||||||
f"{self._unique_id}_{WebsocketNotification.REMOTE_MENU_CHANGED}",
|
async_dispatcher_send(
|
||||||
)
|
self.hass,
|
||||||
|
f"{self._unique_id}_{WebsocketNotification.REMOTE_MENU_CHANGED}",
|
||||||
|
)
|
||||||
|
|
||||||
def on_playback_error_notification(self, notification: PlaybackError) -> None:
|
def on_playback_error_notification(self, notification: PlaybackError) -> None:
|
||||||
"""Send playback_error dispatch."""
|
"""Send playback_error dispatch."""
|
||||||
|
Loading…
x
Reference in New Issue
Block a user