mirror of
https://github.com/home-assistant/core.git
synced 2025-07-24 21:57:51 +00:00
Support default display category based one switch device_class. (#28221)
This commit is contained in:
parent
f971e16749
commit
dc8c085872
@ -270,6 +270,10 @@ class SwitchCapabilities(AlexaEntity):
|
|||||||
|
|
||||||
def default_display_categories(self):
|
def default_display_categories(self):
|
||||||
"""Return the display categories for this entity."""
|
"""Return the display categories for this entity."""
|
||||||
|
device_class = self.entity.attributes.get(ATTR_DEVICE_CLASS)
|
||||||
|
if device_class == switch.DEVICE_CLASS_OUTLET:
|
||||||
|
return [DisplayCategory.SMARTPLUG]
|
||||||
|
|
||||||
return [DisplayCategory.SWITCH]
|
return [DisplayCategory.SWITCH]
|
||||||
|
|
||||||
def interfaces(self):
|
def interfaces(self):
|
||||||
|
@ -168,6 +168,23 @@ async def test_switch(hass, events):
|
|||||||
properties.assert_equal("Alexa.PowerController", "powerState", "ON")
|
properties.assert_equal("Alexa.PowerController", "powerState", "ON")
|
||||||
|
|
||||||
|
|
||||||
|
async def test_outlet(hass, events):
|
||||||
|
"""Test switch with device class outlet discovery."""
|
||||||
|
device = (
|
||||||
|
"switch.test",
|
||||||
|
"on",
|
||||||
|
{"friendly_name": "Test switch", "device_class": "outlet"},
|
||||||
|
)
|
||||||
|
appliance = await discovery_test(device, hass)
|
||||||
|
|
||||||
|
assert appliance["endpointId"] == "switch#test"
|
||||||
|
assert appliance["displayCategories"][0] == "SMARTPLUG"
|
||||||
|
assert appliance["friendlyName"] == "Test switch"
|
||||||
|
assert_endpoint_capabilities(
|
||||||
|
appliance, "Alexa.PowerController", "Alexa.EndpointHealth"
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
async def test_light(hass):
|
async def test_light(hass):
|
||||||
"""Test light discovery."""
|
"""Test light discovery."""
|
||||||
device = ("light.test_1", "on", {"friendly_name": "Test light 1"})
|
device = ("light.test_1", "on", {"friendly_name": "Test light 1"})
|
||||||
|
Loading…
x
Reference in New Issue
Block a user