Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 10 additions & 8 deletions homeassistant/components/velux/cover.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""Support for Velux covers."""
from pyvlx import OpeningDevice, Position
from pyvlx.opening_device import Awning, Blind, GarageDoor, RollerShutter, Window
from pyvlx.opening_device import Awning, Blind, GarageDoor, Gate, RollerShutter, Window

from homeassistant.components.cover import (
ATTR_POSITION,
Expand Down Expand Up @@ -73,17 +73,19 @@ def current_cover_position(self):

@property
def device_class(self):
"""Define this cover as either window/blind/awning/shutter."""
if isinstance(self.node, Window):
return "window"
if isinstance(self.node, Blind):
return "blind"
if isinstance(self.node, RollerShutter):
return "shutter"
"""Define this cover as either awning, blind, garage, gate, shutter or window."""
if isinstance(self.node, Awning):
return "awning"
if isinstance(self.node, Blind):
return "blind"
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are constants in the cover entity integration for the valid device classes. Please import and use those here.

DEVICE_CLASS_AWNING = "awning"
DEVICE_CLASS_BLIND = "blind"
DEVICE_CLASS_CURTAIN = "curtain"
DEVICE_CLASS_DAMPER = "damper"
DEVICE_CLASS_DOOR = "door"
DEVICE_CLASS_GARAGE = "garage"
DEVICE_CLASS_GATE = "gate"
DEVICE_CLASS_SHADE = "shade"
DEVICE_CLASS_SHUTTER = "shutter"
DEVICE_CLASS_WINDOW = "window"

if isinstance(self.node, GarageDoor):
return "garage"
if isinstance(self.node, Gate):
return "gate"
if isinstance(self.node, RollerShutter):
return "shutter"
if isinstance(self.node, Window):
return "window"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

btw, do you have any idea, why the velux windows are shown as shutters in apple home.

(which has the effect, that all windows open, when you say "hey siri, open the shutters". :-) )

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm sorry, I don't know. I'm not quite there yet in my integration. I will definitely have a look at it, because I have Somfy roller shutters as well as Velux windows :-)

return "window"

@property
Expand Down