From 6f6c670b3b0efdd2e98a3a3ce39b234b1dd4b1d4 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Sun, 3 May 2020 15:29:12 -0500 Subject: [PATCH] Make alexa and google aware of DEVICE_CLASS_GATE (#35103) --- homeassistant/components/alexa/entities.py | 4 ++-- .../components/google_assistant/const.py | 1 + tests/components/alexa/test_smart_home.py | 23 +++++++++++++++++++ 3 files changed, 26 insertions(+), 2 deletions(-) diff --git a/homeassistant/components/alexa/entities.py b/homeassistant/components/alexa/entities.py index e22c5c62db9..09ce71bb3bc 100644 --- a/homeassistant/components/alexa/entities.py +++ b/homeassistant/components/alexa/entities.py @@ -386,7 +386,7 @@ class CoverCapabilities(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 == cover.DEVICE_CLASS_GARAGE: + if device_class in (cover.DEVICE_CLASS_GARAGE, cover.DEVICE_CLASS_GATE): return [DisplayCategory.GARAGE_DOOR] if device_class == cover.DEVICE_CLASS_DOOR: return [DisplayCategory.DOOR] @@ -408,7 +408,7 @@ class CoverCapabilities(AlexaEntity): def interfaces(self): """Yield the supported interfaces.""" device_class = self.entity.attributes.get(ATTR_DEVICE_CLASS) - if device_class != cover.DEVICE_CLASS_GARAGE: + if device_class not in (cover.DEVICE_CLASS_GARAGE, cover.DEVICE_CLASS_GATE): yield AlexaPowerController(self.entity) supported = self.entity.attributes.get(ATTR_SUPPORTED_FEATURES, 0) diff --git a/homeassistant/components/google_assistant/const.py b/homeassistant/components/google_assistant/const.py index 37fef6f2d79..9a133b5e6b7 100644 --- a/homeassistant/components/google_assistant/const.py +++ b/homeassistant/components/google_assistant/const.py @@ -124,6 +124,7 @@ DOMAIN_TO_GOOGLE_TYPES = { DEVICE_CLASS_TO_GOOGLE_TYPES = { (cover.DOMAIN, cover.DEVICE_CLASS_GARAGE): TYPE_GARAGE, + (cover.DOMAIN, cover.DEVICE_CLASS_GATE): TYPE_GARAGE, (cover.DOMAIN, cover.DEVICE_CLASS_DOOR): TYPE_DOOR, (switch.DOMAIN, switch.DEVICE_CLASS_SWITCH): TYPE_SWITCH, (switch.DOMAIN, switch.DEVICE_CLASS_OUTLET): TYPE_OUTLET, diff --git a/tests/components/alexa/test_smart_home.py b/tests/components/alexa/test_smart_home.py index 91864027873..0da4c4da6fd 100644 --- a/tests/components/alexa/test_smart_home.py +++ b/tests/components/alexa/test_smart_home.py @@ -4,6 +4,7 @@ import pytest from homeassistant.components.alexa import messages, smart_home import homeassistant.components.camera as camera +from homeassistant.components.cover import DEVICE_CLASS_GATE from homeassistant.components.media_player.const import ( SUPPORT_NEXT_TRACK, SUPPORT_PAUSE, @@ -2630,6 +2631,28 @@ async def test_cover_garage_door(hass): ) +async def test_cover_gate(hass): + """Test gate cover discovery.""" + device = ( + "cover.test_gate", + "off", + { + "friendly_name": "Test cover gate", + "supported_features": 3, + "device_class": DEVICE_CLASS_GATE, + }, + ) + appliance = await discovery_test(device, hass) + + assert appliance["endpointId"] == "cover#test_gate" + assert appliance["displayCategories"][0] == "GARAGE_DOOR" + assert appliance["friendlyName"] == "Test cover gate" + + assert_endpoint_capabilities( + appliance, "Alexa.ModeController", "Alexa.EndpointHealth", "Alexa" + ) + + async def test_cover_position_mode(hass): """Test cover discovery and position using modeController.""" device = (