Skip to content

Commit d8fa4ec

Browse files
committed
Update API
Define parallel updates Add diagnostics
1 parent 2ea683b commit d8fa4ec

File tree

10 files changed

+139
-38
lines changed

10 files changed

+139
-38
lines changed

custom_components/bang_olufsen/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
from homeassistant.const import CONF_HOST, CONF_MODEL, Platform
1414
from homeassistant.core import HomeAssistant
1515
from homeassistant.exceptions import ConfigEntryNotReady
16-
from homeassistant.helpers import device_registry as dr
16+
import homeassistant.helpers.device_registry as dr
1717
from homeassistant.util.ssl import get_default_context
1818

1919
from .const import BEO_REMOTE_MODEL, DOMAIN
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
"""Support for Bang & Olufsen diagnostics."""
2+
3+
from __future__ import annotations
4+
5+
from typing import Any
6+
7+
from homeassistant.core import HomeAssistant
8+
9+
from . import BangOlufsenConfigEntry
10+
11+
12+
async def async_get_config_entry_diagnostics(
13+
hass: HomeAssistant, config_entry: BangOlufsenConfigEntry
14+
) -> dict[str, Any]:
15+
"""Return diagnostics for a config entry."""
16+
17+
return {
18+
"websocket_connected": config_entry.runtime_data.client.websocket_connected,
19+
"config_entry": config_entry.as_dict(),
20+
}

custom_components/bang_olufsen/icons.json

+9-27
Original file line numberDiff line numberDiff line change
@@ -326,32 +326,14 @@
326326
}
327327
},
328328
"services": {
329-
"beolink_allstandby": {
330-
"service": "mdi:close-circle-multiple-outline"
331-
},
332-
"beolink_expand": {
333-
"service": "mdi:location-enter"
334-
},
335-
"beolink_join": {
336-
"service": "mdi:location-enter"
337-
},
338-
"beolink_leader_command": {
339-
"service": "mdi:location-enter"
340-
},
341-
"beolink_leave": {
342-
"service": "mdi:close-circle-outline"
343-
},
344-
"beolink_set_relative_volume": {
345-
"service": "mdi:volume-plus"
346-
},
347-
"beolink_set_volume": {
348-
"service": "mdi:volume-equal"
349-
},
350-
"beolink_unexpand": {
351-
"service": "mdi:location-exit"
352-
},
353-
"reboot": {
354-
"service": "mdi:restart"
355-
}
329+
"beolink_allstandby": { "service": "mdi:close-circle-multiple-outline" },
330+
"beolink_expand": { "service": "mdi:location-enter" },
331+
"beolink_join": { "service": "mdi:location-enter" },
332+
"beolink_leader_command": { "service": "mdi:location-enter" },
333+
"beolink_leave": { "service": "mdi:close-circle-outline" },
334+
"beolink_set_relative_volume": { "service": "mdi:volume-plus" },
335+
"beolink_set_volume": { "service": "mdi:volume-equal" },
336+
"beolink_unexpand": { "service": "mdi:location-exit" },
337+
"reboot": { "service": "mdi:restart" }
356338
}
357339
}

custom_components/bang_olufsen/manifest.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"integration_type": "device",
99
"iot_class": "local_push",
1010
"issue_tracker": "https://github.com/bang-olufsen/bang_olufsen-hacs/issues",
11-
"requirements": ["mozart-api==4.1.1.116.0"],
11+
"requirements": ["mozart-api==4.1.1.116.3"],
1212
"version": "3.1.0",
1313
"zeroconf": ["_bangolufsen._tcp.local."]
1414
}

custom_components/bang_olufsen/media_player.py

+3
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,8 @@
101101
from .entity import BangOlufsenEntity
102102
from .util import get_serial_number_from_jid
103103

104+
PARALLEL_UPDATES = 0
105+
104106
SCAN_INTERVAL = timedelta(seconds=30)
105107

106108
_LOGGER = logging.getLogger(__name__)
@@ -247,6 +249,7 @@ def __init__(self, config_entry: BangOlufsenConfigEntry) -> None:
247249
serial_number=self._unique_id,
248250
)
249251
self._attr_unique_id = self._unique_id
252+
self._attr_should_poll = True
250253

251254
# Misc. variables.
252255
self._audio_sources: dict[str, str] = {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
rules:
2+
# Bronze
3+
config-flow: done
4+
test-before-configure: done
5+
unique-config-entry: done
6+
config-flow-test-coverage: done
7+
runtime-data: done
8+
test-before-setup: done
9+
appropriate-polling: done
10+
entity-unique-id: done
11+
has-entity-name: done
12+
entity-event-setup: done
13+
dependency-transparency: done
14+
action-setup:
15+
status: exempt
16+
comment: This integration only provides entity service actions
17+
common-modules: done
18+
docs-high-level-description: done
19+
docs-installation-instructions: done
20+
docs-removal-instructions:
21+
status: todo
22+
comment: Nothing special has to be done, but I will look at it
23+
docs-actions: done
24+
brands: done
25+
# Silver
26+
config-entry-unloading: done
27+
log-when-unavailable: done
28+
entity-unavailable: done
29+
action-exceptions: done
30+
reauthentication-flow:
31+
status: exempt
32+
comment: This integration does not need any authentication
33+
parallel-updates: done
34+
test-coverage: done
35+
integration-owner: done
36+
docs-installation-parameters: done
37+
docs-configuration-parameters:
38+
status: exempt
39+
comment: This integration does provide configuration options
40+
# Gold
41+
entity-translations:
42+
status: exempt
43+
comment: This integration does not provide any entities that are suitable for translations. The media_player entity's name is simply the friendly name of the device.
44+
entity-device-class: done
45+
devices: done
46+
entity-category: done
47+
entity-disabled-by-default:
48+
status: exempt
49+
comment: This integration only provides a single entity that is enabled by default
50+
discovery: done
51+
stale-devices:
52+
status: exempt
53+
comment: No devices should be removed at this point.
54+
diagnostics: done
55+
exception-translations: done
56+
icon-translations: done
57+
reconfiguration-flow:
58+
status: exempt
59+
comment: Reconfiguration not necessary.
60+
dynamic-devices:
61+
status: exempt
62+
comment: No devices are dynamically added at this point.
63+
discovery-update-info: done
64+
repair-issues:
65+
status: exempt
66+
comment: Not necessary at this point.
67+
docs-use-cases:
68+
status: todo
69+
comment: Could be better.
70+
docs-supported-devices:
71+
status: todo
72+
comment: This is currently done, but should maybe also refer to the specific platform. (https://support.bang-olufsen.com/hc/en-us/articles/24766979863441-Which-platform-is-my-Connected-Audio-product-based-on)
73+
docs-supported-functions:
74+
status: todo
75+
comment: Could be better.
76+
docs-data-update:
77+
status: todo
78+
comment: Is currently not described.
79+
docs-known-limitations:
80+
status: todo
81+
comment: Is currently not described.
82+
docs-troubleshooting:
83+
status: todo
84+
comment: Is currently not described, but may not be necessary?
85+
docs-examples:
86+
status: todo
87+
comment: Action examples are provided but not any blueprints.
88+
# Platinum
89+
async-dependency: done
90+
inject-websession: done
91+
strict-typing: done

custom_components/bang_olufsen/sensor.py

+2
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@
2828

2929
SCAN_INTERVAL = timedelta(minutes=15)
3030

31+
PARALLEL_UPDATES = 0
32+
3133

3234
async def async_setup_entry(
3335
hass: HomeAssistant,

custom_components/bang_olufsen/strings.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"timeout_error": "[%key:common::config_flow::error::cannot_connect%]"
1919
},
2020
"abort": {
21-
"already_configured": "[%key:common::config_flow::abort::single_instance_allowed%]",
21+
"already_configured": "[%key:common::config_flow::abort::already_configured_device%]",
2222
"already_in_progress": "[%key:common::config_flow::abort::already_in_progress%]"
2323
},
2424
"flow_title": "{name}",

custom_components/bang_olufsen/translations/en.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
},
1313
"config": {
1414
"abort": {
15-
"already_configured": "Already configured. Only a single configuration possible.",
15+
"already_configured": "Device is already configured",
1616
"already_in_progress": "Configuration flow is already in progress"
1717
},
1818
"error": {

custom_components/bang_olufsen/websocket.py

+10-7
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
VolumeState,
2020
WebsocketNotificationTag,
2121
)
22-
from mozart_api.mozart_client import MozartClient
22+
from mozart_api.mozart_client import BaseWebSocketResponse, MozartClient
2323

2424
from homeassistant.config_entries import ConfigEntry
2525
from homeassistant.core import HomeAssistant
@@ -285,12 +285,15 @@ async def on_software_update_state(self, _: SoftwareUpdateState) -> None:
285285
sw_version=software_status.software_version,
286286
)
287287

288-
def on_all_notifications_raw(self, notification: dict) -> None:
288+
def on_all_notifications_raw(self, notification: BaseWebSocketResponse) -> None:
289289
"""Receive all notifications."""
290290

291-
# Add the device_id and serial_number to the notification
292-
notification["device_id"] = self._device.id
293-
notification["serial_number"] = int(self._unique_id)
294-
295291
_LOGGER.debug("%s", notification)
296-
self.hass.bus.async_fire(BANG_OLUFSEN_WEBSOCKET_EVENT, notification)
292+
self.hass.bus.async_fire(
293+
BANG_OLUFSEN_WEBSOCKET_EVENT,
294+
{
295+
"device_id": self._device.id,
296+
"serial_number": int(self._unique_id),
297+
**notification,
298+
},
299+
)

0 commit comments

Comments
 (0)