diff --git a/homeassistant/components/bang_olufsen/websocket.py b/homeassistant/components/bang_olufsen/websocket.py index 7415d0f362b..dc505ddf3c4 100644 --- a/homeassistant/components/bang_olufsen/websocket.py +++ b/homeassistant/components/bang_olufsen/websocket.py @@ -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."""