forked from sean9keenan/BigAssFansAPI
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathlargerExample.js
More file actions
41 lines (32 loc) · 1.3 KB
/
largerExample.js
File metadata and controls
41 lines (32 loc) · 1.3 KB
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
var bigAssApi = require("../");
bigAssApi.logging = false;
var myMaster = new bigAssApi.FanMaster(1); // Expect only one fan in my setup
console.log("Waiting for full update");
myMaster.onFanFullyUpdated = function(myBigAss){
// Filter out all fants that don't begin with "Sean" - that's in my fan's name!
var lowercaseName = myBigAss.name.toLowerCase();
if (lowercaseName.indexOf("sean") == -1) {
console.log(lowercaseName);
return;
}
// Will automatically update / retry setting for this connected fan
myBigAss.light.brightness = 1;
myBigAss.fan.speed = 2;
console.log("Initial Big Ass Light value: " + myBigAss.light.brightness);
// Register for an update callback (say if the phone updates the property)
myBigAss.light.registerUpdateCallback("brightness", function (newValue) {
console.log("Updated brightness value: " + myBigAss.light.brightness); // or newValue
});
myBigAss.light.update("brightness"); // Forces an update to brightness
myBigAss.fan.update("speed", function(err, value) {
if (err) {
console.log("Error encountered while trying to get update: " + err);
return;
}
console.log("Updated speed: " + value);
});
setTimeout(function () {
myBigAss.light.brightness = 0;
myBigAss.fan.speed = 1;
}, 3000)
};