-
Notifications
You must be signed in to change notification settings - Fork 4
/
hue-zll.coffee
679 lines (562 loc) · 23.1 KB
/
hue-zll.coffee
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
# Hue ZLL Pimatic plugin
module.exports = (env) ->
# Require the bluebird promise library
Promise = env.require 'bluebird'
# Require the [cassert library](https://github.com/rhoot/cassert).
assert = env.require 'cassert'
t = env.require('decl-api').types
huebase = require('./hue') env
# helper function to mix in key/value pairs from another object
extend = (obj, mixin) ->
obj[key] = value for key, value of mixin
obj
class HueZLLPlugin extends env.plugins.Plugin
init: (app, @framework, @config) =>
deviceConfigDef = require("./device-config-schema")
deviceClasses = [
HueZLLOnOffLight,
HueZLLOnOffLightGroup,
HueZLLDimmableLight,
HueZLLDimmableLightGroup,
HueZLLColorTempLight,
HueZLLColorTempLightGroup,
HueZLLColorLight,
HueZLLColorLightGroup,
HueZLLExtendedColorLight,
HueZLLExtendedColorLightGroup,
HueZLLScenes
]
for DeviceClass in deviceClasses
do (DeviceClass) =>
@framework.deviceManager.registerDeviceClass(DeviceClass.name, {
configDef: deviceConfigDef[DeviceClass.name],
prepareConfig: HueZLLOnOffLight.prepareConfig,
createCallback: (deviceConfig) => new DeviceClass(deviceConfig, this)
})
actions = require("./actions") env
@framework.ruleManager.addActionProvider(new actions.HueZLLDimmerActionProvider(@framework))
@framework.ruleManager.addActionProvider(new actions.CtActionProvider(@framework))
@framework.ruleManager.addActionProvider(new actions.HueSatActionProvider(@framework))
@framework.ruleManager.addActionProvider(new actions.ActivateHueSceneActionProvider(@framework))
if @config.username?.length > 0
@hueApiAvailable = @discoverBridge().then =>
env.logger.info "Requesting status of lights, light groups and scenes from the Hue API"
else
env.logger.warn "Hue bridge username/key is not defined in the configuration. Please run device discovery."
@hueApiAvailable = Promise.reject Error("Hue bridge username/key unavailable")
@hueApiAvailable.suppressUnhandledRejections()
@framework.on "after init", =>
# Check if the mobile-frontent was loaded and get a instance
mobileFrontend = @framework.pluginManager.getPlugin 'mobile-frontend'
if mobileFrontend?
mobileFrontend.registerAssetFile 'js',
"pimatic-hue-zll/node_modules/spectrum-colorpicker/spectrum.js"
mobileFrontend.registerAssetFile 'css',
"pimatic-hue-zll/node_modules/spectrum-colorpicker/spectrum.css"
mobileFrontend.registerAssetFile 'js', "pimatic-hue-zll/app/hue-zll-light.coffee"
mobileFrontend.registerAssetFile 'css', "pimatic-hue-zll/app/hue-zll-light.css"
mobileFrontend.registerAssetFile 'html', "pimatic-hue-zll/app/hue-zll-light.jade"
else
env.logger.warn "mobile-frontend not loaded, no gui will be available"
@framework.deviceManager.on "discover", @onDiscover
prepareConfig: (pConf) ->
# Previous versions unintentionally added a 'name' property to the plugin config in newer Pimatic versions
delete pConf['name'] if pConf['name']?
onDiscover: (eventData) =>
@discoverBridge(eventData
).then( (host) =>
@registerUser(host, eventData.time)
).then( =>
env.logger.debug "Starting discovery of Hue devices"
lightsInventoryPromise = huebase.BaseHueLight.discover(@hueApi)
groupsInventoryPromise = huebase.BaseHueLightGroup.discover(@hueApi)
lightsInventoryPromise.then(@discoverLights)
Promise.join lightsInventoryPromise, groupsInventoryPromise, @discoverLightGroups
)
discoverBridge: (eventData) =>
if @config.host?.length > 0
# If the Hue bridge hostname or ip is manually configured in the configuration, use that
apiPromise = Promise.resolve(@config.host)
else
# If not, start discovery of the bridge
@framework.deviceManager.discoverMessage(
'pimatic-hue-zll',
"No Hue bridge defined in the configuration, starting automatic search for the Hue bridge"
)
apiPromise = huebase.searchBridge(Math.min(eventData?.time or 5000, 5000)
).then( (ipaddr) =>
@framework.deviceManager.discoverMessage(
'pimatic-hue-zll',
"Found Hue bridge on ip #{ipaddr}. " + \
"(To avoid auto-discovery on startup, add \"host\": \"#{ipaddr}\" to the plugin config.)"
)
return ipaddr
).catch( (error) =>
@framework.deviceManager.discoverMessage(
'pimatic-hue-zll',
error.message
)
throw error
)
return apiPromise.then(@initApi)
registerUser: (hostname, timeout) =>
timeout = Math.min(timeout, 30000)
if @config.username?.length > 0
return Promise.resolve [hostname, @config.username]
else
@framework.deviceManager.discoverMessage(
'pimatic-hue-zll',
"No Hue API username (key) defined in the configuration. Attempting to register; " + \
"Please press the link button on the Hue bridge within #{timeout / 1000}s!"
)
os = require "os"
return huebase.registerUser(
@hueApi, hostname, "pimatic-hue-zll##{os.hostname()}", timeout
).then( (apiKey) =>
@framework.deviceManager.discoverMessage(
'pimatic-hue-zll',
"Created Hue API key #{apiKey}. Adding it to the plugin configuration."
)
@config.username = apiKey
@initApi(hostname)
return [hostname, apiKey]
).catch( (error) =>
@framework.deviceManager.discoverMessage(
'pimatic-hue-zll',
"Hue API username registration failed; #{error.message}"
)
throw error
)
initApi: (hostOrIp) =>
env.logger.debug "(Re)Initializing Hue API using host #{hostOrIp}"
# Make a shallow copy of @config to avoid actually changing the configuration
config = extend {}, @config
config.host = hostOrIp
# Initialize hueApi for the plugin
@hueApi = huebase.initHueApi(config)
return hostOrIp
discoverLights: (lightsInventory) =>
env.logger.debug "Hue API lights inventory:"
env.logger.debug lightsInventory
hueLights = {}
for id, dev of @framework.deviceManager.devices
if dev instanceof HueZLLOnOffLight and dev.constructor.name.match(/^HueZLL.+Light$/)
hueLights[dev.config.hueId] = dev
for light in lightsInventory.lights
deviceClass = HueZLLPlugin.deviceClass(light.type)
if deviceClass?
if not hueLights[light.id]?
config = {
class: deviceClass,
name: light.name,
hueId: light.id
}
config['ignoreReachability'] = true if light.manufacturername.toLowerCase() is "osram"
descr = "#{config.name} (#{light.manufacturername} #{light.modelid}) [#{light.type}]"
@framework.deviceManager.discoveredDevice(
'pimatic-hue-zll',
"Hue light #{config.hueId}: #{descr}",
config
)
else
env.logger.debug "Skipping known hue light id #{light.id}"
else
env.logger.warn "Could not classify hue light id #{light.id}, type: #{light.type}"
discoverLightGroups: (lightsInventory, groupsInventory) =>
env.logger.debug "Hue API light groups inventory:"
env.logger.debug groupsInventory
hueLightGroups = {}
for id, dev of @framework.deviceManager.devices
if dev instanceof HueZLLOnOffLight and dev.constructor.name.match(/^HueZLL.+LightGroup$/)
hueLightGroups[dev.config.hueId] = dev
for group in groupsInventory
group.id = parseInt(group.id)
if not hueLightGroups[group.id]?
if group.lights? or group.id is 0
# Attempt to find the appropriate light group type (class) based on the capabilities of the
# lights in the group
if group.lights?
groupLights = (parseInt(id) for id in group.lights)
else if group.id is 0
groupLights = (parseInt(light.id) for light in lightsInventory.lights)
lightTypes = (HueZLLPlugin.deviceClass(light.type) for light in lightsInventory.lights \
when parseInt(light.id) in groupLights)
deviceClass = lightTypes.reduce (devClass, d) ->
if devClass is d
devClass
else if devClass is 'HueZLLExtendedColorLight'
d
else if devClass in ['HueZLLColorTempLight','HueZLLColorLight'] and d isnt 'HueZLLExtendedColorLight'
'HueZLLDimmableLight'
else if devClass is 'HueZLLDimmableLight' and d is 'HueZLLOnOffLight'
d
else
devClass
deviceClass += 'Group'
else
deviceClass = 'HueZLLExtendedColorLightGroup' # No info available, so let's provide all functionality
config = {
class: deviceClass,
name: group.name,
hueId: group.id
}
descr = config.name
if config.hueId is 0
descr += " (all lights)"
else if groupLights?
descr += " (lights #{groupLights})"
@framework.deviceManager.discoveredDevice(
'pimatic-hue-zll',
"Hue light group #{config.hueId}: #{descr}",
config
)
else
env.logger.debug "Skipping known hue light group id #{group.id}"
@deviceClass: (deviceType) ->
return switch deviceType
when "On/Off plug-in unit" then 'HueZLLOnOffLight'
when "Dimmable light" then 'HueZLLDimmableLight'
when "Color temperature light" then 'HueZLLColorTempLight'
when "Color light" then 'HueZLLColorLight'
when "Extended color light" then 'HueZLLExtendedColorLight'
else null
class HueZLLOnOffLight extends env.devices.SwitchActuator
HueClass: huebase.BaseHueLight
_reachable: null
template: "huezllonoff"
constructor: (@config, @plugin) ->
@id = @config.id
@name = if @config.name.length isnt 0 then @config.name else "#{@constructor.name}_#{@id}"
@extendAttributesActions()
super()
@hue = new @HueClass(this, @plugin, @config.hueId)
@hue.deviceStateCallback = @_lightStateReceived
@plugin.hueApiAvailable.then(
@init
).catch( (error) =>
env.logger.error "Can't initialize device #{@id} because the Hue API failed to initialize: #{error.message}"
)
destroy: () ->
@plugin.framework.removeListener "after init", @_cbAfterInit
@hue.destroy()
super()
extendAttributesActions: () =>
@attributes = extend (extend {}, @attributes),
reachable:
description: "Light is reachable?"
type: t.boolean
@prepareConfig: (deviceConfig) ->
deviceConfig.name = "" unless deviceConfig.name?
init: () =>
if @config.polling < 0
# Enable global polling (for all lights or groups)
@lightStateInitialized = @hue.setupGlobalPolling(@plugin.config.polling, @plugin.config.retries * 8)
else
@lightStateInitialized = @hue.setupPolling(@config.polling, @plugin.config.retries * 8)
@lightStateInitialized.then(@_replaceName) if @config.name.length is 0
# Ask Pimatic to wait completing init until the first poll has completed
@_cbAfterInit = (context) =>
context.waitForIt @lightStateInitialized
@plugin.framework.on "after init", @_cbAfterInit
# Wait on first poll on initialization
waitForInit: (callback) => Promise.join @lightStateInitialized, callback
getState: -> @waitForInit ( => @_state )
getReachable: -> @waitForInit ( => @_reachable )
poll: -> @hue.poll()
saveLightState: (transitionTime=null) => @waitForInit ( =>
hueStateChange = @hue.createStateChange @filterConflictingState @hue.getLightStatus().state
hueStateChange.transition(transitionTime) if transitionTime?
return hueStateChange
)
restoreLightState: (stateChange) =>
return @hue.changeHueState(stateChange).then( => @_lightStateReceived(stateChange.payload()) )
_lightStateReceived: (rstate) =>
@_setState rstate.on
@_setReachable rstate.reachable
return rstate
filterConflictingState: (state) -> state
_replaceName: =>
if @hue.name? and @hue.name.length isnt 0
env.logger.info("Changing name of #{@constructor.name} device #{@id} " +
"from \"#{@name}\" to \"#{@hue.name}\"")
@updateName @hue.name
changeStateTo: (state) ->
hueStateChange = @hue.prepareStateChange().on(state)
return @hue.changeHueState(hueStateChange).then( ( => @_setState state) )
_setReachable: (reachable) ->
unless @_reachable is reachable
@_reachable = reachable
@emit "reachable", reachable
class HueZLLOnOffLightGroup extends HueZLLOnOffLight
HueClass: huebase.BaseHueLightGroup
init: () =>
if @config.hueId is 0
# Group 0 (all lights) can't be polled
@lightStateInitialized = Promise.resolve(true)
else
super()
class HueZLLDimmableLight extends HueZLLOnOffLight
HueClass: huebase.BaseHueLight
_dimlevel: null
template: "huezlldimmable"
extendAttributesActions: () =>
super()
@attributes = extend (extend {}, @attributes),
dimlevel:
description: "The current dim level"
type: t.number
unit: "%"
@actions = extend (extend {}, @actions),
changeDimlevelTo:
description: "Sets the level of the dimmer"
params:
dimlevel:
type: t.number
# Wait on first poll on initialization
getDimlevel: -> @waitForInit ( => @_dimlevel )
_lightStateReceived: (rstate) =>
super(rstate)
@_setDimlevel rstate.bri / 254 * 100
return rstate
changeDimlevelTo: (state, transitionTime=null) ->
hueStateChange = @hue.prepareStateChange().on(true).bri(state / 100 * 254)
hueStateChange.transition(transitionTime) if transitionTime?
return @hue.changeHueState(hueStateChange).then( ( =>
@_setState true
@_setDimlevel state
) )
_setDimlevel: (level) =>
level = parseFloat(level)
assert(not isNaN(level))
assert 0 <= level <= 100
unless @_dimlevel is level
@_dimlevel = level
@emit "dimlevel", level
class HueZLLDimmableLightGroup extends HueZLLDimmableLight
HueClass: huebase.BaseHueLightGroup
ColorTempMixin =
_ct: null
changeCtTo: (ct, transitionTime=null) ->
hueStateChange = @hue.prepareStateChange().on(true).ct(ct)
hueStateChange.transition(transitionTime) if transitionTime?
return @hue.changeHueState(hueStateChange).then( ( =>
@_setState true
@_setCt ct
) )
_setCt: (ct) ->
ct = parseFloat(ct)
assert not isNaN(ct)
assert 153 <= ct <= 500
unless @_ct is ct
@_ct = ct
@emit "ct", ct
getCt: -> @waitForInit ( => @_ct )
ColormodeMixin =
_colormode: null
_setColormode: (colormode) ->
unless @_colormode is colormode
@_colormode = colormode
@emit "colormode", colormode
getColormode: -> @waitForInit ( => @_colormode )
class HueZLLColorTempLight extends HueZLLDimmableLight
HueClass: huebase.BaseHueLight
template: "huezllcolortemp"
extendAttributesActions: () =>
super()
@attributes = extend (extend {}, @attributes),
ct:
description: "the color temperature"
type: t.number
colormode:
description: "the mode of color last set"
type: t.string
@actions = extend (extend {}, @actions),
changeCtTo:
description: "changes the color temperature"
params:
ct:
type: t.number
_lightStateReceived: (rstate) =>
super(rstate)
@_setCt rstate.ct if rstate.ct? and rstate.ct > 0
@_setColormode rstate.colormode if rstate.colormode?
return rstate
filterConflictingState: (state) ->
filteredState = {}
filteredState[k] = v for k, v of state when not state.colormode? or not (
(k in ['hue','sat'] and state.colormode != 'hs') or
(k == 'xy' and state.colormode != 'xy') or (k == 'ct' and state.colormode != 'ct'))
return filteredState
extend HueZLLColorTempLight.prototype, ColorTempMixin
extend HueZLLColorTempLight.prototype, ColormodeMixin
class HueZLLColorTempLightGroup extends HueZLLColorTempLight
HueClass: huebase.BaseHueLightGroup
extend HueZLLColorTempLightGroup.prototype, ColorTempMixin
extend HueZLLColorTempLightGroup.prototype, ColormodeMixin
class HueZLLColorLight extends HueZLLDimmableLight
HueClass: huebase.BaseHueLight
_hue: null
_sat: null
template: "huezllcolor"
extendAttributesActions: () =>
super()
@attributes = extend (extend {}, @attributes),
hue:
description: "the color hue value"
type: t.number
unit: "%"
sat:
description: "the color saturation value"
type: t.number
unit: "%"
colormode:
description: "the mode of color last set"
type: t.string
@actions = extend (extend {}, @actions),
changeHueTo:
description: "changes the color hue"
params:
hue:
type: t.number
changeSatTo:
description: "changes the color saturation"
params:
sat:
type: t.number
changeHueSatTo:
description: "changes the color hue and saturation"
params:
hue:
type: t.number
sat:
type: t.number
_lightStateReceived: (rstate) =>
super(rstate)
@_setHue (rstate.hue / 65535 * 100) if rstate.hue?
@_setSat (rstate.sat / 254 * 100) if rstate.sat?
@_setColormode rstate.colormode if rstate.colormode?
return rstate
changeHueTo: (hue, transitionTime=null) ->
hueStateChange = @hue.prepareStateChange().on(true).hue(hue / 100 * 65535)
hueStateChange.transition(transitionTime) if transitionTime?
return @hue.changeHueState(hueStateChange).then( ( =>
@_setState true
@_setHue hue
) )
changeSatTo: (sat, transitionTime=null) ->
hueStateChange = @hue.prepareStateChange().on(true).sat(sat / 100 * 254)
hueStateChange.transition(transitionTime) if transitionTime?
return @hue.changeHueState(hueStateChange).then( ( =>
@_setState true
@_setSat sat
) )
changeHueSatTo: (hue, sat, transitionTime=null) ->
hueStateChange = @hue.prepareStateChange().on(true).hue(hue / 100 * 65535).sat(sat / 100 * 254)
hueStateChange.transition(transitionTime) if transitionTime?
return @hue.changeHueState(hueStateChange).then( ( =>
@_setState true
@_setHue hue
@_setSat sat
) )
_setHue: (hueVal) ->
hueVal = parseFloat(hueVal)
assert not isNaN(hueVal)
assert 0 <= hueVal <= 100
unless @_hue is hueVal
@_hue = hueVal
@emit "hue", hueVal
_setSat: (satVal) ->
satVal = parseFloat(satVal)
assert not isNaN(satVal)
assert 0 <= satVal <= 100
unless @_sat is satVal
@_sat = satVal
@emit "sat", satVal
getHue: -> @waitForInit ( => @_hue )
getSat: -> @waitForInit ( => @_sat )
filterConflictingState: (state) ->
filteredState = {}
filteredState[k] = v for k, v of state when not state.colormode? or not (
(k in ['hue','sat'] and state.colormode != 'hs') or
(k == 'xy' and state.colormode != 'xy') or (k == 'ct' and state.colormode != 'ct'))
return filteredState
extend HueZLLColorLight.prototype, ColormodeMixin
class HueZLLColorLightGroup extends HueZLLColorLight
HueClass: huebase.BaseHueLightGroup
extend HueZLLColorLightGroup.prototype, ColormodeMixin
class HueZLLExtendedColorLight extends HueZLLColorLight
HueClass: huebase.BaseHueLight
template: "huezllextendedcolor"
extendAttributesActions: () =>
super()
@attributes = extend (extend {}, @attributes),
ct:
description: "the color temperature"
type: t.number
@actions = extend (extend {}, @actions),
changeCtTo:
description: "changes the color temperature"
params:
ct:
type: t.number
_lightStateReceived: (rstate) =>
super(rstate)
@_setCt rstate.ct if rstate.ct? and rstate.ct > 0
return rstate
extend HueZLLExtendedColorLight.prototype, ColorTempMixin
extend HueZLLExtendedColorLight.prototype, ColormodeMixin
class HueZLLExtendedColorLightGroup extends HueZLLExtendedColorLight
HueClass: huebase.BaseHueLightGroup
extend HueZLLExtendedColorLightGroup.prototype, ColorTempMixin
extend HueZLLExtendedColorLightGroup.prototype, ColormodeMixin
class HueZLLScenes extends env.devices.Device
_lastActivatedScene: null
constructor: (@config, @plugin) ->
@id = @config.id
@name = @config.name
@extendAttributesActions()
super()
@hue = new huebase.BaseHueScenes(this, @plugin)
@plugin.hueApiAvailable.then(
@init
).catch( (error) =>
env.logger.error "Can't initialize device #{@id} because the Hue API failed to initialize: #{error.message}"
)
destroy: () ->
@plugin.framework.removeListener "after init", @_cbAfterInit
@hue.destroy()
super()
extendAttributesActions: () =>
@attributes = extend (extend {}, @attributes),
lastActivatedScene:
description: "Hue scene last activated by Pimatic"
type: t.string
@actions = extend (extend {}, @actions),
activateScene:
description: "activates a Hue scene"
params:
sceneName:
type: t.string
groupId:
type: t.number
init: () =>
scenesRetrieved = @hue.requestScenes(@plugin.config.retries * 8).then( =>
env.logger.info "Retrieved #{Object.keys(@hue.scenesByName).length} unique scenes from the Hue API:",
('"'+name+'"' for name in @getKnownSceneNames()).join(', ')
)
# Ask Pimatic to wait completing init until the scenes have been retrieved
@_cbAfterInit = (context) =>
context.waitForIt scenesRetrieved
@plugin.framework.on "after init", @_cbAfterInit
activateScene: (sceneName, groupId=null) =>
return @hue.activateSceneByName(sceneName, groupId).then( =>
@_setLastActivatedScene sceneName
)
_setLastActivatedScene: (sceneName) ->
assert sceneName.length > 0
unless @_lastActivatedScene is sceneName
@_lastActivatedScene = sceneName
@emit "lastActivatedScene", sceneName
getLastActivatedScene: -> Promise.resolve @_lastActivatedScene
getKnownSceneNames: => (scene.uniquename for key, scene of @hue.scenesByName)
return new HueZLLPlugin()