diff --git a/custom_components/bangolufsen/coordinator.py b/custom_components/bangolufsen/coordinator.py index d21c55e..c671095 100644 --- a/custom_components/bangolufsen/coordinator.py +++ b/custom_components/bangolufsen/coordinator.py @@ -323,7 +323,7 @@ def on_volume_notification(self, notification: VolumeState) -> None: notification, ) - def on_software_update_state(self, _: SoftwareUpdateState) -> None: + def on_software_update_state(self, notification: SoftwareUpdateState) -> None: """Check device sw version.""" # Get software version. diff --git a/custom_components/bangolufsen/manifest.json b/custom_components/bangolufsen/manifest.json index 40438c4..5b14eb7 100644 --- a/custom_components/bangolufsen/manifest.json +++ b/custom_components/bangolufsen/manifest.json @@ -7,6 +7,6 @@ "iot_class": "local_push", "issue_tracker": "https://github.com/bang-olufsen/bangolufsen-hacs/issues", "requirements": ["mozart-api==2.5.3.123.1"], - "version": "1.0.5", + "version": "1.0.6", "zeroconf": ["_bangolufsen._tcp.local."] } diff --git a/custom_components/bangolufsen/select.py b/custom_components/bangolufsen/select.py index 5f4dc63..f4b9834 100644 --- a/custom_components/bangolufsen/select.py +++ b/custom_components/bangolufsen/select.py @@ -1,6 +1,8 @@ """Select entities for the Bang & Olufsen Mozart integration.""" from __future__ import annotations +import logging + from mozart_api.models import ListeningModeProps, SpeakerGroupOverview from homeassistant.components.select import SelectEntity @@ -12,6 +14,8 @@ from .const import DOMAIN, BangOlufsenEntity, EntityEnum, WebSocketNotification +_LOGGER = logging.getLogger(__name__) + async def async_setup_entry( hass: HomeAssistant, @@ -151,23 +155,26 @@ async def _update_listening_positions( ).get() self._listening_positions = {} - index = 0 # Listening positions for scene_key in scenes: scene = scenes[scene_key] if scene.tags is not None and "listeningposition" in scene.tags: - # Ensure that the label is unique - label = f"{scene.label} - {index}" + # Ignore listening positions with the same name + if scene.label in self._listening_positions: + _LOGGER.warning( + "Ignoring listening position with duplicate name: %s and ID: %s", + scene.label, + scene_key, + ) + continue - self._listening_positions[label] = scene_key + self._listening_positions[scene.label] = scene_key # Currently guess the current active listening position by the speakergroup ID if active_speaker_group.id == scene.action_list[0].speaker_group_id: - self._attr_current_option = label - - index += 1 + self._attr_current_option = scene.label self._attr_options = list(self._listening_positions.keys())