Improve Bang & Olufsen notification type comparison (#123067)
* Change notification comparison * Use try_parse_enum to determine notification typepull/124361/head
parent
1d1a6ee52f
commit
f33328308c
|
@ -20,6 +20,7 @@ from homeassistant.config_entries import ConfigEntry
|
|||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers import device_registry as dr
|
||||
from homeassistant.helpers.dispatcher import async_dispatcher_send
|
||||
from homeassistant.util.enum import try_parse_enum
|
||||
|
||||
from .const import (
|
||||
BANG_OLUFSEN_WEBSOCKET_EVENT,
|
||||
|
@ -92,12 +93,14 @@ class BangOlufsenWebsocket(BangOlufsenBase):
|
|||
self, notification: WebsocketNotificationTag
|
||||
) -> None:
|
||||
"""Send notification dispatch."""
|
||||
if notification.value:
|
||||
if WebsocketNotification.REMOTE_MENU_CHANGED in notification.value:
|
||||
async_dispatcher_send(
|
||||
self.hass,
|
||||
f"{self._unique_id}_{WebsocketNotification.REMOTE_MENU_CHANGED}",
|
||||
)
|
||||
# Try to match the notification type with available WebsocketNotification members
|
||||
notification_type = try_parse_enum(WebsocketNotification, notification.value)
|
||||
|
||||
if notification_type is 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:
|
||||
"""Send playback_error dispatch."""
|
||||
|
|
Loading…
Reference in New Issue