Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve Bang & Olufsen notification type comparison #123067

Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Use try_parse_enum to determine notification type
  • Loading branch information
mj23000 committed Aug 8, 2024
commit d0f4d69df727e0a64ce4ade5765aa68b839eef1c
15 changes: 9 additions & 6 deletions homeassistant/components/bang_olufsen/websocket.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
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,
Expand Down Expand Up @@ -92,12 +93,14 @@
self, notification: WebsocketNotificationTag
) -> None:
"""Send notification dispatch."""
if notification.value:
if notification.value == WebsocketNotification.REMOTE_MENU_CHANGED:
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)

Check warning on line 97 in homeassistant/components/bang_olufsen/websocket.py

View check run for this annotation

Codecov / codecov/patch

homeassistant/components/bang_olufsen/websocket.py#L97

Added line #L97 was not covered by tests

if notification_type is WebsocketNotification.REMOTE_MENU_CHANGED:
async_dispatcher_send(

Check warning on line 100 in homeassistant/components/bang_olufsen/websocket.py

View check run for this annotation

Codecov / codecov/patch

homeassistant/components/bang_olufsen/websocket.py#L99-L100

Added lines #L99 - L100 were not covered by tests
self.hass,
f"{self._unique_id}_{WebsocketNotification.REMOTE_MENU_CHANGED}",
)

def on_playback_error_notification(self, notification: PlaybackError) -> None:
"""Send playback_error dispatch."""
Expand Down