Skip to content

Commit

Permalink
Move device_class
Browse files Browse the repository at this point in the history
  • Loading branch information
tetienne committed Jul 25, 2021
1 parent 1e6733f commit 5fc5089
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 35 deletions.
7 changes: 6 additions & 1 deletion custom_components/tahoma/cover_devices/horizontal_cover.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""Support for TaHoma cover - shutters etc."""
from homeassistant.components.cover import ATTR_POSITION
from homeassistant.components.cover import ATTR_POSITION, DEVICE_CLASS_AWNING

from custom_components.tahoma.cover_devices.tahoma_cover import TahomaCover

Expand All @@ -13,6 +13,11 @@
class TahomaHorizontalCover(TahomaCover):
"""Representation of a TaHoma Cover."""

@property
def device_class(self):
"""Return the class of the device."""
return DEVICE_CLASS_AWNING

@property
def current_cover_position(self):
"""
Expand Down
33 changes: 0 additions & 33 deletions custom_components/tahoma/cover_devices/tahoma_cover.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,6 @@
from homeassistant.components.cover import (
ATTR_POSITION,
ATTR_TILT_POSITION,
DEVICE_CLASS_AWNING,
DEVICE_CLASS_BLIND,
DEVICE_CLASS_CURTAIN,
DEVICE_CLASS_GARAGE,
DEVICE_CLASS_GATE,
DEVICE_CLASS_SHUTTER,
DEVICE_CLASS_WINDOW,
SUPPORT_CLOSE,
SUPPORT_CLOSE_TILT,
SUPPORT_OPEN,
Expand Down Expand Up @@ -87,23 +80,6 @@
SUPPORT_COVER_POSITION_LOW_SPEED = 1024


TAHOMA_COVER_DEVICE_CLASSES = {
"Awning": DEVICE_CLASS_AWNING,
"Blind": DEVICE_CLASS_BLIND,
"Curtain": DEVICE_CLASS_CURTAIN,
"ExteriorScreen": DEVICE_CLASS_BLIND,
"ExteriorVenetianBlind": DEVICE_CLASS_BLIND,
"GarageDoor": DEVICE_CLASS_GARAGE,
"Gate": DEVICE_CLASS_GATE,
"MyFoxSecurityCamera": DEVICE_CLASS_SHUTTER,
"Pergola": DEVICE_CLASS_AWNING,
"RollerShutter": DEVICE_CLASS_SHUTTER,
"SwingingShutter": DEVICE_CLASS_SHUTTER,
"VeluxInteriorBlind": DEVICE_CLASS_BLIND,
"Window": DEVICE_CLASS_WINDOW,
}


class TahomaCover(TahomaEntity, CoverEntity):
"""Representation of a TaHoma Cover."""

Expand Down Expand Up @@ -156,15 +132,6 @@ def is_closed(self):

return None

@property
def device_class(self):
"""Return the class of the device."""
return (
TAHOMA_COVER_DEVICE_CLASSES.get(self.device.widget)
or TAHOMA_COVER_DEVICE_CLASSES.get(self.device.ui_class)
or DEVICE_CLASS_BLIND
)

@property
def icon(self):
"""Return the icon to use in the frontend, if any."""
Expand Down
35 changes: 34 additions & 1 deletion custom_components/tahoma/cover_devices/vertical_cover.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
"""Support for TaHoma cover - shutters etc."""
from homeassistant.components.cover import ATTR_POSITION
from homeassistant.components.cover import (
ATTR_POSITION,
DEVICE_CLASS_AWNING,
DEVICE_CLASS_BLIND,
DEVICE_CLASS_CURTAIN,
DEVICE_CLASS_GARAGE,
DEVICE_CLASS_GATE,
DEVICE_CLASS_SHUTTER,
DEVICE_CLASS_WINDOW,
)

from custom_components.tahoma.cover_devices.tahoma_cover import TahomaCover

Expand All @@ -24,10 +33,34 @@

SUPPORT_COVER_POSITION_LOW_SPEED = 1024

TAHOMA_COVER_DEVICE_CLASSES = {
"Blind": DEVICE_CLASS_BLIND,
"Curtain": DEVICE_CLASS_CURTAIN,
"ExteriorScreen": DEVICE_CLASS_BLIND,
"ExteriorVenetianBlind": DEVICE_CLASS_BLIND,
"GarageDoor": DEVICE_CLASS_GARAGE,
"Gate": DEVICE_CLASS_GATE,
"MyFoxSecurityCamera": DEVICE_CLASS_SHUTTER,
"Pergola": DEVICE_CLASS_AWNING,
"RollerShutter": DEVICE_CLASS_SHUTTER,
"SwingingShutter": DEVICE_CLASS_SHUTTER,
"VeluxInteriorBlind": DEVICE_CLASS_BLIND,
"Window": DEVICE_CLASS_WINDOW,
}


class TahomaVerticalCover(TahomaCover):
"""Representation of a TaHoma Cover."""

@property
def device_class(self):
"""Return the class of the device."""
return (
TAHOMA_COVER_DEVICE_CLASSES.get(self.device.widget)
or TAHOMA_COVER_DEVICE_CLASSES.get(self.device.ui_class)
or DEVICE_CLASS_BLIND
)

@property
def current_cover_position(self):
"""
Expand Down

0 comments on commit 5fc5089

Please sign in to comment.