-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathindex.js
More file actions
57 lines (36 loc) · 1.13 KB
/
Copy pathindex.js
File metadata and controls
57 lines (36 loc) · 1.13 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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
'use strict';
var SkyRemote = require('sky-remote');
var Accessory, Service, Characteristic;
module.exports = function(homebridge) {
Accessory = homebridge.platformAccessory;
Service = homebridge.hap.Service;
Characteristic = homebridge.hap.Characteristic;
homebridge.registerAccessory("homebridge-sky-plus", "SkyPlus", SkyPlusAccessory);
};
function SkyPlusAccessory(log, config, api) {
this.log = log;
this.config = config;
this.name = config.name || 'Sky+';
var remoteControl = new SkyRemote(config.ipAddress);
this.skyPlus = remoteControl;
}
SkyPlusAccessory.prototype = {
setPowerState: function(powerOn, callback) {
this.log("Sending on command to '" + this.name + "'...");
this.skyPlus.press('power', function(error) {
if (error) {
this.log('Failed to turn on ' + this.name + '. ' + error);
}
callback();
});
},
identify: function(callback) {
this.log("Identify...");
callback();
},
getServices: function() {
var switchService = new Service.Switch(this.name);
switchService.getCharacteristic(Characteristic.On).on('set', this.setPowerState.bind(this));
return [switchService];
}
};