Skip to content

Commit bce65d4

Browse files
authored
Allow test vendor IDs to set Matter label (home-assistant#161974)
1 parent daa0ddf commit bce65d4

5 files changed

Lines changed: 29 additions & 25 deletions

File tree

homeassistant/components/matter/entity.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,16 @@
4949
4: None, # Inovelli VTM36
5050
16: ["label", "name", "button"], # Inovelli VTM30
5151
},
52+
65521: { # Test/DIY devices
53+
32768: ["ha_entitylabel"],
54+
32769: ["ha_entitylabel"],
55+
32770: ["ha_entitylabel"],
56+
},
57+
65522: { # Test/DIY devices
58+
32768: ["ha_entitylabel"],
59+
32769: ["ha_entitylabel"],
60+
32770: ["ha_entitylabel"],
61+
},
5262
}
5363

5464

tests/components/matter/fixtures/nodes/mock_generic_switch_multi.json

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -75,12 +75,6 @@
7575
"1/59/65531": [0, 1, 65528, 65529, 65531, 65532, 65533],
7676
"1/59/65532": 30,
7777
"1/59/65528": [],
78-
"1/64/0": [
79-
{
80-
"0": "Label",
81-
"1": "1"
82-
}
83-
],
8478
"2/3/65529": [0, 64],
8579
"2/3/65531": [0, 1, 65528, 65529, 65531, 65532, 65533],
8680
"2/29/0": [
@@ -107,7 +101,7 @@
107101
"2/59/65528": [],
108102
"2/64/0": [
109103
{
110-
"0": "Label",
104+
"0": "ha_entitylabel",
111105
"1": "Fancy Button"
112106
}
113107
]

tests/components/matter/snapshots/test_event.ambr

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1909,7 +1909,7 @@
19091909
'state': 'unknown',
19101910
})
19111911
# ---
1912-
# name: test_events[mock_generic_switch_multi][event.mock_generic_switch_button_2-entry]
1912+
# name: test_events[mock_generic_switch_multi][event.mock_generic_switch_button_fancy_button-entry]
19131913
EntityRegistryEntrySnapshot({
19141914
'aliases': list([
19151915
None,
@@ -1932,20 +1932,20 @@
19321932
'disabled_by': None,
19331933
'domain': 'event',
19341934
'entity_category': None,
1935-
'entity_id': 'event.mock_generic_switch_button_2',
1935+
'entity_id': 'event.mock_generic_switch_button_fancy_button',
19361936
'has_entity_name': True,
19371937
'hidden_by': None,
19381938
'icon': None,
19391939
'id': <ANY>,
19401940
'labels': set({
19411941
}),
19421942
'name': None,
1943-
'object_id_base': 'Button (2)',
1943+
'object_id_base': 'Button (Fancy Button)',
19441944
'options': dict({
19451945
}),
19461946
'original_device_class': <EventDeviceClass.BUTTON: 'button'>,
19471947
'original_icon': None,
1948-
'original_name': 'Button (2)',
1948+
'original_name': 'Button (Fancy Button)',
19491949
'platform': 'matter',
19501950
'previous_unique_id': None,
19511951
'suggested_object_id': None,
@@ -1955,7 +1955,7 @@
19551955
'unit_of_measurement': None,
19561956
})
19571957
# ---
1958-
# name: test_events[mock_generic_switch_multi][event.mock_generic_switch_button_2-state]
1958+
# name: test_events[mock_generic_switch_multi][event.mock_generic_switch_button_fancy_button-state]
19591959
StateSnapshot({
19601960
'attributes': ReadOnlyDict({
19611961
'device_class': 'button',
@@ -1968,10 +1968,10 @@
19681968
'long_press',
19691969
'long_release',
19701970
]),
1971-
'friendly_name': 'Mock Generic Switch Button (2)',
1971+
'friendly_name': 'Mock Generic Switch Button (Fancy Button)',
19721972
}),
19731973
'context': <ANY>,
1974-
'entity_id': 'event.mock_generic_switch_button_2',
1974+
'entity_id': 'event.mock_generic_switch_button_fancy_button',
19751975
'last_changed': <ANY>,
19761976
'last_reported': <ANY>,
19771977
'last_updated': <ANY>,

tests/components/matter/snapshots/test_sensor.ambr

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9494,7 +9494,7 @@
94949494
'state': '0',
94959495
})
94969496
# ---
9497-
# name: test_sensors[mock_generic_switch_multi][sensor.mock_generic_switch_current_switch_position_2-entry]
9497+
# name: test_sensors[mock_generic_switch_multi][sensor.mock_generic_switch_current_switch_position_fancy_button-entry]
94989498
EntityRegistryEntrySnapshot({
94999499
'aliases': list([
95009500
None,
@@ -9510,20 +9510,20 @@
95109510
'disabled_by': None,
95119511
'domain': 'sensor',
95129512
'entity_category': <EntityCategory.DIAGNOSTIC: 'diagnostic'>,
9513-
'entity_id': 'sensor.mock_generic_switch_current_switch_position_2',
9513+
'entity_id': 'sensor.mock_generic_switch_current_switch_position_fancy_button',
95149514
'has_entity_name': True,
95159515
'hidden_by': None,
95169516
'icon': None,
95179517
'id': <ANY>,
95189518
'labels': set({
95199519
}),
95209520
'name': None,
9521-
'object_id_base': 'Current switch position (2)',
9521+
'object_id_base': 'Current switch position (Fancy Button)',
95229522
'options': dict({
95239523
}),
95249524
'original_device_class': None,
95259525
'original_icon': None,
9526-
'original_name': 'Current switch position (2)',
9526+
'original_name': 'Current switch position (Fancy Button)',
95279527
'platform': 'matter',
95289528
'previous_unique_id': None,
95299529
'suggested_object_id': None,
@@ -9533,14 +9533,14 @@
95339533
'unit_of_measurement': None,
95349534
})
95359535
# ---
9536-
# name: test_sensors[mock_generic_switch_multi][sensor.mock_generic_switch_current_switch_position_2-state]
9536+
# name: test_sensors[mock_generic_switch_multi][sensor.mock_generic_switch_current_switch_position_fancy_button-state]
95379537
StateSnapshot({
95389538
'attributes': ReadOnlyDict({
9539-
'friendly_name': 'Mock Generic Switch Current switch position (2)',
9539+
'friendly_name': 'Mock Generic Switch Current switch position (Fancy Button)',
95409540
'state_class': <SensorStateClass.MEASUREMENT: 'measurement'>,
95419541
}),
95429542
'context': <ANY>,
9543-
'entity_id': 'sensor.mock_generic_switch_current_switch_position_2',
9543+
'entity_id': 'sensor.mock_generic_switch_current_switch_position_fancy_button',
95449544
'last_changed': <ANY>,
95459545
'last_reported': <ANY>,
95469546
'last_updated': <ANY>,

tests/components/matter/test_event.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ async def test_generic_switch_multi_node(
7474
state_button_1 = hass.states.get("event.mock_generic_switch_button_1")
7575
assert state_button_1
7676
assert state_button_1.state == "unknown"
77-
# name should be 'DeviceName Button (1)' due to the label set to just '1'
77+
# name should be 'DeviceName Button (1)'
7878
assert state_button_1.name == "Mock Generic Switch Button (1)"
7979
# check event_types from featuremap 30 (0b11110) and MultiPressMax unset (default 2)
8080
assert state_button_1.attributes[ATTR_EVENT_TYPES] == [
@@ -84,11 +84,11 @@ async def test_generic_switch_multi_node(
8484
"long_release",
8585
]
8686
# check button 2
87-
state_button_2 = hass.states.get("event.mock_generic_switch_button_2")
87+
state_button_2 = hass.states.get("event.mock_generic_switch_button_fancy_button")
8888
assert state_button_2
8989
assert state_button_2.state == "unknown"
90-
# name should be 'DeviceName Button (2)'
91-
assert state_button_2.name == "Mock Generic Switch Button (2)"
90+
# name should be 'DeviceName Button (Fancy Button)' due to ha_entitylabel 'Fancy Button'
91+
assert state_button_2.name == "Mock Generic Switch Button (Fancy Button)"
9292
# check event_types from featuremap 30 (0b11110) and MultiPressMax 4
9393
assert state_button_2.attributes[ATTR_EVENT_TYPES] == [
9494
"multi_press_1",

0 commit comments

Comments
 (0)