-
Notifications
You must be signed in to change notification settings - Fork 13
/
pimatic-led-light.coffee
68 lines (53 loc) · 3.07 KB
/
pimatic-led-light.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
module.exports = (env) ->
# import device wrappers
IwyMaster = require('./devices/iwy_master')(env)
Milight = require('./devices/milight')(env)
MilightRF24 = require('./devices/milightRF24')(env)
Wifi370 = require('./devices/wifi370')(env)
unless process.env.NODE_ENV is 'travis-test'
Blinkstick = require('./devices/blinkstick')(env)
DummyLedLight = require('./devices/dummy')(env)
HyperionLedLight = require('./devices/hyperion')(env)
# import preadicares and actions
ColorActionProvider = require('./predicates_and_actions/color_action')(env)
class LedLightPlugin extends env.plugins.Plugin
init: (app, @framework, @config) =>
deviceConfigDef = require('./device-config-schema.coffee')
@framework.deviceManager.registerDeviceClass 'IwyMaster',
configDef: deviceConfigDef.IwyMaster
createCallback: (config) -> return new IwyMaster(config)
@framework.deviceManager.registerDeviceClass 'Wifi370',
configDef: deviceConfigDef.Wifi370
createCallback: (config) -> return new Wifi370(config)
@framework.deviceManager.registerDeviceClass 'Milight',
configDef: deviceConfigDef.Milight
createCallback: (config, lastState) -> return new Milight(config, lastState)
@framework.deviceManager.registerDeviceClass 'MilightRF24',
configDef: deviceConfigDef.MilightRF24
createCallback: (config, lastState) ->
return MilightRF24.connectToGateway(config).getDevice(config, lastState)
unless process.env.NODE_ENV is 'travis-test'
@framework.deviceManager.registerDeviceClass 'Blinkstick',
configDef: deviceConfigDef.Blinkstick
createCallback: (config) -> return new Blinkstick(config)
@framework.deviceManager.registerDeviceClass 'DummyLedLight',
configDef: deviceConfigDef.DummyLedLight
createCallback: (config) -> return new DummyLedLight(config)
@framework.deviceManager.registerDeviceClass 'Hyperion',
configDef: deviceConfigDef.HyperionLedLight
createCallback: (config) -> return new HyperionLedLight(config)
@framework.ruleManager.addActionProvider(new ColorActionProvider(@framework))
# wait till all plugins are loaded
@framework.on "after init", =>
# Check if the mobile-frontend was loaded and get a instance
mobileFrontend = @framework.pluginManager.getPlugin 'mobile-frontend'
if mobileFrontend?
mobileFrontend.registerAssetFile 'js', 'pimatic-led-light/ui/led-light.coffee'
mobileFrontend.registerAssetFile 'css', 'pimatic-led-light/ui/led-light.css'
mobileFrontend.registerAssetFile 'html', 'pimatic-led-light/ui/led-light.html'
mobileFrontend.registerAssetFile 'js', 'pimatic-led-light/ui/vendor/spectrum.js'
mobileFrontend.registerAssetFile 'css', 'pimatic-led-light/ui/vendor/spectrum.css'
mobileFrontend.registerAssetFile 'js', 'pimatic-led-light/ui/vendor/async.js'
else
env.logger.warn 'your plugin could not find the mobile-frontend. No gui will be available'
return new LedLightPlugin()