diff --git a/homeassistant/components/alexa/entities.py b/homeassistant/components/alexa/entities.py index 2f7f6dc996b..17cdab18df1 100644 --- a/homeassistant/components/alexa/entities.py +++ b/homeassistant/components/alexa/entities.py @@ -411,7 +411,7 @@ class SwitchCapabilities(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 == switch.DEVICE_CLASS_OUTLET: + if device_class == switch.SwitchDeviceClass.OUTLET: return [DisplayCategory.SMARTPLUG] return [DisplayCategory.SWITCH] @@ -470,20 +470,20 @@ 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 in (cover.DEVICE_CLASS_GARAGE, cover.DEVICE_CLASS_GATE): + if device_class in (cover.CoverDeviceClass.GARAGE, cover.CoverDeviceClass.GATE): return [DisplayCategory.GARAGE_DOOR] - if device_class == cover.DEVICE_CLASS_DOOR: + if device_class == cover.CoverDeviceClass.DOOR: return [DisplayCategory.DOOR] if device_class in ( - cover.DEVICE_CLASS_BLIND, - cover.DEVICE_CLASS_SHADE, - cover.DEVICE_CLASS_CURTAIN, + cover.CoverDeviceClass.BLIND, + cover.CoverDeviceClass.SHADE, + cover.CoverDeviceClass.CURTAIN, ): return [DisplayCategory.INTERIOR_BLIND] if device_class in ( - cover.DEVICE_CLASS_WINDOW, - cover.DEVICE_CLASS_AWNING, - cover.DEVICE_CLASS_SHUTTER, + cover.CoverDeviceClass.WINDOW, + cover.CoverDeviceClass.AWNING, + cover.CoverDeviceClass.SHUTTER, ): return [DisplayCategory.EXTERIOR_BLIND] @@ -492,7 +492,10 @@ class CoverCapabilities(AlexaEntity): def interfaces(self): """Yield the supported interfaces.""" 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) supported = self.entity.attributes.get(ATTR_SUPPORTED_FEATURES, 0) @@ -600,7 +603,7 @@ class MediaPlayerCapabilities(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 == media_player.DEVICE_CLASS_SPEAKER: + if device_class == media_player.MediaPlayerDeviceClass.SPEAKER: return [DisplayCategory.SPEAKER] return [DisplayCategory.TV] @@ -763,17 +766,20 @@ class BinarySensorCapabilities(AlexaEntity): """Return the type of binary sensor.""" attrs = self.entity.attributes if attrs.get(ATTR_DEVICE_CLASS) in ( - binary_sensor.DEVICE_CLASS_DOOR, - binary_sensor.DEVICE_CLASS_GARAGE_DOOR, - binary_sensor.DEVICE_CLASS_OPENING, - binary_sensor.DEVICE_CLASS_WINDOW, + binary_sensor.BinarySensorDeviceClass.DOOR, + binary_sensor.BinarySensorDeviceClass.GARAGE_DOOR, + binary_sensor.BinarySensorDeviceClass.OPENING, + binary_sensor.BinarySensorDeviceClass.WINDOW, ): 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 - 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