Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
23 changes: 17 additions & 6 deletions homeassistant/components/bang_olufsen/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,25 @@ async def get_remotes(client: MozartClient) -> list[PairedRemote]:

def get_device_buttons(model: BeoModel) -> list[str]:
"""Get supported buttons for a given model."""
# Beoconnect Core does not have any buttons
if model == BeoModel.BEOCONNECT_CORE:
return []

buttons = DEVICE_BUTTONS.copy()

# Beosound Premiere does not have a bluetooth button
if model == BeoModel.BEOSOUND_PREMIERE:
# Models that don't have a microphone button
if model in (
BeoModel.BEOSOUND_A5,
BeoModel.BEOSOUND_A9,
BeoModel.BEOSOUND_PREMIERE,
):
buttons.remove(BeoButtons.MICROPHONE)

# Models that don't have a Bluetooth button
if model in (
BeoModel.BEOSOUND_A9,
BeoModel.BEOSOUND_PREMIERE,
):
buttons.remove(BeoButtons.BLUETOOTH)

# Beoconnect Core does not have any buttons
elif model == BeoModel.BEOCONNECT_CORE:
buttons = []

return buttons
14 changes: 14 additions & 0 deletions tests/components/bang_olufsen/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
TEST_DATA_CREATE_ENTRY,
TEST_DATA_CREATE_ENTRY_2,
TEST_DATA_CREATE_ENTRY_3,
TEST_DATA_CREATE_ENTRY_4,
TEST_FRIENDLY_NAME,
TEST_FRIENDLY_NAME_3,
TEST_FRIENDLY_NAME_4,
Expand All @@ -48,10 +49,12 @@
TEST_NAME,
TEST_NAME_2,
TEST_NAME_3,
TEST_NAME_4,
TEST_REMOTE_SERIAL,
TEST_SERIAL_NUMBER,
TEST_SERIAL_NUMBER_2,
TEST_SERIAL_NUMBER_3,
TEST_SERIAL_NUMBER_4,
TEST_SOUND_MODE,
TEST_SOUND_MODE_2,
TEST_SOUND_MODE_NAME,
Expand Down Expand Up @@ -93,6 +96,17 @@ def mock_config_entry_premiere() -> MockConfigEntry:
)


@pytest.fixture
def mock_config_entry_a5() -> MockConfigEntry:
"""Mock config entry for Beosound A5."""
return MockConfigEntry(
domain=DOMAIN,
unique_id=TEST_SERIAL_NUMBER_4,
data=TEST_DATA_CREATE_ENTRY_4,
title=TEST_NAME_4,
)


async def mock_websocket_connection(
hass: HomeAssistant, mock_mozart_client: AsyncMock
) -> None:
Expand Down
16 changes: 13 additions & 3 deletions tests/components/bang_olufsen/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
TEST_MODEL_PREMIERE = "Beosound Premiere"
TEST_MODEL_THEATRE = "Beosound Theatre"
TEST_MODEL_LEVEL = "Beosound Level"
TEST_MODEL_A5 = "Beosound A5"
TEST_SERIAL_NUMBER = "11111111"
TEST_NAME = f"{TEST_MODEL_BALANCE}-{TEST_SERIAL_NUMBER}"
TEST_FRIENDLY_NAME = "Living room Balance"
Expand All @@ -64,9 +65,11 @@
TEST_MEDIA_PLAYER_ENTITY_ID_3 = f"media_player.beosound_premiere_{TEST_SERIAL_NUMBER_3}"
TEST_HOST_3 = "192.168.0.3"

TEST_FRIENDLY_NAME_4 = "Lounge room Balance"
TEST_JID_4 = f"{TEST_TYPE_NUMBER}.{TEST_ITEM_NUMBER}.44444444@products.bang-olufsen.com"
TEST_MEDIA_PLAYER_ENTITY_ID_4 = "media_player.beosound_balance_44444444"
TEST_FRIENDLY_NAME_4 = "Lounge room A5"
TEST_SERIAL_NUMBER_4 = "44444444"
TEST_NAME_4 = f"{TEST_MODEL_A5}-{TEST_SERIAL_NUMBER_4}"
TEST_JID_4 = f"{TEST_TYPE_NUMBER}.{TEST_ITEM_NUMBER}.{TEST_SERIAL_NUMBER_4}@products.bang-olufsen.com"
TEST_MEDIA_PLAYER_ENTITY_ID_4 = f"media_player.beosound_a5_{TEST_SERIAL_NUMBER_4}"
TEST_HOST_4 = "192.168.0.4"

# Beoremote One
Expand Down Expand Up @@ -105,6 +108,13 @@
CONF_NAME: TEST_NAME_3,
}

TEST_DATA_CREATE_ENTRY_4 = {
CONF_HOST: TEST_HOST_4,
CONF_MODEL: TEST_MODEL_A5,
CONF_BEOLINK_JID: TEST_JID_4,
CONF_NAME: TEST_NAME_4,
}

TEST_DATA_ZEROCONF = ZeroconfServiceInfo(
ip_address=IPv4Address(TEST_HOST),
ip_addresses=[IPv4Address(TEST_HOST)],
Expand Down
4 changes: 2 additions & 2 deletions tests/components/bang_olufsen/snapshots/test_diagnostics.ambr
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,11 @@
'beolink': dict({
'listeners': dict({
'Bedroom Premiere': '1111.1111111.33333333@products.bang-olufsen.com',
'Lounge room Balance': '1111.1111111.44444444@products.bang-olufsen.com',
'Lounge room A5': '1111.1111111.44444444@products.bang-olufsen.com',
}),
'peers': dict({
'Bedroom Premiere': '1111.1111111.33333333@products.bang-olufsen.com',
'Lounge room Balance': '1111.1111111.44444444@products.bang-olufsen.com',
'Lounge room A5': '1111.1111111.44444444@products.bang-olufsen.com',
}),
'self': dict({
'Living room Balance': '1111.1111111.11111111@products.bang-olufsen.com',
Expand Down
109 changes: 106 additions & 3 deletions tests/components/bang_olufsen/snapshots/test_event.ambr
Original file line number Diff line number Diff line change
@@ -1,4 +1,108 @@
# serializer version: 1
# name: test_button_event_creation_a5
list([
'event.beosound_a5_44444444_bluetooth',
'event.beosound_a5_44444444_next',
'event.beosound_a5_44444444_play_pause',
'event.beosound_a5_44444444_favorite_1',
'event.beosound_a5_44444444_favorite_2',
'event.beosound_a5_44444444_favorite_3',
'event.beosound_a5_44444444_favorite_4',
'event.beosound_a5_44444444_previous',
'event.beosound_a5_44444444_volume',
'event.beoremote_one_55555555_44444444_light_blue',
'event.beoremote_one_55555555_44444444_light_digit_0',
'event.beoremote_one_55555555_44444444_light_digit_1',
'event.beoremote_one_55555555_44444444_light_digit_2',
'event.beoremote_one_55555555_44444444_light_digit_3',
'event.beoremote_one_55555555_44444444_light_digit_4',
'event.beoremote_one_55555555_44444444_light_digit_5',
'event.beoremote_one_55555555_44444444_light_digit_6',
'event.beoremote_one_55555555_44444444_light_digit_7',
'event.beoremote_one_55555555_44444444_light_digit_8',
'event.beoremote_one_55555555_44444444_light_digit_9',
'event.beoremote_one_55555555_44444444_light_down',
'event.beoremote_one_55555555_44444444_light_green',
'event.beoremote_one_55555555_44444444_light_left',
'event.beoremote_one_55555555_44444444_light_play',
'event.beoremote_one_55555555_44444444_light_red',
'event.beoremote_one_55555555_44444444_light_rewind',
'event.beoremote_one_55555555_44444444_light_right',
'event.beoremote_one_55555555_44444444_light_select',
'event.beoremote_one_55555555_44444444_light_stop',
'event.beoremote_one_55555555_44444444_light_up',
'event.beoremote_one_55555555_44444444_light_wind',
'event.beoremote_one_55555555_44444444_light_yellow',
'event.beoremote_one_55555555_44444444_light_function_1',
'event.beoremote_one_55555555_44444444_light_function_2',
'event.beoremote_one_55555555_44444444_light_function_3',
'event.beoremote_one_55555555_44444444_light_function_4',
'event.beoremote_one_55555555_44444444_light_function_5',
'event.beoremote_one_55555555_44444444_light_function_6',
'event.beoremote_one_55555555_44444444_light_function_7',
'event.beoremote_one_55555555_44444444_light_function_8',
'event.beoremote_one_55555555_44444444_light_function_9',
'event.beoremote_one_55555555_44444444_light_function_10',
'event.beoremote_one_55555555_44444444_light_function_11',
'event.beoremote_one_55555555_44444444_light_function_12',
'event.beoremote_one_55555555_44444444_light_function_13',
'event.beoremote_one_55555555_44444444_light_function_14',
'event.beoremote_one_55555555_44444444_light_function_15',
'event.beoremote_one_55555555_44444444_light_function_16',
'event.beoremote_one_55555555_44444444_light_function_17',
'event.beoremote_one_55555555_44444444_control_blue',
'event.beoremote_one_55555555_44444444_control_digit_0',
'event.beoremote_one_55555555_44444444_control_digit_1',
'event.beoremote_one_55555555_44444444_control_digit_2',
'event.beoremote_one_55555555_44444444_control_digit_3',
'event.beoremote_one_55555555_44444444_control_digit_4',
'event.beoremote_one_55555555_44444444_control_digit_5',
'event.beoremote_one_55555555_44444444_control_digit_6',
'event.beoremote_one_55555555_44444444_control_digit_7',
'event.beoremote_one_55555555_44444444_control_digit_8',
'event.beoremote_one_55555555_44444444_control_digit_9',
'event.beoremote_one_55555555_44444444_control_down',
'event.beoremote_one_55555555_44444444_control_green',
'event.beoremote_one_55555555_44444444_control_left',
'event.beoremote_one_55555555_44444444_control_play',
'event.beoremote_one_55555555_44444444_control_red',
'event.beoremote_one_55555555_44444444_control_rewind',
'event.beoremote_one_55555555_44444444_control_right',
'event.beoremote_one_55555555_44444444_control_select',
'event.beoremote_one_55555555_44444444_control_stop',
'event.beoremote_one_55555555_44444444_control_up',
'event.beoremote_one_55555555_44444444_control_wind',
'event.beoremote_one_55555555_44444444_control_yellow',
'event.beoremote_one_55555555_44444444_control_function_1',
'event.beoremote_one_55555555_44444444_control_function_2',
'event.beoremote_one_55555555_44444444_control_function_3',
'event.beoremote_one_55555555_44444444_control_function_4',
'event.beoremote_one_55555555_44444444_control_function_5',
'event.beoremote_one_55555555_44444444_control_function_6',
'event.beoremote_one_55555555_44444444_control_function_7',
'event.beoremote_one_55555555_44444444_control_function_8',
'event.beoremote_one_55555555_44444444_control_function_9',
'event.beoremote_one_55555555_44444444_control_function_10',
'event.beoremote_one_55555555_44444444_control_function_11',
'event.beoremote_one_55555555_44444444_control_function_12',
'event.beoremote_one_55555555_44444444_control_function_13',
'event.beoremote_one_55555555_44444444_control_function_14',
'event.beoremote_one_55555555_44444444_control_function_15',
'event.beoremote_one_55555555_44444444_control_function_16',
'event.beoremote_one_55555555_44444444_control_function_17',
'event.beoremote_one_55555555_44444444_control_function_18',
'event.beoremote_one_55555555_44444444_control_function_19',
'event.beoremote_one_55555555_44444444_control_function_20',
'event.beoremote_one_55555555_44444444_control_function_21',
'event.beoremote_one_55555555_44444444_control_function_22',
'event.beoremote_one_55555555_44444444_control_function_23',
'event.beoremote_one_55555555_44444444_control_function_24',
'event.beoremote_one_55555555_44444444_control_function_25',
'event.beoremote_one_55555555_44444444_control_function_26',
'event.beoremote_one_55555555_44444444_control_function_27',
'media_player.beosound_a5_44444444',
])
# ---
# name: test_button_event_creation_balance
list([
'event.beosound_balance_11111111_bluetooth',
Expand Down Expand Up @@ -104,9 +208,8 @@
'media_player.beosound_balance_11111111',
])
# ---
# name: test_button_event_creation_beosound_premiere
# name: test_button_event_creation_premiere
list([
'event.beosound_premiere_33333333_microphone',
'event.beosound_premiere_33333333_next',
'event.beosound_premiere_33333333_play_pause',
'event.beosound_premiere_33333333_favorite_1',
Expand Down Expand Up @@ -208,7 +311,7 @@
'media_player.beosound_premiere_33333333',
])
# ---
# name: test_no_button_and_remote_key_event_creation
# name: test_no_button_and_remote_key_event_creation_core
list([
'media_player.beoconnect_core_22222222',
])
Expand Down
Loading
Loading