-
Notifications
You must be signed in to change notification settings - Fork 1
/
scenes.js
64 lines (54 loc) · 2.72 KB
/
scenes.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
59
60
61
62
63
64
var _ = require('underscore');
var hue = require('./hueWrapper');
var logger = require('./logger');
var Actions = require('./action/actionDirectory');
var LightAction = Actions.LightAction;
var ColorBrightnessLightCommand = hue.ColorBrightnessLightCommand;
var OffLightCommand = hue.OffLightCommand;
var Color = require('./color.js');
var LightGroup = hue.LightGroup;
var Light = hue.Light;
(function(context) {
function Scene(lightActions) {
this.actionType = "Scene";
this.lightActions = lightActions;
if (!_.isArray(lightActions)) {
this.lightActions = [lightActions];
}
}
Scene.prototype.activate = function() {
logger.i("Scene was activated.");
_.each(this.lightActions, function(lightAction) {
lightAction.run();
});
}
var entranceLightGroup = new LightGroup("entrance", ["Stairs Bottom", "Stairs Top", "Hallway"]);
var bedroomLightGroup = new LightGroup("bedroom", ["Bedroom Main", "Bedroom Window", "Bedroom Spotlight"]);
var hallwayLightGroup = new LightGroup("hallway", ["Hallway", "Stairs Top", "Stairs Bottom"]);
var stairsLightGroup = new LightGroup("stairs", ["Stairs Top", "Stairs Bottom"]);
var bathroomLightGroup = new LightGroup("bathroom", ["Bathtub", "Toilet"]);
var allLightGroup = new LightGroup("all", [
"Bedroom Main", "Bedroom Window", "Bedroom Spotlight",
"Hallway", "Stairs Top", "Stairs Bottom", "Bathtub", "Toilet"
]);
context.TurnOffHallwayLights = new Scene([
new LightAction(new Light("Stairs Top"), new OffLightCommand()),
new LightAction(new Light("Hallway"), new OffLightCommand()),
]);
context.TurnOnHallwayLights = new Scene([
new LightAction(new Light("Stairs Top"), new ColorBrightnessLightCommand(Color.randomColorful(), "ComputedBrightnessLevel", 0)),
new LightAction(new Light("Hallway"), new ColorBrightnessLightCommand(Color.randomColorful(), "ComputedBrightnessLevel", 1)),
]);
context.WelcomeHome = new Scene([
new LightAction(new Light("Stairs Bottom"), new ColorBrightnessLightCommand(Color.randomColorful(), 100, 1)),
new LightAction(new Light("Stairs Top"), new ColorBrightnessLightCommand(Color.randomColorful(), 100, 3)),
new LightAction(new Light("Hallway"), new ColorBrightnessLightCommand(Color.randomColorful(), 100, 5)),
new LightAction(bedroomLightGroup, new ColorBrightnessLightCommand(Color.randomColorful(), 100, 5))
]);
context.AllOff = new Scene([
new LightAction(allLightGroup, new OffLightCommand())
]);
context.SomebodyHome = new Scene([
new LightAction(bedroomLightGroup, new ColorBrightnessLightCommand(Color.randomColor(), 100, 10))
]);
})(exports);