-
Notifications
You must be signed in to change notification settings - Fork 1
/
actionRunner.js
58 lines (51 loc) · 1.82 KB
/
actionRunner.js
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
/*
actionRunner
*/
var _ = require('underscore');
var util = require('util');
var logger = require('./logger');
var Lights = require('./hueWrapper');
var Actions = require('./action/actionDirectory');
var Events = require('./events');
var Scenes = require('./scenes');
var Devices = require('./irDevices');
var Light = Lights.Light;
var LightAction = Actions.LightAction;
var SceneAction = Actions.SceneAction;
var DeviceAction = Actions.DeviceAction;
var StateUpdatingAction = Actions.StateUpdatingAction;
/*
addAction(Events.SOMEBODY_HOME, new SceneAction(Scenes.SomebodyHome));
addAction(Events.HOUSE_EMPTY, new SceneAction(Scenes.AllOff));
addAction(Events.BATHROOM_MOTION_ACTIVE, new LightAction(new Light("Toilet"), new Lights.OnLightCommand()));
addAction(Events.ENTRANCE_MOTION_ACTIVE, new SceneAction(Scenes.WelcomeHome));
addAction(
Events.ENTRANCE_MOTION_ACTIVE,
new DeviceAction("TV", new Devices.DeviceTogglePowerCommand()));
addAction(
Events.ENTRANCE_MOTION_ACTIVE,
new DeviceAction("Stereo", new Devices.DeviceTogglePowerCommand()));
addAction(
Events.ENTRANCE_MOTION_ACTIVE,
new DeviceAction("ATV", new Devices.DeviceSelectCommand()));
addAction(Events.ENTRANCE_MOTION_INACTIVE, new LightAction(Lights.EntranceGroup, new Lights.OffLightCommand()));
addAction(
Events.ENTRANCE_MOTION_INACTIVE,
new LightAction(new Light("Hallway"), new Lights.BrightnessLightCommand(40, 2)));
addAction(
Events.BATHROOM_ENTRANCE_MOTION_ACTIVE,
new LightAction(new Light("Bathtub"), new Lights.OnLightCommand()));
*/
var actionTypes;
var actions = {};
module.exports = conditions = {
defineActionType: function(_actionType) {
actionTypes = _actionType;
},
defineAction: function(actionId, action) {
actions[actionId] = action;
},
runAction: function(actionId) {
actions[actionId].run();
}
};