diff --git a/homeassistant/components/bang_olufsen/websocket.py b/homeassistant/components/bang_olufsen/websocket.py index ff3ad849e92..bc817226b61 100644 --- a/homeassistant/components/bang_olufsen/websocket.py +++ b/homeassistant/components/bang_olufsen/websocket.py @@ -204,13 +204,11 @@ class BangOlufsenWebsocket(BangOlufsenBase): def on_all_notifications_raw(self, notification: BaseWebSocketResponse) -> None: """Receive all notifications.""" + debug_notification = { + "device_id": self._device.id, + "serial_number": int(self._unique_id), + **notification, + } - _LOGGER.debug("%s", notification) - self.hass.bus.async_fire( - BANG_OLUFSEN_WEBSOCKET_EVENT, - { - "device_id": self._device.id, - "serial_number": int(self._unique_id), - **notification, - }, - ) + _LOGGER.debug("%s", debug_notification) + self.hass.bus.async_fire(BANG_OLUFSEN_WEBSOCKET_EVENT, debug_notification) diff --git a/tests/components/bang_olufsen/test_websocket.py b/tests/components/bang_olufsen/test_websocket.py index b17859a4f4e..ecf5b2d011e 100644 --- a/tests/components/bang_olufsen/test_websocket.py +++ b/tests/components/bang_olufsen/test_websocket.py @@ -135,7 +135,6 @@ async def test_on_all_notifications_raw( }, "eventType": "WebSocketEventVolume", } - raw_notification_full = raw_notification # Get device ID for the modified notification that is sent as an event and in the log assert mock_config_entry.unique_id @@ -144,12 +143,11 @@ async def test_on_all_notifications_raw( identifiers={(DOMAIN, mock_config_entry.unique_id)} ) ) - raw_notification_full.update( - { - "device_id": device.id, - "serial_number": mock_config_entry.unique_id, - } - ) + raw_notification_full = { + "device_id": device.id, + "serial_number": int(mock_config_entry.unique_id), + **raw_notification, + } caplog.set_level(logging.DEBUG)