From 178b2d8c2278f9afe314f9200aff5ee339f50657 Mon Sep 17 00:00:00 2001 From: ochlocracy <5885236+ochlocracy@users.noreply.github.com> Date: Sun, 11 Oct 2020 12:09:05 -0400 Subject: [PATCH] Update display categories in Alexa (#41626) * Add new display categories from Alexa Smart Home API * Update Vacuum entities to use VACUUM_CLEANER category. * Update Automation entities to use ACTIVITY_TRIGGER category. * Update tests for Automation entities to use ACTIVITY_TRIGGER category. --- homeassistant/components/alexa/entities.py | 53 +++++++++++++++++++--- tests/components/alexa/test_smart_home.py | 19 +++----- 2 files changed, 53 insertions(+), 19 deletions(-) diff --git a/homeassistant/components/alexa/entities.py b/homeassistant/components/alexa/entities.py index 53cf35dfe75..574ba6b8ba7 100644 --- a/homeassistant/components/alexa/entities.py +++ b/homeassistant/components/alexa/entities.py @@ -96,9 +96,24 @@ class DisplayCategory: # to HDMI1. Applies to Scenes ACTIVITY_TRIGGER = "ACTIVITY_TRIGGER" - # Indicates media devices with video or photo capabilities. + # Indicates a device that emits pleasant odors and masks unpleasant odors in interior spaces. + AIR_FRESHENER = "AIR_FRESHENER" + + # Indicates a device that improves the quality of air in interior spaces. + AIR_PURIFIER = "AIR_PURIFIER" + + # Indicates a smart device in an automobile, such as a dash camera. + AUTO_ACCESSORY = "AUTO_ACCESSORY" + + # Indicates a security device with video or photo functionality. CAMERA = "CAMERA" + # Indicates a religious holiday decoration that often contains lights. + CHRISTMAS_TREE = "CHRISTMAS_TREE" + + # Indicates a device that makes coffee. + COFFEE_MAKER = "COFFEE_MAKER" + # Indicates a non-mobile computer, such as a desktop computer. COMPUTER = "COMPUTER" @@ -120,9 +135,16 @@ class DisplayCategory: # Indicates a game console, such as Microsoft Xbox or Nintendo Switch GAME_CONSOLE = "GAME_CONSOLE" - # Indicates a garage door. Garage doors must implement the ModeController interface to open and close the door. + # Indicates a garage door. + # Garage doors must implement the ModeController interface to open and close the door. GARAGE_DOOR = "GARAGE_DOOR" + # Indicates a wearable device that transmits audio directly into the ear. + HEADPHONES = "HEADPHONES" + + # Indicates a smart-home hub. + HUB = "HUB" + # Indicates a window covering on the inside of a structure. INTERIOR_BLIND = "INTERIOR_BLIND" @@ -144,18 +166,24 @@ class DisplayCategory: # Indicates a network-connected music system. MUSIC_SYSTEM = "MUSIC_SYSTEM" - # An endpoint that cannot be described in on of the other categories. - OTHER = "OTHER" - # Indicates a network router. NETWORK_HARDWARE = "NETWORK_HARDWARE" + # An endpoint that cannot be described in on of the other categories. + OTHER = "OTHER" + # Indicates an oven cooking appliance. OVEN = "OVEN" # Indicates a non-mobile phone, such as landline or an IP phone. PHONE = "PHONE" + # Indicates a device that prints. + PRINTER = "PRINTER" + + # Indicates a network router. + ROUTER = "ROUTER" + # Describes a combination of devices set to a specific state, when the # order of the state change is not important. For example a bedtime scene # might include turning off lights and lowering the thermostat, but the @@ -168,6 +196,13 @@ class DisplayCategory: # Indicates a security panel. SECURITY_PANEL = "SECURITY_PANEL" + # Indicates a security system. + SECURITY_SYSTEM = "SECURITY_SYSTEM" + + # Indicates an electric cooking device that sits on a countertop, cooks at low temperatures, + # and is often shaped like a cooking pot. + SLOW_COOKER = "SLOW_COOKER" + # Indicates an endpoint that locks. SMARTLOCK = "SMARTLOCK" @@ -198,6 +233,9 @@ class DisplayCategory: # Indicates the endpoint is a television. TV = "TV" + # Indicates a vacuum cleaner. + VACUUM_CLEANER = "VACUUM_CLEANER" + # Indicates a network-connected wearable device, such as an Apple Watch, Fitbit, or Samsung Gear. WEARABLE = "WEARABLE" @@ -347,6 +385,9 @@ class GenericCapabilities(AlexaEntity): def default_display_categories(self): """Return the display categories for this entity.""" + if self.entity.domain == automation.DOMAIN: + return [DisplayCategory.ACTIVITY_TRIGGER] + return [DisplayCategory.OTHER] def interfaces(self): @@ -769,7 +810,7 @@ class VacuumCapabilities(AlexaEntity): def default_display_categories(self): """Return the display categories for this entity.""" - return [DisplayCategory.OTHER] + return [DisplayCategory.VACUUM_CLEANER] def interfaces(self): """Yield the supported interfaces.""" diff --git a/tests/components/alexa/test_smart_home.py b/tests/components/alexa/test_smart_home.py index c3bbcbb7a31..9a7f5760270 100644 --- a/tests/components/alexa/test_smart_home.py +++ b/tests/components/alexa/test_smart_home.py @@ -1490,7 +1490,7 @@ async def test_automation(hass): appliance = await discovery_test(device, hass) assert appliance["endpointId"] == "automation#test" - assert appliance["displayCategories"][0] == "OTHER" + assert appliance["displayCategories"][0] == "ACTIVITY_TRIGGER" assert appliance["friendlyName"] == "Test automation" assert_endpoint_capabilities( appliance, "Alexa.PowerController", "Alexa.EndpointHealth", "Alexa" @@ -3296,10 +3296,7 @@ async def test_media_player_sound_mode_list_unsupported(hass): # Test equalizer controller is not there assert_endpoint_capabilities( - appliance, - "Alexa", - "Alexa.PowerController", - "Alexa.EndpointHealth", + appliance, "Alexa", "Alexa.PowerController", "Alexa.EndpointHealth" ) @@ -3459,7 +3456,7 @@ async def test_vacuum_discovery(hass): appliance = await discovery_test(device, hass) assert appliance["endpointId"] == "vacuum#test_1" - assert appliance["displayCategories"][0] == "OTHER" + assert appliance["displayCategories"][0] == "VACUUM_CLEANER" assert appliance["friendlyName"] == "Test vacuum 1" assert_endpoint_capabilities( @@ -3502,7 +3499,7 @@ async def test_vacuum_fan_speed(hass): appliance = await discovery_test(device, hass) assert appliance["endpointId"] == "vacuum#test_2" - assert appliance["displayCategories"][0] == "OTHER" + assert appliance["displayCategories"][0] == "VACUUM_CLEANER" assert appliance["friendlyName"] == "Test vacuum 2" capabilities = assert_endpoint_capabilities( @@ -3834,10 +3831,7 @@ async def test_camera_hass_urls(hass, mock_stream, url, result): "idle", {"friendly_name": "Test camera", "supported_features": 3}, ) - await async_process_ha_core_config( - hass, - {"external_url": url}, - ) + await async_process_ha_core_config(hass, {"external_url": url}) appliance = await discovery_test(device, hass) assert len(appliance["capabilities"]) == result @@ -3850,8 +3844,7 @@ async def test_initialize_camera_stream(hass, mock_camera, mock_stream): ) await async_process_ha_core_config( - hass, - {"external_url": "https://mycamerastream.test"}, + hass, {"external_url": "https://mycamerastream.test"} ) with patch(