Skip to content

Commit

Permalink
Convert source parameter in beolink join action to option selector
Browse files Browse the repository at this point in the history
Bump version
  • Loading branch information
mj23000 committed Dec 5, 2024
1 parent a3124bf commit 7a0c9ca
Show file tree
Hide file tree
Showing 6 changed files with 59 additions and 6 deletions.
3 changes: 3 additions & 0 deletions custom_components/bang_olufsen/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -420,3 +420,6 @@ class WebsocketNotification(StrEnum):
STR_PARAMETERS,
NONE_PARAMETERS,
)

# Prefix for Beolink Converter NL/ML in async_beolink_join custom service
BL_CONVERTER_PREFIX = "bc_nlml_"
2 changes: 1 addition & 1 deletion custom_components/bang_olufsen/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@
"iot_class": "local_push",
"issue_tracker": "https://github.com/bang-olufsen/bang_olufsen-hacs/issues",
"requirements": ["mozart-api==4.1.1.116.3"],
"version": "3.1.0",
"version": "3.1.1",
"zeroconf": ["_bangolufsen._tcp.local."]
}
6 changes: 6 additions & 0 deletions custom_components/bang_olufsen/media_player.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@
BEOLINK_LISTENER_COMMAND,
BEOLINK_RELATIVE_VOLUME,
BEOLINK_VOLUME,
BL_CONVERTER_PREFIX,
CONF_BEOLINK_JID,
CONNECTION_STATUS,
DOMAIN,
Expand Down Expand Up @@ -1165,6 +1166,11 @@ async def async_beolink_join(
response = await self._client.join_beolink_peer(jid=beolink_jid)
# Join a peer and select specific source
elif beolink_jid and source_id:
# Home Assistant does not support the "raw" Beolink Converter NL/ML source ids in strings.json
# So they have the be transformed to be compatible and now have to be capatilized in order to work
if BL_CONVERTER_PREFIX in source_id:
source_id = source_id.removeprefix(BL_CONVERTER_PREFIX).upper()

response = await self._client.join_beolink_peer(
jid=beolink_jid, source=source_id
)
Expand Down
14 changes: 13 additions & 1 deletion custom_components/bang_olufsen/services.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,19 @@ beolink_join:
required: false
example: tidal
selector:
text:
select:
translation_key: "source_ids"
options:
- deezer
- spotify
- tidal
- beoradio
- bc_nlml_radio
- bc_nlml_tp1
- bc_nlml_tp2
- bc_nlml_cd
- bc_nlml_aux_a
- bc_nlml_ph

beolink_leader_command:
target:
Expand Down
20 changes: 18 additions & 2 deletions custom_components/bang_olufsen/strings.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,22 @@
}
}
},
"selector": {
"source_ids": {
"options": {
"deezer": "Deezer",
"spotify": "Spotify",
"tidal": "Mozart Tidal",
"beoradio": "ASE Beoradio",
"bc_nlml_radio": "Beolink Converter NL/ML RADIO",
"bc_nlml_tp1": "Beolink Converter NL/ML TP1",
"bc_nlml_tp2": "Beolink Converter NL/ML TP2",
"bc_nlml_cd": "Beolink Converter NL/ML CD",
"bc_nlml_aux_a": "Beolink Converter NL/ML AUX_A",
"bc_nlml_ph": "Beolink Converter NL/ML PH"
}
}
},
"services": {
"beolink_allstandby": {
"name": "Beolink all standby",
Expand Down Expand Up @@ -70,8 +86,8 @@
"description": "Manually specify Beolink JID to join."
},
"source_id": {
"name": "Source ID",
"description": "Specify which source to join, behavior varies between platforms. Compatible Mozart source IDs: 'deezer', 'spotify', 'tidal'. Compatible ASE source IDs: 'beoradio', 'deezer', 'spotify', using Beolink Converter NL/ML: 'RADIO', 'TP1', 'TP2', 'CD', 'AUX_A', 'PH'. A defined Beolink JID is required."
"name": "Source",
"description": "Specify which source to join, behavior varies between platforms. Source names prefaced by a platform name can only be used when connecting to that platform. A defined Beolink JID is required"
}
},
"sections": {
Expand Down
20 changes: 18 additions & 2 deletions custom_components/bang_olufsen/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -1239,6 +1239,22 @@
"message": "An error occurred while attempting to play {media_type}: {error_message}."
}
},
"selector": {
"source_ids": {
"options": {
"bc_nlml_aux_a": "Beolink Converter NL/ML AUX_A",
"bc_nlml_cd": "Beolink Converter NL/ML CD",
"bc_nlml_ph": "Beolink Converter NL/ML PH",
"bc_nlml_radio": "Beolink Converter NL/ML RADIO",
"bc_nlml_tp1": "Beolink Converter NL/ML TP1",
"bc_nlml_tp2": "Beolink Converter NL/ML TP2",
"beoradio": "ASE Beoradio",
"deezer": "Deezer",
"spotify": "Spotify",
"tidal": "Mozart Tidal"
}
}
},
"services": {
"beolink_allstandby": {
"description": "Set all Connected Beolink devices to standby.",
Expand Down Expand Up @@ -1272,8 +1288,8 @@
"name": "Beolink JID"
},
"source_id": {
"description": "Specify which source to join, behavior varies between platforms. Compatible Mozart source IDs: 'deezer', 'spotify', 'tidal'. Compatible ASE source IDs: 'beoradio', 'deezer', 'spotify', using Beolink Converter NL/ML: 'RADIO', 'TP1', 'TP2', 'CD', 'AUX_A', 'PH'. A defined Beolink JID is required.",
"name": "Source ID"
"description": "Specify which source to join, behavior varies between platforms. Source names prefaced by a platform name can only be used when connecting to that platform. A defined Beolink JID is required",
"name": "Source"
}
},
"name": "Beolink join",
Expand Down

0 comments on commit 7a0c9ca

Please sign in to comment.