11"""Defines a SmartThings device."""
22from collections import defaultdict , namedtuple
33import colorsys
4- from enum import Enum
54import re
65from typing import Any , Dict , Mapping , Optional , Sequence , Tuple
76
87from .api import Api
98from .capability import ATTRIBUTE_ON_VALUES , Attribute , Capability
109from .entity import Entity
1110
11+ DEVICE_TYPE_OCF = 'OCF'
12+ DEVICE_TYPE_DTH = 'DTH'
13+ DEVICE_TYPE_UNKNOWN = 'UNKNOWN'
14+ DEVICE_TYPE_ENDPOINT_APP = 'ENDPOINT_APP'
15+ DEVICE_TYPE_VIPER = 'VIPER'
16+
1217COLOR_HEX_MATCHER = re .compile ('^#[A-Fa-f0-9]{6}$' )
1318Status = namedtuple ('status' , 'value unit data' )
1419STATUS_NONE = Status (None , None , None )
@@ -58,15 +63,6 @@ class Command:
5863 unlock = 'unlock'
5964
6065
61- class DeviceType (Enum ):
62- """Define the device type."""
63-
64- UNKNOWN = 'UNKNOWN'
65- DTH = 'DTH'
66- ENDPOINT_APP = 'ENDPOINT_APP'
67- VIPER = 'VIPER'
68-
69-
7066class Device :
7167 """Represents a SmartThings device."""
7268
@@ -77,7 +73,7 @@ def __init__(self):
7773 self ._label = None
7874 self ._location_id = None
7975 self ._room_id = None
80- self ._type = DeviceType . UNKNOWN
76+ self ._type = DEVICE_TYPE_UNKNOWN
8177 self ._device_type_id = None
8278 self ._device_type_name = None
8379 self ._device_type_network = None
@@ -91,7 +87,7 @@ def apply_data(self, data: dict):
9187 self ._label = data ['label' ]
9288 self ._location_id = data ['locationId' ]
9389 self ._room_id = data .get ('roomId' )
94- self ._type = DeviceType ( data ['type' ])
90+ self ._type = data ['type' ]
9591 self ._components .clear ()
9692 self ._capabilities .clear ()
9793 for component in data ['components' ]:
@@ -101,7 +97,7 @@ def apply_data(self, data: dict):
10197 self ._capabilities .extend (capabilities )
10298 else :
10399 self ._components [component_id ] = capabilities
104- if self ._type is DeviceType . DTH :
100+ if self ._type == DEVICE_TYPE_DTH :
105101 dth = data ['dth' ]
106102 self ._device_type_id = dth ["deviceTypeId" ]
107103 self ._device_type_name = dth ["deviceTypeName" ]
@@ -140,7 +136,7 @@ def room_id(self):
140136 return self ._room_id
141137
142138 @property
143- def type (self ) -> DeviceType :
139+ def type (self ) -> str :
144140 """Get the SmartThings device type."""
145141 return self ._type
146142
0 commit comments