mirror of
https://github.com/home-assistant/core.git
synced 2025-12-24 12:59:34 +00:00
Fix button event entity creation in Bang & Olufsen (#157982)
Co-authored-by: Abílio Costa <abmantis@users.noreply.github.com>
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -37,6 +37,7 @@ from .const import (
|
||||
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,
|
||||
@@ -48,10 +49,12 @@ from .const import (
|
||||
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,
|
||||
@@ -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:
|
||||
|
||||
@@ -42,6 +42,7 @@ TEST_MODEL_CORE = "Beoconnect Core"
|
||||
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"
|
||||
@@ -64,9 +65,11 @@ TEST_JID_3 = f"{TEST_TYPE_NUMBER}.{TEST_ITEM_NUMBER}.{TEST_SERIAL_NUMBER_3}@prod
|
||||
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
|
||||
@@ -105,6 +108,13 @@ TEST_DATA_CREATE_ENTRY_3 = {
|
||||
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)],
|
||||
|
||||
@@ -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',
|
||||
|
||||
@@ -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',
|
||||
@@ -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',
|
||||
@@ -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',
|
||||
])
|
||||
|
||||
@@ -5,11 +5,11 @@
|
||||
<BeoAttribute.BEOLINK: 'beolink'>: dict({
|
||||
<BeoAttribute.BEOLINK_LISTENERS: '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',
|
||||
}),
|
||||
<BeoAttribute.BEOLINK_PEERS: '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',
|
||||
}),
|
||||
<BeoAttribute.BEOLINK_SELF: 'self'>: dict({
|
||||
'Living room Balance': '1111.1111111.11111111@products.bang-olufsen.com',
|
||||
@@ -53,11 +53,11 @@
|
||||
<BeoAttribute.BEOLINK: 'beolink'>: dict({
|
||||
<BeoAttribute.BEOLINK_LISTENERS: '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',
|
||||
}),
|
||||
<BeoAttribute.BEOLINK_PEERS: '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',
|
||||
}),
|
||||
<BeoAttribute.BEOLINK_SELF: 'self'>: dict({
|
||||
'Living room Balance': '1111.1111111.11111111@products.bang-olufsen.com',
|
||||
@@ -102,11 +102,11 @@
|
||||
<BeoAttribute.BEOLINK: 'beolink'>: dict({
|
||||
<BeoAttribute.BEOLINK_LISTENERS: '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',
|
||||
}),
|
||||
<BeoAttribute.BEOLINK_PEERS: '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',
|
||||
}),
|
||||
<BeoAttribute.BEOLINK_SELF: 'self'>: dict({
|
||||
'Living room Balance': '1111.1111111.11111111@products.bang-olufsen.com',
|
||||
@@ -151,11 +151,11 @@
|
||||
<BeoAttribute.BEOLINK: 'beolink'>: dict({
|
||||
<BeoAttribute.BEOLINK_LISTENERS: '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',
|
||||
}),
|
||||
<BeoAttribute.BEOLINK_PEERS: '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',
|
||||
}),
|
||||
<BeoAttribute.BEOLINK_SELF: 'self'>: dict({
|
||||
'Living room Balance': '1111.1111111.11111111@products.bang-olufsen.com',
|
||||
@@ -200,11 +200,11 @@
|
||||
<BeoAttribute.BEOLINK: 'beolink'>: dict({
|
||||
<BeoAttribute.BEOLINK_LISTENERS: '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',
|
||||
}),
|
||||
<BeoAttribute.BEOLINK_PEERS: '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',
|
||||
}),
|
||||
<BeoAttribute.BEOLINK_SELF: 'self'>: dict({
|
||||
'Living room Balance': '1111.1111111.11111111@products.bang-olufsen.com',
|
||||
@@ -249,11 +249,11 @@
|
||||
<BeoAttribute.BEOLINK: 'beolink'>: dict({
|
||||
<BeoAttribute.BEOLINK_LISTENERS: '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',
|
||||
}),
|
||||
<BeoAttribute.BEOLINK_PEERS: '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',
|
||||
}),
|
||||
<BeoAttribute.BEOLINK_SELF: 'self'>: dict({
|
||||
'Living room Balance': '1111.1111111.11111111@products.bang-olufsen.com',
|
||||
@@ -297,11 +297,11 @@
|
||||
<BeoAttribute.BEOLINK: 'beolink'>: dict({
|
||||
<BeoAttribute.BEOLINK_LISTENERS: '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',
|
||||
}),
|
||||
<BeoAttribute.BEOLINK_PEERS: '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',
|
||||
}),
|
||||
<BeoAttribute.BEOLINK_SELF: 'self'>: dict({
|
||||
'Living room Balance': '1111.1111111.11111111@products.bang-olufsen.com',
|
||||
@@ -345,11 +345,11 @@
|
||||
<BeoAttribute.BEOLINK: 'beolink'>: dict({
|
||||
<BeoAttribute.BEOLINK_LISTENERS: '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',
|
||||
}),
|
||||
<BeoAttribute.BEOLINK_PEERS: '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',
|
||||
}),
|
||||
<BeoAttribute.BEOLINK_SELF: 'self'>: dict({
|
||||
'Living room Balance': '1111.1111111.11111111@products.bang-olufsen.com',
|
||||
@@ -393,11 +393,11 @@
|
||||
<BeoAttribute.BEOLINK: 'beolink'>: dict({
|
||||
<BeoAttribute.BEOLINK_LISTENERS: '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',
|
||||
}),
|
||||
<BeoAttribute.BEOLINK_PEERS: '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',
|
||||
}),
|
||||
<BeoAttribute.BEOLINK_SELF: 'self'>: dict({
|
||||
'Living room Balance': '1111.1111111.11111111@products.bang-olufsen.com',
|
||||
@@ -441,11 +441,11 @@
|
||||
<BeoAttribute.BEOLINK: 'beolink'>: dict({
|
||||
<BeoAttribute.BEOLINK_LISTENERS: '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',
|
||||
}),
|
||||
<BeoAttribute.BEOLINK_PEERS: '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',
|
||||
}),
|
||||
<BeoAttribute.BEOLINK_SELF: 'self'>: dict({
|
||||
'Living room Balance': '1111.1111111.11111111@products.bang-olufsen.com',
|
||||
@@ -489,11 +489,11 @@
|
||||
<BeoAttribute.BEOLINK: 'beolink'>: dict({
|
||||
<BeoAttribute.BEOLINK_LISTENERS: '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',
|
||||
}),
|
||||
<BeoAttribute.BEOLINK_PEERS: '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',
|
||||
}),
|
||||
<BeoAttribute.BEOLINK_SELF: 'self'>: dict({
|
||||
'Living room Balance': '1111.1111111.11111111@products.bang-olufsen.com',
|
||||
@@ -537,11 +537,11 @@
|
||||
<BeoAttribute.BEOLINK: 'beolink'>: dict({
|
||||
<BeoAttribute.BEOLINK_LISTENERS: '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',
|
||||
}),
|
||||
<BeoAttribute.BEOLINK_PEERS: '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',
|
||||
}),
|
||||
<BeoAttribute.BEOLINK_SELF: 'self'>: dict({
|
||||
'Living room Balance': '1111.1111111.11111111@products.bang-olufsen.com',
|
||||
@@ -585,11 +585,11 @@
|
||||
<BeoAttribute.BEOLINK: 'beolink'>: dict({
|
||||
<BeoAttribute.BEOLINK_LISTENERS: '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',
|
||||
}),
|
||||
<BeoAttribute.BEOLINK_PEERS: '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',
|
||||
}),
|
||||
<BeoAttribute.BEOLINK_SELF: 'self'>: dict({
|
||||
'Living room Balance': '1111.1111111.11111111@products.bang-olufsen.com',
|
||||
@@ -634,11 +634,11 @@
|
||||
<BeoAttribute.BEOLINK: 'beolink'>: dict({
|
||||
<BeoAttribute.BEOLINK_LISTENERS: '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',
|
||||
}),
|
||||
<BeoAttribute.BEOLINK_PEERS: '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',
|
||||
}),
|
||||
<BeoAttribute.BEOLINK_SELF: 'self'>: dict({
|
||||
'Living room Balance': '1111.1111111.22222222@products.bang-olufsen.com',
|
||||
@@ -683,11 +683,11 @@
|
||||
<BeoAttribute.BEOLINK: 'beolink'>: dict({
|
||||
<BeoAttribute.BEOLINK_LISTENERS: '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',
|
||||
}),
|
||||
<BeoAttribute.BEOLINK_PEERS: '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',
|
||||
}),
|
||||
<BeoAttribute.BEOLINK_SELF: 'self'>: dict({
|
||||
'Living room Balance': '1111.1111111.11111111@products.bang-olufsen.com',
|
||||
@@ -732,11 +732,11 @@
|
||||
<BeoAttribute.BEOLINK: 'beolink'>: dict({
|
||||
<BeoAttribute.BEOLINK_LISTENERS: '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',
|
||||
}),
|
||||
<BeoAttribute.BEOLINK_PEERS: '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',
|
||||
}),
|
||||
<BeoAttribute.BEOLINK_SELF: 'self'>: dict({
|
||||
'Living room Balance': '1111.1111111.22222222@products.bang-olufsen.com',
|
||||
@@ -781,11 +781,11 @@
|
||||
<BeoAttribute.BEOLINK: 'beolink'>: dict({
|
||||
<BeoAttribute.BEOLINK_LISTENERS: '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',
|
||||
}),
|
||||
<BeoAttribute.BEOLINK_PEERS: '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',
|
||||
}),
|
||||
<BeoAttribute.BEOLINK_SELF: 'self'>: dict({
|
||||
'Living room Balance': '1111.1111111.11111111@products.bang-olufsen.com',
|
||||
@@ -831,11 +831,11 @@
|
||||
<BeoAttribute.BEOLINK: 'beolink'>: dict({
|
||||
<BeoAttribute.BEOLINK_LISTENERS: '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',
|
||||
}),
|
||||
<BeoAttribute.BEOLINK_PEERS: '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',
|
||||
}),
|
||||
<BeoAttribute.BEOLINK_SELF: 'self'>: dict({
|
||||
'Living room Balance': '1111.1111111.22222222@products.bang-olufsen.com',
|
||||
@@ -880,11 +880,11 @@
|
||||
<BeoAttribute.BEOLINK: 'beolink'>: dict({
|
||||
<BeoAttribute.BEOLINK_LISTENERS: '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',
|
||||
}),
|
||||
<BeoAttribute.BEOLINK_PEERS: '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',
|
||||
}),
|
||||
<BeoAttribute.BEOLINK_SELF: 'self'>: dict({
|
||||
'Living room Balance': '1111.1111111.11111111@products.bang-olufsen.com',
|
||||
@@ -929,11 +929,11 @@
|
||||
<BeoAttribute.BEOLINK: 'beolink'>: dict({
|
||||
<BeoAttribute.BEOLINK_LISTENERS: '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',
|
||||
}),
|
||||
<BeoAttribute.BEOLINK_PEERS: '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',
|
||||
}),
|
||||
<BeoAttribute.BEOLINK_SELF: 'self'>: dict({
|
||||
'Living room Balance': '1111.1111111.22222222@products.bang-olufsen.com',
|
||||
@@ -978,11 +978,11 @@
|
||||
<BeoAttribute.BEOLINK: 'beolink'>: dict({
|
||||
<BeoAttribute.BEOLINK_LISTENERS: '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',
|
||||
}),
|
||||
<BeoAttribute.BEOLINK_PEERS: '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',
|
||||
}),
|
||||
<BeoAttribute.BEOLINK_SELF: 'self'>: dict({
|
||||
'Living room Balance': '1111.1111111.11111111@products.bang-olufsen.com',
|
||||
@@ -1029,7 +1029,7 @@
|
||||
}),
|
||||
<BeoAttribute.BEOLINK_PEERS: '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',
|
||||
}),
|
||||
<BeoAttribute.BEOLINK_SELF: 'self'>: dict({
|
||||
'Living room Balance': '1111.1111111.11111111@products.bang-olufsen.com',
|
||||
@@ -1072,11 +1072,11 @@
|
||||
<BeoAttribute.BEOLINK: 'beolink'>: dict({
|
||||
<BeoAttribute.BEOLINK_LISTENERS: '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',
|
||||
}),
|
||||
<BeoAttribute.BEOLINK_PEERS: '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',
|
||||
}),
|
||||
<BeoAttribute.BEOLINK_SELF: 'self'>: dict({
|
||||
'Living room Balance': '1111.1111111.22222222@products.bang-olufsen.com',
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
from unittest.mock import AsyncMock
|
||||
|
||||
from mozart_api.models import BeoRemoteButton, ButtonEvent, PairedRemoteResponse
|
||||
from pytest_unordered import unordered
|
||||
from syrupy.assertion import SnapshotAssertion
|
||||
|
||||
from homeassistant.components.bang_olufsen.const import (
|
||||
@@ -20,37 +21,64 @@ from .const import (
|
||||
TEST_BUTTON_EVENT_ENTITY_ID,
|
||||
TEST_REMOTE_KEY_EVENT_ENTITY_ID,
|
||||
TEST_SERIAL_NUMBER_3,
|
||||
TEST_SERIAL_NUMBER_4,
|
||||
)
|
||||
from .util import (
|
||||
get_a5_entity_ids,
|
||||
get_balance_entity_ids,
|
||||
get_core_entity_ids,
|
||||
get_premiere_entity_ids,
|
||||
get_remote_entity_ids,
|
||||
)
|
||||
from .util import get_button_entity_ids, get_remote_entity_ids
|
||||
|
||||
from tests.common import MockConfigEntry
|
||||
|
||||
|
||||
async def test_button_event_creation_balance(
|
||||
async def _check_button_event_creation(
|
||||
hass: HomeAssistant,
|
||||
integration: None,
|
||||
entity_registry: EntityRegistry,
|
||||
snapshot: SnapshotAssertion,
|
||||
config_entry: MockConfigEntry,
|
||||
client: AsyncMock,
|
||||
entity_ids: list[str],
|
||||
) -> None:
|
||||
"""Test button event entities are created when using a Balance (Most devices support all buttons like the Balance)."""
|
||||
|
||||
# Add Button Event entity ids
|
||||
entity_ids: list[str] = [*get_button_entity_ids(), *get_remote_entity_ids()]
|
||||
"""Test body for entity creation tests."""
|
||||
# Load entry
|
||||
config_entry.add_to_hass(hass)
|
||||
await hass.config_entries.async_setup(config_entry.entry_id)
|
||||
await mock_websocket_connection(hass, client)
|
||||
|
||||
# Check that the entities are available
|
||||
for entity_id in entity_ids:
|
||||
assert entity_registry.async_get(entity_id)
|
||||
|
||||
# Check number of entities
|
||||
# The media_player entity and all of the button event entities should be the only available
|
||||
# Check that no entities other than the expected have been created
|
||||
entity_ids_available = list(entity_registry.entities.keys())
|
||||
assert len(entity_ids_available) == 1 + len(entity_ids)
|
||||
|
||||
# Check snapshot
|
||||
assert entity_ids_available == unordered(entity_ids)
|
||||
assert entity_ids_available == snapshot
|
||||
|
||||
|
||||
async def test_no_button_and_remote_key_event_creation(
|
||||
async def test_button_event_creation_balance(
|
||||
hass: HomeAssistant,
|
||||
entity_registry: EntityRegistry,
|
||||
snapshot: SnapshotAssertion,
|
||||
mock_config_entry: MockConfigEntry,
|
||||
mock_mozart_client: AsyncMock,
|
||||
) -> None:
|
||||
"""Test button event entities are created when using a Balance (Most devices support all buttons like the Balance)."""
|
||||
|
||||
await _check_button_event_creation(
|
||||
hass,
|
||||
entity_registry,
|
||||
snapshot,
|
||||
mock_config_entry,
|
||||
mock_mozart_client,
|
||||
[*get_balance_entity_ids(), *get_remote_entity_ids()],
|
||||
)
|
||||
|
||||
|
||||
async def test_no_button_and_remote_key_event_creation_core(
|
||||
hass: HomeAssistant,
|
||||
mock_config_entry_core: MockConfigEntry,
|
||||
mock_mozart_client: AsyncMock,
|
||||
@@ -62,51 +90,58 @@ async def test_no_button_and_remote_key_event_creation(
|
||||
items=[]
|
||||
)
|
||||
|
||||
# Load entry
|
||||
mock_config_entry_core.add_to_hass(hass)
|
||||
await hass.config_entries.async_setup(mock_config_entry_core.entry_id)
|
||||
await mock_websocket_connection(hass, mock_mozart_client)
|
||||
|
||||
# Check number of entities
|
||||
# The media_player entity should be the only available
|
||||
entity_ids_available = list(entity_registry.entities.keys())
|
||||
assert len(entity_ids_available) == 1
|
||||
|
||||
# Check snapshot
|
||||
assert entity_ids_available == snapshot
|
||||
await _check_button_event_creation(
|
||||
hass,
|
||||
entity_registry,
|
||||
snapshot,
|
||||
mock_config_entry_core,
|
||||
mock_mozart_client,
|
||||
get_core_entity_ids(),
|
||||
)
|
||||
|
||||
|
||||
async def test_button_event_creation_beosound_premiere(
|
||||
async def test_button_event_creation_premiere(
|
||||
hass: HomeAssistant,
|
||||
mock_config_entry_premiere: MockConfigEntry,
|
||||
mock_mozart_client: AsyncMock,
|
||||
entity_registry: EntityRegistry,
|
||||
snapshot: SnapshotAssertion,
|
||||
) -> None:
|
||||
"""Test Bluetooth button event entity is not created when using a Beosound Premiere."""
|
||||
"""Test Bluetooth and Microphone button event entities are not created when using a Beosound Premiere."""
|
||||
|
||||
# Load entry
|
||||
mock_config_entry_premiere.add_to_hass(hass)
|
||||
await hass.config_entries.async_setup(mock_config_entry_premiere.entry_id)
|
||||
await mock_websocket_connection(hass, mock_mozart_client)
|
||||
await _check_button_event_creation(
|
||||
hass,
|
||||
entity_registry,
|
||||
snapshot,
|
||||
mock_config_entry_premiere,
|
||||
mock_mozart_client,
|
||||
[
|
||||
*get_premiere_entity_ids(),
|
||||
*get_remote_entity_ids(device_serial=TEST_SERIAL_NUMBER_3),
|
||||
],
|
||||
)
|
||||
|
||||
# Add Button Event entity ids
|
||||
entity_ids = [
|
||||
*get_button_entity_ids("beosound_premiere_33333333"),
|
||||
*get_remote_entity_ids(device_serial=TEST_SERIAL_NUMBER_3),
|
||||
]
|
||||
entity_ids.remove("event.beosound_premiere_33333333_bluetooth")
|
||||
|
||||
# Check that the entities are available
|
||||
for entity_id in entity_ids:
|
||||
assert entity_registry.async_get(entity_id)
|
||||
async def test_button_event_creation_a5(
|
||||
hass: HomeAssistant,
|
||||
mock_config_entry_a5: MockConfigEntry,
|
||||
mock_mozart_client: AsyncMock,
|
||||
entity_registry: EntityRegistry,
|
||||
snapshot: SnapshotAssertion,
|
||||
) -> None:
|
||||
"""Test Microphone button event entity is not created when using a Beosound A5."""
|
||||
|
||||
# Check number of entities
|
||||
# The media_player entity and all of the button event entities (except Bluetooth) should be the only available
|
||||
entity_ids_available = list(entity_registry.entities.keys())
|
||||
assert len(entity_ids_available) == 1 + len(entity_ids)
|
||||
|
||||
assert entity_ids_available == snapshot
|
||||
await _check_button_event_creation(
|
||||
hass,
|
||||
entity_registry,
|
||||
snapshot,
|
||||
mock_config_entry_a5,
|
||||
mock_mozart_client,
|
||||
[
|
||||
*get_a5_entity_ids(),
|
||||
*get_remote_entity_ids(device_serial=TEST_SERIAL_NUMBER_4),
|
||||
],
|
||||
)
|
||||
|
||||
|
||||
async def test_button(
|
||||
|
||||
@@ -10,6 +10,7 @@ from mozart_api.models import (
|
||||
WebsocketNotificationTag,
|
||||
)
|
||||
import pytest
|
||||
from pytest_unordered import unordered
|
||||
from syrupy.assertion import SnapshotAssertion
|
||||
|
||||
from homeassistant.components.bang_olufsen.const import (
|
||||
@@ -29,7 +30,7 @@ from .const import (
|
||||
TEST_REMOTE_SERIAL_PAIRED,
|
||||
TEST_SERIAL_NUMBER,
|
||||
)
|
||||
from .util import get_button_entity_ids, get_remote_entity_ids
|
||||
from .util import get_balance_entity_ids, get_remote_entity_ids
|
||||
|
||||
from tests.common import MockConfigEntry
|
||||
|
||||
@@ -133,9 +134,8 @@ async def test_on_remote_control_already_added(
|
||||
assert device_registry.async_get_device({(DOMAIN, TEST_REMOTE_SERIAL_PAIRED)})
|
||||
|
||||
# Check number of entities (remote and button events and media_player)
|
||||
assert (
|
||||
len(list(entity_registry.entities.keys()))
|
||||
== len(get_remote_entity_ids()) + len(get_button_entity_ids()) + 1
|
||||
assert list(entity_registry.entities.keys()) == unordered(
|
||||
[*get_balance_entity_ids(), *get_remote_entity_ids()]
|
||||
)
|
||||
remote_callback = mock_mozart_client.get_notification_notifications.call_args[0][0]
|
||||
|
||||
@@ -152,12 +152,11 @@ async def test_on_remote_control_already_added(
|
||||
assert mock_mozart_client.get_bluetooth_remotes.call_count == 2
|
||||
assert device_registry.async_get_device({(DOMAIN, TEST_REMOTE_SERIAL_PAIRED)})
|
||||
|
||||
# Check number of entities
|
||||
# Check number of entities (remote and button events and media_player)
|
||||
entity_ids_available = list(entity_registry.entities.keys())
|
||||
|
||||
assert (
|
||||
len(entity_ids_available)
|
||||
== len(get_remote_entity_ids()) + len(get_button_entity_ids()) + 1
|
||||
assert list(entity_registry.entities.keys()) == unordered(
|
||||
[*get_balance_entity_ids(), *get_remote_entity_ids()]
|
||||
)
|
||||
assert entity_ids_available == snapshot
|
||||
|
||||
@@ -180,10 +179,9 @@ async def test_on_remote_control_paired(
|
||||
assert mock_mozart_client.get_bluetooth_remotes.call_count == 1
|
||||
assert device_registry.async_get_device({(DOMAIN, TEST_REMOTE_SERIAL_PAIRED)})
|
||||
|
||||
# Check number of entities (button events and media_player)
|
||||
assert (
|
||||
len(list(entity_registry.entities.keys()))
|
||||
== len(get_remote_entity_ids()) + len(get_button_entity_ids()) + 1
|
||||
# Check number of entities (button and remote events and media_player)
|
||||
assert list(entity_registry.entities.keys()) == unordered(
|
||||
[*get_balance_entity_ids(), *get_remote_entity_ids()]
|
||||
)
|
||||
# "Pair" a new remote
|
||||
mock_mozart_client.get_bluetooth_remotes.return_value = PairedRemoteResponse(
|
||||
@@ -234,12 +232,12 @@ async def test_on_remote_control_paired(
|
||||
# Check number of entities (remote and button events and media_player)
|
||||
entity_ids_available = list(entity_registry.entities.keys())
|
||||
|
||||
assert (
|
||||
len(entity_ids_available)
|
||||
== len(get_remote_entity_ids())
|
||||
+ len(get_remote_entity_ids())
|
||||
+ len(get_button_entity_ids())
|
||||
+ 1
|
||||
assert entity_ids_available == unordered(
|
||||
[
|
||||
*get_balance_entity_ids(),
|
||||
*get_remote_entity_ids(),
|
||||
*get_remote_entity_ids("66666666"),
|
||||
]
|
||||
)
|
||||
assert entity_ids_available == snapshot
|
||||
|
||||
@@ -262,11 +260,11 @@ async def test_on_remote_control_unpaired(
|
||||
assert mock_mozart_client.get_bluetooth_remotes.call_count == 1
|
||||
assert device_registry.async_get_device({(DOMAIN, TEST_REMOTE_SERIAL_PAIRED)})
|
||||
|
||||
# Check number of entities (button events and media_player)
|
||||
assert (
|
||||
len(list(entity_registry.entities.keys()))
|
||||
== len(get_remote_entity_ids()) + len(get_button_entity_ids()) + 1
|
||||
# Check number of entities (button and remote events and media_player)
|
||||
assert list(entity_registry.entities.keys()) == unordered(
|
||||
[*get_balance_entity_ids(), *get_remote_entity_ids()]
|
||||
)
|
||||
|
||||
# "Unpair" the remote
|
||||
mock_mozart_client.get_bluetooth_remotes.return_value = PairedRemoteResponse(
|
||||
items=[]
|
||||
@@ -296,7 +294,7 @@ async def test_on_remote_control_unpaired(
|
||||
# Check number of entities (button events and media_player)
|
||||
entity_ids_available = list(entity_registry.entities.keys())
|
||||
|
||||
assert len(entity_ids_available) == +len(get_button_entity_ids()) + 1
|
||||
assert entity_ids_available == unordered(get_balance_entity_ids())
|
||||
assert entity_ids_available == snapshot
|
||||
|
||||
|
||||
|
||||
@@ -10,17 +10,58 @@ from homeassistant.components.bang_olufsen.const import (
|
||||
DEVICE_BUTTONS,
|
||||
)
|
||||
|
||||
from .const import TEST_REMOTE_SERIAL, TEST_SERIAL_NUMBER
|
||||
from .const import (
|
||||
TEST_MEDIA_PLAYER_ENTITY_ID,
|
||||
TEST_MEDIA_PLAYER_ENTITY_ID_2,
|
||||
TEST_MEDIA_PLAYER_ENTITY_ID_3,
|
||||
TEST_MEDIA_PLAYER_ENTITY_ID_4,
|
||||
TEST_REMOTE_SERIAL,
|
||||
TEST_SERIAL_NUMBER,
|
||||
)
|
||||
|
||||
|
||||
def get_button_entity_ids(id_prefix: str = "beosound_balance_11111111") -> list[str]:
|
||||
"""Return a list of button entity_ids that Mozart devices (except Beoconnect Core and Beosound Premiere) provides."""
|
||||
def _get_button_entity_ids(id_prefix: str = "beosound_balance_11111111") -> list[str]:
|
||||
"""Return a list of button entity_ids that Mozart devices provide.
|
||||
|
||||
Beoconnect Core, Beosound A5, Beosound A9 and Beosound Premiere do not have (all of the) physical buttons and need filtering.
|
||||
"""
|
||||
return [
|
||||
f"event.{id_prefix}_{underscore(button_type)}".replace("preset", "favorite_")
|
||||
for button_type in DEVICE_BUTTONS
|
||||
]
|
||||
|
||||
|
||||
def get_balance_entity_ids() -> list[str]:
|
||||
"""Return a list of entity_ids that a Beosound Balance provides."""
|
||||
return [TEST_MEDIA_PLAYER_ENTITY_ID, *_get_button_entity_ids()]
|
||||
|
||||
|
||||
def get_premiere_entity_ids() -> list[str]:
|
||||
"""Return a list of entity_ids that a Beosound Premiere provides."""
|
||||
buttons = [
|
||||
TEST_MEDIA_PLAYER_ENTITY_ID_3,
|
||||
*_get_button_entity_ids("beosound_premiere_33333333"),
|
||||
]
|
||||
buttons.remove("event.beosound_premiere_33333333_bluetooth")
|
||||
buttons.remove("event.beosound_premiere_33333333_microphone")
|
||||
return buttons
|
||||
|
||||
|
||||
def get_a5_entity_ids() -> list[str]:
|
||||
"""Return a list of entity_ids that a Beosound A5 provides."""
|
||||
buttons = [
|
||||
TEST_MEDIA_PLAYER_ENTITY_ID_4,
|
||||
*_get_button_entity_ids("beosound_a5_44444444"),
|
||||
]
|
||||
buttons.remove("event.beosound_a5_44444444_microphone")
|
||||
return buttons
|
||||
|
||||
|
||||
def get_core_entity_ids() -> list[str]:
|
||||
"""Return a list of entity_ids that a Beoconnect core provides."""
|
||||
return [TEST_MEDIA_PLAYER_ENTITY_ID_2]
|
||||
|
||||
|
||||
def get_remote_entity_ids(
|
||||
remote_serial: str = TEST_REMOTE_SERIAL, device_serial: str = TEST_SERIAL_NUMBER
|
||||
) -> list[str]:
|
||||
|
||||
Reference in New Issue
Block a user