mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 11:17:21 +00:00
Use new DeviceClass enums in alexa (#61263)
Co-authored-by: epenet <epenet@users.noreply.github.com>
This commit is contained in:
parent
adf63d5116
commit
af603d0427
@ -411,7 +411,7 @@ 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)
|
device_class = self.entity.attributes.get(ATTR_DEVICE_CLASS)
|
||||||
if device_class == switch.DEVICE_CLASS_OUTLET:
|
if device_class == switch.SwitchDeviceClass.OUTLET:
|
||||||
return [DisplayCategory.SMARTPLUG]
|
return [DisplayCategory.SMARTPLUG]
|
||||||
|
|
||||||
return [DisplayCategory.SWITCH]
|
return [DisplayCategory.SWITCH]
|
||||||
@ -470,20 +470,20 @@ 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 in (cover.DEVICE_CLASS_GARAGE, cover.DEVICE_CLASS_GATE):
|
if device_class in (cover.CoverDeviceClass.GARAGE, cover.CoverDeviceClass.GATE):
|
||||||
return [DisplayCategory.GARAGE_DOOR]
|
return [DisplayCategory.GARAGE_DOOR]
|
||||||
if device_class == cover.DEVICE_CLASS_DOOR:
|
if device_class == cover.CoverDeviceClass.DOOR:
|
||||||
return [DisplayCategory.DOOR]
|
return [DisplayCategory.DOOR]
|
||||||
if device_class in (
|
if device_class in (
|
||||||
cover.DEVICE_CLASS_BLIND,
|
cover.CoverDeviceClass.BLIND,
|
||||||
cover.DEVICE_CLASS_SHADE,
|
cover.CoverDeviceClass.SHADE,
|
||||||
cover.DEVICE_CLASS_CURTAIN,
|
cover.CoverDeviceClass.CURTAIN,
|
||||||
):
|
):
|
||||||
return [DisplayCategory.INTERIOR_BLIND]
|
return [DisplayCategory.INTERIOR_BLIND]
|
||||||
if device_class in (
|
if device_class in (
|
||||||
cover.DEVICE_CLASS_WINDOW,
|
cover.CoverDeviceClass.WINDOW,
|
||||||
cover.DEVICE_CLASS_AWNING,
|
cover.CoverDeviceClass.AWNING,
|
||||||
cover.DEVICE_CLASS_SHUTTER,
|
cover.CoverDeviceClass.SHUTTER,
|
||||||
):
|
):
|
||||||
return [DisplayCategory.EXTERIOR_BLIND]
|
return [DisplayCategory.EXTERIOR_BLIND]
|
||||||
|
|
||||||
@ -492,7 +492,10 @@ 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 not in (cover.DEVICE_CLASS_GARAGE, cover.DEVICE_CLASS_GATE):
|
if device_class not in (
|
||||||
|
cover.CoverDeviceClass.GARAGE,
|
||||||
|
cover.CoverDeviceClass.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)
|
||||||
@ -600,7 +603,7 @@ class MediaPlayerCapabilities(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 == media_player.DEVICE_CLASS_SPEAKER:
|
if device_class == media_player.MediaPlayerDeviceClass.SPEAKER:
|
||||||
return [DisplayCategory.SPEAKER]
|
return [DisplayCategory.SPEAKER]
|
||||||
|
|
||||||
return [DisplayCategory.TV]
|
return [DisplayCategory.TV]
|
||||||
@ -763,17 +766,20 @@ class BinarySensorCapabilities(AlexaEntity):
|
|||||||
"""Return the type of binary sensor."""
|
"""Return the type of binary sensor."""
|
||||||
attrs = self.entity.attributes
|
attrs = self.entity.attributes
|
||||||
if attrs.get(ATTR_DEVICE_CLASS) in (
|
if attrs.get(ATTR_DEVICE_CLASS) in (
|
||||||
binary_sensor.DEVICE_CLASS_DOOR,
|
binary_sensor.BinarySensorDeviceClass.DOOR,
|
||||||
binary_sensor.DEVICE_CLASS_GARAGE_DOOR,
|
binary_sensor.BinarySensorDeviceClass.GARAGE_DOOR,
|
||||||
binary_sensor.DEVICE_CLASS_OPENING,
|
binary_sensor.BinarySensorDeviceClass.OPENING,
|
||||||
binary_sensor.DEVICE_CLASS_WINDOW,
|
binary_sensor.BinarySensorDeviceClass.WINDOW,
|
||||||
):
|
):
|
||||||
return self.TYPE_CONTACT
|
return self.TYPE_CONTACT
|
||||||
|
|
||||||
if attrs.get(ATTR_DEVICE_CLASS) == binary_sensor.DEVICE_CLASS_MOTION:
|
if attrs.get(ATTR_DEVICE_CLASS) == binary_sensor.BinarySensorDeviceClass.MOTION:
|
||||||
return self.TYPE_MOTION
|
return self.TYPE_MOTION
|
||||||
|
|
||||||
if attrs.get(ATTR_DEVICE_CLASS) == binary_sensor.DEVICE_CLASS_PRESENCE:
|
if (
|
||||||
|
attrs.get(ATTR_DEVICE_CLASS)
|
||||||
|
== binary_sensor.BinarySensorDeviceClass.PRESENCE
|
||||||
|
):
|
||||||
return self.TYPE_PRESENCE
|
return self.TYPE_PRESENCE
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user