Make alexa and google aware of DEVICE_CLASS_GATE (#35103)
This commit is contained in:
parent
2af984917e
commit
6f6c670b3b
3 changed files with 26 additions and 2 deletions
|
@ -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)
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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 = (
|
||||
|
|
Loading…
Add table
Reference in a new issue