homebridge-orro 1.0.0 → 1.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/config.schema.json +69 -33
- package/dist/platform.d.ts.map +1 -1
- package/dist/platform.js +5 -15
- package/dist/platform.js.map +1 -1
- package/dist/platformAccessory.d.ts +1 -6
- package/dist/platformAccessory.d.ts.map +1 -1
- package/dist/platformAccessory.js +65 -47
- package/dist/platformAccessory.js.map +1 -1
- package/dist/settings.d.ts +1 -1
- package/dist/settings.d.ts.map +1 -1
- package/dist/settings.js +1 -1
- package/dist/settings.js.map +1 -1
- package/package.json +3 -3
package/config.schema.json
CHANGED
|
@@ -1,35 +1,71 @@
|
|
|
1
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
|
-
|
|
2
|
+
"pluginAlias": "Homebridge Orro",
|
|
3
|
+
"pluginType": "platform",
|
|
4
|
+
"singular": true,
|
|
5
|
+
"headerDisplay": "Add one or more switches from your Orro network below",
|
|
6
|
+
"schema": {
|
|
7
|
+
"homeID": {
|
|
8
|
+
"title": "Home ID",
|
|
9
|
+
"type": "string",
|
|
10
|
+
"required": true
|
|
11
|
+
},
|
|
12
|
+
"accessToken": {
|
|
13
|
+
"title": "Offline Access Token",
|
|
14
|
+
"type": "string",
|
|
15
|
+
"required": true
|
|
16
|
+
},
|
|
17
|
+
"switches": {
|
|
18
|
+
"type": "array",
|
|
19
|
+
"items": {
|
|
20
|
+
"title": "Switches",
|
|
21
|
+
"type": "object",
|
|
22
|
+
"properties": {
|
|
23
|
+
"name": {
|
|
24
|
+
"title": "Name",
|
|
25
|
+
"type": "string",
|
|
26
|
+
"required": true
|
|
27
|
+
},
|
|
28
|
+
"serialNumber": {
|
|
29
|
+
"title": "Serial Number",
|
|
30
|
+
"type": "string",
|
|
31
|
+
"required": true
|
|
32
|
+
},
|
|
33
|
+
"switchID": {
|
|
34
|
+
"title": "Switch ID",
|
|
35
|
+
"type": "string",
|
|
36
|
+
"required": true
|
|
37
|
+
},
|
|
38
|
+
"ipAddress": {
|
|
39
|
+
"title": "IP Address",
|
|
40
|
+
"type": "string",
|
|
41
|
+
"required": true
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
"layout": [
|
|
48
|
+
{
|
|
49
|
+
"key": "config",
|
|
50
|
+
"type": "section",
|
|
51
|
+
"title": "Configuration",
|
|
52
|
+
"expandable": false,
|
|
53
|
+
"items": [
|
|
54
|
+
"homeID",
|
|
55
|
+
"accessToken"
|
|
56
|
+
]
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
"key": "switches",
|
|
60
|
+
"type": "array",
|
|
61
|
+
"orderable": false,
|
|
62
|
+
"buttonText": "Add Switch",
|
|
63
|
+
"items": [
|
|
64
|
+
"switches[].name",
|
|
65
|
+
"switches[].serialNumber",
|
|
66
|
+
"switches[].switchID",
|
|
67
|
+
"switches[].ipAddress"
|
|
68
|
+
]
|
|
69
|
+
}
|
|
70
|
+
]
|
|
35
71
|
}
|
package/dist/platform.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"platform.d.ts","sourceRoot":"","sources":["../src/platform.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,qBAAqB,EAAE,MAAM,EAAE,iBAAiB,EAAE,cAAc,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAK5H;;;;EAIE;AACF,qBAAa,YAAa,YAAW,qBAAqB;aAQlC,GAAG,EAAE,MAAM;aACX,MAAM,EAAE,cAAc;aACtB,GAAG,EAAE,GAAG;IAT5B,SAAgB,OAAO,EAAE,OAAO,OAAO,CAAwB;IAC/D,SAAgB,cAAc,EAAE,OAAO,cAAc,CAA+B;IAGpF,SAAgB,WAAW,EAAE,iBAAiB,EAAE,CAAM;gBAGlC,GAAG,EAAE,MAAM,EACX,MAAM,EAAE,cAAc,EACtB,GAAG,EAAE,GAAG;IAe5B;;;MAGE;IACF,kBAAkB,CAAC,SAAS,EAAE,iBAAiB;IAO/C;;;;MAIE;IACF,eAAe;
|
|
1
|
+
{"version":3,"file":"platform.d.ts","sourceRoot":"","sources":["../src/platform.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,qBAAqB,EAAE,MAAM,EAAE,iBAAiB,EAAE,cAAc,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAK5H;;;;EAIE;AACF,qBAAa,YAAa,YAAW,qBAAqB;aAQlC,GAAG,EAAE,MAAM;aACX,MAAM,EAAE,cAAc;aACtB,GAAG,EAAE,GAAG;IAT5B,SAAgB,OAAO,EAAE,OAAO,OAAO,CAAwB;IAC/D,SAAgB,cAAc,EAAE,OAAO,cAAc,CAA+B;IAGpF,SAAgB,WAAW,EAAE,iBAAiB,EAAE,CAAM;gBAGlC,GAAG,EAAE,MAAM,EACX,MAAM,EAAE,cAAc,EACtB,GAAG,EAAE,GAAG;IAe5B;;;MAGE;IACF,kBAAkB,CAAC,SAAS,EAAE,iBAAiB;IAO/C;;;;MAIE;IACF,eAAe;CAkDlB"}
|
package/dist/platform.js
CHANGED
|
@@ -17,7 +17,7 @@ class OrroPlatform {
|
|
|
17
17
|
this.Characteristic = this.api.hap.Characteristic;
|
|
18
18
|
// this is used to track restored cached accessories
|
|
19
19
|
this.accessories = [];
|
|
20
|
-
this.log.debug('Finished initializing platform:', this.config.
|
|
20
|
+
this.log.debug('Finished initializing platform:', this.config.platform);
|
|
21
21
|
// When this event is fired it means Homebridge has restored all cached accessories from disk.
|
|
22
22
|
// Dynamic Platform plugins should only register new accessories after this event was fired,
|
|
23
23
|
// in order to ensure they weren't added to homebridge already. This event can also be used
|
|
@@ -43,22 +43,12 @@ class OrroPlatform {
|
|
|
43
43
|
* must not be registered again to prevent "duplicate UUID" errors.
|
|
44
44
|
*/
|
|
45
45
|
discoverDevices() {
|
|
46
|
-
// EXAMPLE ONLY
|
|
47
|
-
// A real plugin you would discover accessories from the local network, cloud services
|
|
48
|
-
// or a user-defined array in the platform config.
|
|
49
|
-
const exampleDevices = [{
|
|
50
|
-
exampleUniqueId: 'ABCD',
|
|
51
|
-
exampleDisplayName: 'Bedroom',
|
|
52
|
-
}, {
|
|
53
|
-
exampleUniqueId: 'EFGH',
|
|
54
|
-
exampleDisplayName: 'Kitchen',
|
|
55
|
-
}];
|
|
56
46
|
// loop over the discovered devices and register each one if it has not already been registered
|
|
57
|
-
for (const device of
|
|
47
|
+
for (const device of this.config.switches) {
|
|
58
48
|
// generate a unique id for the accessory this should be generated from
|
|
59
49
|
// something globally unique, but constant, for example, the device serial
|
|
60
50
|
// number or MAC address
|
|
61
|
-
const uuid = this.api.hap.uuid.generate(device.
|
|
51
|
+
const uuid = this.api.hap.uuid.generate(device.serialNumber);
|
|
62
52
|
// see if an accessory with the same uuid has already been registered and restored from
|
|
63
53
|
// the cached devices we stored in the `configureAccessory` method above
|
|
64
54
|
const existingAccessory = this.accessories.find(accessory => accessory.UUID === uuid);
|
|
@@ -78,9 +68,9 @@ class OrroPlatform {
|
|
|
78
68
|
}
|
|
79
69
|
else {
|
|
80
70
|
// the accessory does not yet exist, so we need to create it
|
|
81
|
-
this.log.info('Adding new accessory:', device.
|
|
71
|
+
this.log.info('Adding new accessory:', device.name);
|
|
82
72
|
// create a new accessory
|
|
83
|
-
const accessory = new this.api.platformAccessory(device.
|
|
73
|
+
const accessory = new this.api.platformAccessory(device.name, uuid);
|
|
84
74
|
// store a copy of the device object in the `accessory.context`
|
|
85
75
|
// the `context` property can be used to store any data about the accessory you may need
|
|
86
76
|
accessory.context.device = device;
|
package/dist/platform.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"platform.js","sourceRoot":"","sources":["../src/platform.ts"],"names":[],"mappings":";;;AAEA,yCAAwD;AACxD,2DAA6C;AAE7C;;;;EAIE;AACF,MAAa,YAAY;IAOrB,YACoB,GAAW,EACX,MAAsB,EACtB,GAAQ;QAFR,QAAG,GAAH,GAAG,CAAQ;QACX,WAAM,GAAN,MAAM,CAAgB;QACtB,QAAG,GAAH,GAAG,CAAK;QATZ,YAAO,GAAmB,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,OAAO,CAAC;QAC/C,mBAAc,GAA0B,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,cAAc,CAAC;QAEpF,oDAAoD;QACpC,gBAAW,GAAwB,EAAE,CAAC;QAOlD,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,iCAAiC,EAAE,IAAI,CAAC,MAAM,CAAC,
|
|
1
|
+
{"version":3,"file":"platform.js","sourceRoot":"","sources":["../src/platform.ts"],"names":[],"mappings":";;;AAEA,yCAAwD;AACxD,2DAA6C;AAE7C;;;;EAIE;AACF,MAAa,YAAY;IAOrB,YACoB,GAAW,EACX,MAAsB,EACtB,GAAQ;QAFR,QAAG,GAAH,GAAG,CAAQ;QACX,WAAM,GAAN,MAAM,CAAgB;QACtB,QAAG,GAAH,GAAG,CAAK;QATZ,YAAO,GAAmB,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,OAAO,CAAC;QAC/C,mBAAc,GAA0B,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,cAAc,CAAC;QAEpF,oDAAoD;QACpC,gBAAW,GAAwB,EAAE,CAAC;QAOlD,IAAI,CAAC,GAAG,CAAC,K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AE,iBAAiB,CAAC,CAAC;gBAEpC,4GAA4G;gBAC5G,qDAAqD;gBACrD,2FAA2F;gBAC3F,2FAA2F;aAC9F;iBAAM;gBACH,4DAA4D;gBAC5D,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,uBAAuB,EAAE,MAAM,CAAC,IAAI,CAAC,CAAC;gBAEpD,yBAAyB;gBACzB,MAAM,SAAS,GAAG,IAAI,IAAI,CAAC,GAAG,CAAC,iBAAiB,CAAC,MAAM,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;gBAEpE,+DAA+D;gBAC/D,wFAAwF;gBACxF,SAAS,CAAC,OAAO,CAAC,MAAM,GAAG,MAAM,CAAC;gBAElC,8DAA8D;gBAC9D,+CAA+C;gBAC/C,IAAI,0BAAM,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;gBAE5B,sCAAsC;gBACtC,IAAI,CAAC,GAAG,CAAC,2BAA2B,CAAC,sBAAW,EAAE,wBAAa,EAAE,CAAC,SAAS,CAAC,CAAC,CAAC;aACjF;SACJ;IACL,CAAC;CACJ;AA3FD,oCA2FC"}
|
|
@@ -15,13 +15,8 @@ export declare class Switch {
|
|
|
15
15
|
*/
|
|
16
16
|
private state;
|
|
17
17
|
private connection;
|
|
18
|
-
private serialNumber;
|
|
19
|
-
private switchIP;
|
|
20
|
-
private switchID;
|
|
21
|
-
private homeID;
|
|
22
|
-
private accessToken;
|
|
23
18
|
constructor(platform: OrroPlatform, accessory: PlatformAccessory);
|
|
24
|
-
|
|
19
|
+
connect: () => Promise<void>;
|
|
25
20
|
/**
|
|
26
21
|
* Handle "SET" requests from HomeKit
|
|
27
22
|
* These are sent when the user changes the state of an accessory, for example, turning on a Light bulb.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"platformAccessory.d.ts","sourceRoot":"","sources":["../src/platformAccessory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,iBAAiB,EAAW,MAAM,YAAY,CAAC;AAC7E,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAG1C;;;;EAIE;AACF,qBAAa,MAAM;
|
|
1
|
+
{"version":3,"file":"platformAccessory.d.ts","sourceRoot":"","sources":["../src/platformAccessory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,iBAAiB,EAAW,MAAM,YAAY,CAAC;AAC7E,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAG1C;;;;EAIE;AACF,qBAAa,MAAM;IAeX,OAAO,CAAC,QAAQ,CAAC,QAAQ;IACzB,OAAO,CAAC,QAAQ,CAAC,SAAS;IAf9B,OAAO,CAAC,OAAO,CAAU;IAEzB;;;MAGE;IACF,OAAO,CAAC,KAAK,CAGX;IAEF,OAAO,CAAC,UAAU,CAAkB;gBAGf,QAAQ,EAAE,YAAY,EACtB,SAAS,EAAE,iBAAiB;IAgCjD,OAAO,sBA0CN;IAED;;;MAGE;IACI,KAAK,CAAC,KAAK,EAAE,mBAAmB;IAoBtC;;;;;;;;;;;;MAYE;IACI,KAAK,IAAI,OAAO,CAAC,mBAAmB,CAAC;IAM3C;;;MAGE;IACI,aAAa,CAAC,KAAK,EAAE,mBAAmB;CAoBjD"}
|
|
@@ -19,49 +19,56 @@ class Switch {
|
|
|
19
19
|
On: false,
|
|
20
20
|
Brightness: 100
|
|
21
21
|
};
|
|
22
|
-
this.
|
|
23
|
-
this.switchIP = '192.168.7.125';
|
|
24
|
-
this.switchID = 'de1bc286-51f7-480e-b702-7957b9952618';
|
|
25
|
-
this.homeID = '3debeb6b-023d-4dba-8e70-92663b6d2610';
|
|
26
|
-
this.accessToken = 'YxqRX78eQU_gyzdftPmOG_7n261njz2NFF3hgckXEyQjZGi7qS1RBGdeGhjIb0gYKRKA_wMqeu8RdG9Aybaz1Q';
|
|
27
|
-
this.getConnection = new Promise((resolve, reject) => {
|
|
28
|
-
if (this.connection) {
|
|
29
|
-
resolve(this.connection);
|
|
30
|
-
}
|
|
22
|
+
this.connect = async () => {
|
|
31
23
|
const client = new websocket_1.client();
|
|
32
|
-
|
|
24
|
+
this.platform.log.info('Connecting to:', `ws://${this.accessory.context.device.ipAddress}:8080/edison/${this.platform.config.homeID}`);
|
|
25
|
+
client.connect(`ws://${this.accessory.context.device.ipAddress}:8080/edison/${this.platform.config.homeID}`, null, null, [{ 'offline-access-token': this.platform.config.accessToken }]);
|
|
33
26
|
client.on('connect', connection => {
|
|
27
|
+
this.platform.log.info(`Connected to ${this.accessory.context.device.name}`);
|
|
34
28
|
// listen for system events
|
|
35
|
-
connection.on('message',
|
|
29
|
+
connection.on('message', response => {
|
|
36
30
|
try {
|
|
37
|
-
const
|
|
38
|
-
|
|
39
|
-
|
|
31
|
+
const { data } = JSON.parse(response.utf8Data);
|
|
32
|
+
const { dimmerLevel, onOff } = data || {};
|
|
33
|
+
// update on/off state if changed externally
|
|
34
|
+
if (typeof (onOff) === 'boolean' && onOff !== this.state.On) {
|
|
35
|
+
this.platform.log.info(`Updated on to ${onOff ? 'true' : 'false'} from system event`);
|
|
36
|
+
this.state.On = onOff;
|
|
37
|
+
this.service.updateCharacteristic(this.platform.Characteristic.On, onOff);
|
|
38
|
+
}
|
|
39
|
+
// update dimmer level if changed externally
|
|
40
|
+
if (dimmerLevel >= 0 && dimmerLevel !== this.state.Brightness) {
|
|
41
|
+
this.platform.log.info(`Updated brightness to ${dimmerLevel} from system event`);
|
|
42
|
+
this.state.Brightness = dimmerLevel;
|
|
43
|
+
this.service.updateCharacteristic(this.platform.Characteristic.Brightness, dimmerLevel);
|
|
40
44
|
}
|
|
41
45
|
}
|
|
42
46
|
catch (e) {
|
|
43
|
-
this.platform.log.error('Websocket api error:', e.message);
|
|
47
|
+
this.platform.log.error('Websocket api response error:', e.message);
|
|
44
48
|
}
|
|
45
49
|
});
|
|
46
50
|
this.connection = connection;
|
|
47
|
-
|
|
51
|
+
});
|
|
52
|
+
client.on('disconnect', () => {
|
|
53
|
+
this.platform.log.error(`Disconnected from ${this.accessory.context.device.name}`);
|
|
54
|
+
this.connect();
|
|
48
55
|
});
|
|
49
56
|
client.on('error', error => {
|
|
50
|
-
|
|
51
|
-
this.
|
|
57
|
+
this.platform.log.error('Websocket api error:', error.message);
|
|
58
|
+
this.connect();
|
|
52
59
|
});
|
|
53
|
-
}
|
|
60
|
+
};
|
|
54
61
|
// set accessory information
|
|
55
62
|
this.accessory.getService(this.platform.Service.AccessoryInformation)
|
|
56
63
|
.setCharacteristic(this.platform.Characteristic.Manufacturer, 'Orro')
|
|
57
64
|
.setCharacteristic(this.platform.Characteristic.Model, 'Switch')
|
|
58
|
-
.setCharacteristic(this.platform.Characteristic.SerialNumber,
|
|
65
|
+
.setCharacteristic(this.platform.Characteristic.SerialNumber, accessory.context.device.serialNumber);
|
|
59
66
|
// get the LightBulb service if it exists, otherwise create a new LightBulb service
|
|
60
67
|
// you can create multiple services for each accessory
|
|
61
68
|
this.service = this.accessory.getService(this.platform.Service.Lightbulb) || this.accessory.addService(this.platform.Service.Lightbulb);
|
|
62
69
|
// set the service name, this is what is displayed as the default name on the Home app
|
|
63
70
|
// in this example we are using the name we stored in the `accessory.context` in the `discoverDevices` method.
|
|
64
|
-
this.service.setCharacteristic(this.platform.Characteristic.Name, accessory.context.device.
|
|
71
|
+
this.service.setCharacteristic(this.platform.Characteristic.Name, accessory.context.device.name);
|
|
65
72
|
// each service must implement at-minimum the "required characteristics" for the given service type
|
|
66
73
|
// see https://developers.homebridge.io/#/service/Lightbulb
|
|
67
74
|
// register handlers for the On/Off Characteristic
|
|
@@ -71,24 +78,30 @@ class Switch {
|
|
|
71
78
|
// register handlers for the Brightness Characteristic
|
|
72
79
|
this.service.getCharacteristic(this.platform.Characteristic.Brightness)
|
|
73
80
|
.onSet(this.setBrightness.bind(this)); // SET - bind to the 'setBrightness` method below
|
|
81
|
+
this.connect();
|
|
74
82
|
}
|
|
75
83
|
/**
|
|
76
84
|
* Handle "SET" requests from HomeKit
|
|
77
85
|
* These are sent when the user changes the state of an accessory, for example, turning on a Light bulb.
|
|
78
86
|
*/
|
|
79
87
|
async setOn(value) {
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
88
|
+
try {
|
|
89
|
+
const payload = JSON.stringify({
|
|
90
|
+
targetId: this.accessory.context.device.switchID,
|
|
91
|
+
clientId: 'homebridge-orro',
|
|
92
|
+
type: 'RemoteCommand',
|
|
93
|
+
timestamp: Date.now(),
|
|
94
|
+
data: {
|
|
95
|
+
command: value ? 'on' : 'off'
|
|
96
|
+
}
|
|
97
|
+
});
|
|
98
|
+
this.connection.sendUTF(payload);
|
|
99
|
+
this.state.On = value;
|
|
100
|
+
this.platform.log.info('Set Characteristic On ->', value);
|
|
101
|
+
}
|
|
102
|
+
catch (e) {
|
|
103
|
+
this.platform.log.error('Set Characteristic On Error -> ', e.message);
|
|
104
|
+
}
|
|
92
105
|
}
|
|
93
106
|
/**
|
|
94
107
|
* Handle the "GET" requests from HomeKit
|
|
@@ -105,7 +118,7 @@ class Switch {
|
|
|
105
118
|
*/
|
|
106
119
|
async getOn() {
|
|
107
120
|
const isOn = this.state.On;
|
|
108
|
-
this.platform.log.
|
|
121
|
+
this.platform.log.info('Get Characteristic On ->', isOn);
|
|
109
122
|
return isOn;
|
|
110
123
|
}
|
|
111
124
|
/**
|
|
@@ -113,19 +126,24 @@ class Switch {
|
|
|
113
126
|
* These are sent when the user changes the state of an accessory, for example, changing the Brightness
|
|
114
127
|
*/
|
|
115
128
|
async setBrightness(value) {
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
+
try {
|
|
130
|
+
const payload = JSON.stringify({
|
|
131
|
+
targetId: this.accessory.context.device.switchID,
|
|
132
|
+
clientId: 'homebridge-orro',
|
|
133
|
+
type: 'RemoteCommand',
|
|
134
|
+
timestamp: Date.now(),
|
|
135
|
+
data: {
|
|
136
|
+
command: 'dimmer_set',
|
|
137
|
+
value: value
|
|
138
|
+
}
|
|
139
|
+
});
|
|
140
|
+
this.connection.sendUTF(payload);
|
|
141
|
+
this.state.Brightness = value;
|
|
142
|
+
this.platform.log.info('Set Characteristic Brightness -> ', value);
|
|
143
|
+
}
|
|
144
|
+
catch (e) {
|
|
145
|
+
this.platform.log.error('Set Characteristic Brightness Error -> ', e.message);
|
|
146
|
+
}
|
|
129
147
|
}
|
|
130
148
|
}
|
|
131
149
|
exports.Switch = Switch;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"platformAccessory.js","sourceRoot":"","sources":["../src/platformAccessory.ts"],"names":[],"mappings":";;;AAEA,yCAAsD;AAEtD;;;;EAIE;AACF,MAAa,MAAM;
|
|
1
|
+
{"version":3,"file":"platformAccessory.js","sourceRoot":"","sources":["../src/platformAccessory.ts"],"names":[],"mappings":";;;AAEA,yCAAsD;AAEtD;;;;EAIE;AACF,MAAa,MAAM;IAcf,YACqB,QAAsB,EACtB,SAA4B;QAD5B,aAAQ,GAAR,QAAQ,CAAc;QACtB,cAAS,GAAT,SAAS,CAAmB;QAbjD;;;UAGE;QACM,UAAK,GAAG;YACZ,EAAE,EAAE,KAAK;YACT,UAAU,EAAE,GAAG;SAClB,CAAC;QAsCF,YAAO,GAAG,KAAK,IAAI,EAAE;YAEjB,MAAM,MAAM,GAAG,IAAI,kBAAe,EAAE,CAAC;YACrC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,gBAAgB,EAAE,QAAQ,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,MAAM,CAAC,SAAS,gBAAgB,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC;YACvI,MAAM,CAAC,O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F,OAAO,EAAE,YAAY;oBACrB,KAAK,EAAE,KAAK;iBACf;aACJ,CAAC,CAAC;YACH,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;YACjC,IAAI,CAAC,KAAK,CAAC,UAAU,GAAG,KAAe,CAAC;YACxC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,mCAAmC,EAAE,KAAK,CAAC,CAAC;SAEtE;QAAC,OAAM,CAAC,EAAE;YACP,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,KAAK,CAAC,yCAAyC,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC;SACjF;IACL,CAAC;CACJ;AA/JD,wBA+JC"}
|
package/dist/settings.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* This is the name of the platform that users will use to register the plugin in the Homebridge config.json
|
|
3
3
|
*/
|
|
4
|
-
export declare const PLATFORM_NAME = "Orro";
|
|
4
|
+
export declare const PLATFORM_NAME = "Homebridge Orro";
|
|
5
5
|
/**
|
|
6
6
|
* This must match the name of your plugin as defined the package.json
|
|
7
7
|
*/
|
package/dist/settings.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"settings.d.ts","sourceRoot":"","sources":["../src/settings.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,eAAO,MAAM,aAAa,
|
|
1
|
+
{"version":3,"file":"settings.d.ts","sourceRoot":"","sources":["../src/settings.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,eAAO,MAAM,aAAa,oBAAoB,CAAC;AAE/C;;GAEG;AACH,eAAO,MAAM,WAAW,oBAAoB,CAAC"}
|
package/dist/settings.js
CHANGED
|
@@ -4,7 +4,7 @@ exports.PLUGIN_NAME = exports.PLATFORM_NAME = void 0;
|
|
|
4
4
|
/**
|
|
5
5
|
* This is the name of the platform that users will use to register the plugin in the Homebridge config.json
|
|
6
6
|
*/
|
|
7
|
-
exports.PLATFORM_NAME = 'Orro';
|
|
7
|
+
exports.PLATFORM_NAME = 'Homebridge Orro';
|
|
8
8
|
/**
|
|
9
9
|
* This must match the name of your plugin as defined the package.json
|
|
10
10
|
*/
|
package/dist/settings.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"settings.js","sourceRoot":"","sources":["../src/settings.ts"],"names":[],"mappings":";;;AAAA;;GAEG;AACU,QAAA,aAAa,GAAG,
|
|
1
|
+
{"version":3,"file":"settings.js","sourceRoot":"","sources":["../src/settings.ts"],"names":[],"mappings":";;;AAAA;;GAEG;AACU,QAAA,aAAa,GAAG,iBAAiB,CAAC;AAE/C;;GAEG;AACU,QAAA,WAAW,GAAG,iBAAiB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
|
-
"displayName": "Orro",
|
|
2
|
+
"displayName": "Homebridge Orro",
|
|
3
3
|
"name": "homebridge-orro",
|
|
4
|
-
"version": "1.0.
|
|
5
|
-
"description": "
|
|
4
|
+
"version": "1.0.4",
|
|
5
|
+
"description": "Homebridge support for Orro lan switches.",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
7
|
"repository": {
|
|
8
8
|
"type": "git",
|