From cc1951c13db0eec7b4b561841f6386a806435092 Mon Sep 17 00:00:00 2001 From: mnaggatz <62095545+mnaggatz@users.noreply.github.com> Date: Mon, 25 May 2020 00:46:31 +0200 Subject: [PATCH] Use device class constants for velux cover entity (#36078) * Add support for Velux Gates * Comment expanded and listing sorted alphabetically. * There are constants in the cover entity integration for the valid device classes. Import and use those here. * Blank line deleted * Reformate code because of "CheckFormat" error * Import only the names we need instead of the whole module * Reformate code because of "CheckFormat" error * isort error --- homeassistant/components/velux/cover.py | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/homeassistant/components/velux/cover.py b/homeassistant/components/velux/cover.py index 1decffeb744..e8e210c1e53 100644 --- a/homeassistant/components/velux/cover.py +++ b/homeassistant/components/velux/cover.py @@ -4,6 +4,12 @@ from pyvlx.opening_device import Awning, Blind, GarageDoor, Gate, RollerShutter, from homeassistant.components.cover import ( ATTR_POSITION, + DEVICE_CLASS_AWNING, + DEVICE_CLASS_BLIND, + DEVICE_CLASS_GARAGE, + DEVICE_CLASS_GATE, + DEVICE_CLASS_SHUTTER, + DEVICE_CLASS_WINDOW, SUPPORT_CLOSE, SUPPORT_OPEN, SUPPORT_SET_POSITION, @@ -19,7 +25,6 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info= """Set up cover(s) for Velux platform.""" entities = [] for node in hass.data[DATA_VELUX].pyvlx.nodes: - if isinstance(node, OpeningDevice): entities.append(VeluxCover(node)) async_add_entities(entities) @@ -75,18 +80,18 @@ class VeluxCover(CoverEntity): def device_class(self): """Define this cover as either awning, blind, garage, gate, shutter or window.""" if isinstance(self.node, Awning): - return "awning" + return DEVICE_CLASS_AWNING if isinstance(self.node, Blind): - return "blind" + return DEVICE_CLASS_BLIND if isinstance(self.node, GarageDoor): - return "garage" + return DEVICE_CLASS_GARAGE if isinstance(self.node, Gate): - return "gate" + return DEVICE_CLASS_GATE if isinstance(self.node, RollerShutter): - return "shutter" + return DEVICE_CLASS_SHUTTER if isinstance(self.node, Window): - return "window" - return "window" + return DEVICE_CLASS_WINDOW + return DEVICE_CLASS_WINDOW @property def is_closed(self):