-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
45 lines (36 loc) · 990 Bytes
/
index.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
const dotenv = require('dotenv');
const axios = require('axios').default;
dotenv.config();
var lightsCollection = process.env.HUE_LIGHT_ID.split(',');
var ableton = require('ableton-push2');
var push2 = new ableton.Push2(port = 'live');
const controlLight = async (lightID, on) => {
try {
return await axios.put('http://' + process.env.HUE_BRIDGE_IP + '/api/' + process.env.HUE_USERNAME + '/lights/' + lightID + '/state',
{
"on": on,
"sat": 254,
"bri": 255,
"hue": 89000
}
);
} catch (error) {
console.error(error);
}
}
push2.midi.on('cc', function (msg) {
// RECORDING
if (msg.controller == 86) {
console.log('🔴 RECORDING...');
lightsCollection.forEach(function (light) {
controlLight(light, true);
});
}
// STOP RECORDING
if (msg.controller == 85) {
console.log('🚫 NOT RECORDING');
lightsCollection.forEach(function (light) {
controlLight(light, false);
});
}
});