Make alexa and google aware of DEVICE_CLASS_GATE (#35103)

This commit is contained in:
J. Nick Koston 2020-05-03 15:29:12 -05:00 committed by GitHub
parent 2af984917e
commit 6f6c670b3b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 26 additions and 2 deletions

View File

@ -386,7 +386,7 @@ class CoverCapabilities(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) 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] return [DisplayCategory.GARAGE_DOOR]
if device_class == cover.DEVICE_CLASS_DOOR: if device_class == cover.DEVICE_CLASS_DOOR:
return [DisplayCategory.DOOR] return [DisplayCategory.DOOR]
@ -408,7 +408,7 @@ class CoverCapabilities(AlexaEntity):
def interfaces(self): def interfaces(self):
"""Yield the supported interfaces.""" """Yield the supported interfaces."""
device_class = self.entity.attributes.get(ATTR_DEVICE_CLASS) 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) yield AlexaPowerController(self.entity)
supported = self.entity.attributes.get(ATTR_SUPPORTED_FEATURES, 0) supported = self.entity.attributes.get(ATTR_SUPPORTED_FEATURES, 0)

View File

@ -124,6 +124,7 @@ DOMAIN_TO_GOOGLE_TYPES = {
DEVICE_CLASS_TO_GOOGLE_TYPES = { DEVICE_CLASS_TO_GOOGLE_TYPES = {
(cover.DOMAIN, cover.DEVICE_CLASS_GARAGE): TYPE_GARAGE, (cover.DOMAIN, cover.DEVICE_CLASS_GARAGE): TYPE_GARAGE,
(cover.DOMAIN, cover.DEVICE_CLASS_GATE): TYPE_GARAGE,
(cover.DOMAIN, cover.DEVICE_CLASS_DOOR): TYPE_DOOR, (cover.DOMAIN, cover.DEVICE_CLASS_DOOR): TYPE_DOOR,
(switch.DOMAIN, switch.DEVICE_CLASS_SWITCH): TYPE_SWITCH, (switch.DOMAIN, switch.DEVICE_CLASS_SWITCH): TYPE_SWITCH,
(switch.DOMAIN, switch.DEVICE_CLASS_OUTLET): TYPE_OUTLET, (switch.DOMAIN, switch.DEVICE_CLASS_OUTLET): TYPE_OUTLET,

View File

@ -4,6 +4,7 @@ import pytest
from homeassistant.components.alexa import messages, smart_home from homeassistant.components.alexa import messages, smart_home
import homeassistant.components.camera as camera import homeassistant.components.camera as camera
from homeassistant.components.cover import DEVICE_CLASS_GATE
from homeassistant.components.media_player.const import ( from homeassistant.components.media_player.const import (
SUPPORT_NEXT_TRACK, SUPPORT_NEXT_TRACK,
SUPPORT_PAUSE, 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): async def test_cover_position_mode(hass):
"""Test cover discovery and position using modeController.""" """Test cover discovery and position using modeController."""
device = ( device = (