-
Notifications
You must be signed in to change notification settings - Fork 1
/
irDevices.js
50 lines (41 loc) · 1.57 KB
/
irDevices.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
var _ = require('underscore');
var logger = require('./logger');
var http = require('http');
(function(exports) {
function IrDevice(deviceName) {
this.deviceName = deviceName;
}
IrDevice.prototype.act = function(action) {
var options = {
host: '10.0.0.50',
port: 8556,
path: '/?action=' + this.deviceName + action
};
logger.i("Posting to ir device: " + action);
http.get(options, function(res) {
console.log("Got response: " + res.statusCode);
}).on('error', function(e) {
console.log("Got error: " + e.message);
});
}
function DeviceTogglePowerCommand() {}
DeviceTogglePowerCommand.prototype.execute = function(deviceName) {
new IrDevice(deviceName).act("Power");
}
function DeviceIncreaseVolumeCommand() {}
DeviceIncreaseVolumeCommand.prototype.execute = function(deviceName) {
new IrDevice(deviceName).act("VolUp");
}
function DeviceDecreaseVolumeCommand() {}
DeviceDecreaseVolumeCommand.prototype.execute = function(deviceName) {
new IrDevice(deviceName).act("VolDown");
}
function DeviceSelectCommand() {}
DeviceSelectCommand.prototype.execute = function(deviceName) {
new IrDevice(deviceName).act("Select");
}
exports.DeviceTogglePowerCommand = DeviceTogglePowerCommand;
exports.DeviceIncreaseVolumeCommand = DeviceIncreaseVolumeCommand;
exports.DeviceDecreaseVolumeCommand = DeviceDecreaseVolumeCommand;
exports.DeviceSelectCommand = DeviceSelectCommand;
})(exports);