Change Alexa default display category based on media_player device_class (#28191)
* Support default display category based one media_player device_class. * Support default display category based one media_player device_class.pull/28211/head
parent
5c8a9c2815
commit
38428308fc
|
@ -391,6 +391,10 @@ class MediaPlayerCapabilities(AlexaEntity):
|
|||
|
||||
def default_display_categories(self):
|
||||
"""Return the display categories for this entity."""
|
||||
device_class = self.entity.attributes.get(ATTR_DEVICE_CLASS)
|
||||
if device_class == media_player.DEVICE_CLASS_SPEAKER:
|
||||
return [DisplayCategory.SPEAKER]
|
||||
|
||||
return [DisplayCategory.TV]
|
||||
|
||||
def interfaces(self):
|
||||
|
|
|
@ -968,6 +968,25 @@ async def test_media_player_power(hass):
|
|||
)
|
||||
|
||||
|
||||
async def test_media_player_speaker(hass):
|
||||
"""Test media player discovery with device class speaker."""
|
||||
device = (
|
||||
"media_player.test",
|
||||
"off",
|
||||
{
|
||||
"friendly_name": "Test media player",
|
||||
"supported_features": 51765,
|
||||
"volume_level": 0.75,
|
||||
"device_class": "speaker",
|
||||
},
|
||||
)
|
||||
appliance = await discovery_test(device, hass)
|
||||
|
||||
assert appliance["endpointId"] == "media_player#test"
|
||||
assert appliance["displayCategories"][0] == "SPEAKER"
|
||||
assert appliance["friendlyName"] == "Test media player"
|
||||
|
||||
|
||||
async def test_alert(hass):
|
||||
"""Test alert discovery."""
|
||||
device = ("alert.test", "off", {"friendly_name": "Test alert"})
|
||||
|
|
Loading…
Reference in New Issue