3434import time
3535from enum import Enum
3636
37- __version__ = '1.0.7.0 '
37+ __version__ = '1.0.7.1 '
3838MODULE = __name__
3939PORT = 4000
4040
6565LAST_SEEN_DURATION_MINUTES = 5
6666NO_RGB_VALUES = (1 , 0 , 0 )
6767TYPE_LIGHT_TUNABLE_WHITE = 2
68- TYPE_LIGHT_RGB = 10
68+ TYPE_LIGHT_RGBW = 10
6969
7070DEFAULT_LUMINANCE = 1
7171DEFAULT_TEMPERATURE = 2700
7272MIN_TEMPERATURE_TUNABLE_WHITE = 2700
7373MAX_TEMPERATURE_TUNABLE_WHITE = 6500
74- MIN_TEMPERATURE_RGB = 1900
75- MAX_TEMPERATURE_RGB = 6500
74+ MIN_TEMPERATURE_RGBW = 1900
75+ MAX_TEMPERATURE_RGBW = 6500
7676MAX_LUMINANCE = 100
7777MAX_COLOUR = 255
7878
@@ -87,10 +87,11 @@ class DeviceSubType(Enum):
8787 LIGHT_FIXED_WHITE = 1
8888 LIGHT_TUNABLE_WHITE = 2
8989 LIGHT_RGB = 3
90- PLUG = 4
91- CONTACT_SENSOR = 5
92- MOTION_SENSOR = 6
93- SWITCH = 7
90+ LIGHT_RGBW = 4
91+ PLUG = 5
92+ SWITCH = 6
93+ CONTACT_SENSOR = 7
94+ MOTION_SENSOR = 8
9495
9596
9697class DeviceType (Enum ):
@@ -112,9 +113,12 @@ class DeviceType(Enum):
112113 4 : {'type' : DeviceType .LIGHT ,
113114 'subtype' : DeviceSubType .LIGHT_FIXED_WHITE ,
114115 'name' : 'light fixed white' },
116+ 8 : {'type' : DeviceType .LIGHT ,
117+ 'subtype' : DeviceSubType .LIGHT_RGB ,
118+ 'name' : 'light rgb' },
115119 10 : {'type' : DeviceType .LIGHT ,
116- 'subtype' : DeviceSubType .LIGHT_RGB ,
117- 'name' : 'light rgb ' },
120+ 'subtype' : DeviceSubType .LIGHT_RGBW ,
121+ 'name' : 'light rgbw ' },
118122 16 : {'type' : DeviceType .PLUG ,
119123 'subtype' : DeviceSubType .PLUG ,
120124 'name' : 'plug' },
@@ -144,7 +148,7 @@ class DeviceType(Enum):
144148 'name' : 'tradfri tunable white' ,
145149 'min_temp' : 2200 ,
146150 'max_temp' : 4000
147- },
151+ }
148152}
149153
150154
@@ -242,9 +246,9 @@ def __init__(self, conn, addr, type_id, type_id_assumed):
242246 self .__devicename = (device_info ['name' ] if type_id == type_id_assumed
243247 else UNKNOWN_DEVICENAME )
244248
245- if self .__devicesubtype in (DeviceSubType .CONTACT_SENSOR ,
246- DeviceSubType .MOTION_SENSOR ,
247- DeviceSubType .SWITCH ):
249+ if self .__devicesubtype in (DeviceSubType .SWITCH ,
250+ DeviceSubType .CONTACT_SENSOR ,
251+ DeviceSubType .MOTION_SENSOR ):
248252 self .__lum = 0
249253 self .__temp = 0
250254 self .__red = 0
@@ -274,12 +278,16 @@ def __init__(self, conn, addr, type_id, type_id_assumed):
274278 'min_temp' , MIN_TEMPERATURE_TUNABLE_WHITE )
275279 self .__max_temp = device_info .get (
276280 'max_temp' , MAX_TEMPERATURE_TUNABLE_WHITE )
281+ elif self .__devicesubtype == DeviceSubType .LIGHT_RGB :
282+ self .__supported_features = set (('on' , 'lum' , 'rgb' ))
283+ self .__min_temp = self .__temp
284+ self .__max_temp = self .__temp
277285 else :
278286 self .__supported_features = set (('on' , 'lum' , 'temp' , 'rgb' ))
279287 self .__min_temp = device_info .get ('min_temp' ,
280- MIN_TEMPERATURE_RGB )
288+ MIN_TEMPERATURE_RGBW )
281289 self .__max_temp = device_info .get ('max_temp' ,
282- MAX_TEMPERATURE_RGB )
290+ MAX_TEMPERATURE_RGBW )
283291
284292 def name (self ):
285293 """
@@ -891,7 +899,8 @@ def __str__(self):
891899class Lightify :
892900 """ main osram lightify class
893901 """
894- def __init__ (self , host , new_device_types = None , log_level = logging .INFO , loghandler = None ):
902+ def __init__ (self , host , new_device_types = None , log_level = logging .INFO ,
903+ loghandler = None ):
895904 """
896905 :param host: lightify gateway host
897906 :param new_device_types: dict of additional device types to merge with
@@ -900,10 +909,10 @@ def __init__(self, host, new_device_types=None, log_level=logging.INFO, loghandl
900909 'type': <DeviceType instance>,
901910 'subtype': <DeviceSubType instance>,
902911 'name': <name of the device>,
903- # only for LIGHT_TUNABLE_WHITE and LIGHT_RGB :
912+ # only for LIGHT_TUNABLE_WHITE and LIGHT_RGBW :
904913 'min_temp': <minimum temperature>, # optional, default:
905914 # 2700 (LIGHT_TUNABLE_WHITE)
906- # 1900 (LIGHT_RGB )
915+ # 1900 (LIGHT_RGBW )
907916 'max_temp': <maximum temperature> # optional, default: 6500
908917 },
909918 ...
@@ -926,10 +935,7 @@ def __init__(self, host, new_device_types=None, log_level=logging.INFO, loghandl
926935
927936 self .__logger = logging .getLogger (MODULE )
928937 self .__logger .setLevel (log_level )
929- if loghandler :
930- self .__logger .addHandler (loghandler )
931- else :
932- self .__logger .addHandler (logging .NullHandler ())
938+ self .__logger .addHandler (loghandler or logging .NullHandler ())
933939 self .__logger .info ('Initializing %s, version=%s' , MODULE , __version__ )
934940
935941 # a sequence number used to number commands sent to the gateway
@@ -980,7 +986,8 @@ def set_loglevel(self, log_level):
980986 :param log_level: logging.loglevel Enum
981987 """
982988 self .__logger .setLevel (log_level )
983- self .__logger .info ("set log level to '%s'" , logging .getLevelName (log_level ))
989+ self .__logger .info ('set log level to %s' ,
990+ logging .getLevelName (log_level ))
984991
985992 def set_lights_updated (self ):
986993 """ update lights updated timestamp
@@ -1576,7 +1583,7 @@ def update_all_light_status(self, throttling_interval=None):
15761583 if (red , green , blue ) == NO_RGB_VALUES :
15771584 type_id_assumed = TYPE_LIGHT_TUNABLE_WHITE
15781585 else :
1579- type_id_assumed = TYPE_LIGHT_RGB
1586+ type_id_assumed = TYPE_LIGHT_RGBW
15801587 else :
15811588 type_id_assumed = type_id
15821589
0 commit comments