@fredsocial/homebridge-tplink-tapo 0.1.0
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/LICENSE +21 -0
- package/README.md +105 -0
- package/config.schema.json +347 -0
- package/lib/accessory-information.d.ts +4 -0
- package/lib/accessory-information.d.ts.map +1 -0
- package/lib/accessory-information.js +26 -0
- package/lib/accessory-information.js.map +1 -0
- package/lib/characteristics/amperes.d.ts +4 -0
- package/lib/characteristics/amperes.d.ts.map +1 -0
- package/lib/characteristics/amperes.js +15 -0
- package/lib/characteristics/amperes.js.map +1 -0
- package/lib/characteristics/default-characteristic.d.ts +3 -0
- package/lib/characteristics/default-characteristic.d.ts.map +1 -0
- package/lib/characteristics/default-characteristic.js +19 -0
- package/lib/characteristics/default-characteristic.js.map +1 -0
- package/lib/characteristics/index.d.ts +3 -0
- package/lib/characteristics/index.d.ts.map +1 -0
- package/lib/characteristics/index.js +25 -0
- package/lib/characteristics/index.js.map +1 -0
- package/lib/characteristics/kilowatt-hours.d.ts +4 -0
- package/lib/characteristics/kilowatt-hours.d.ts.map +1 -0
- package/lib/characteristics/kilowatt-hours.js +15 -0
- package/lib/characteristics/kilowatt-hours.js.map +1 -0
- package/lib/characteristics/kilowatt-volt-ampere-hour.d.ts +4 -0
- package/lib/characteristics/kilowatt-volt-ampere-hour.d.ts.map +1 -0
- package/lib/characteristics/kilowatt-volt-ampere-hour.js +16 -0
- package/lib/characteristics/kilowatt-volt-ampere-hour.js.map +1 -0
- package/lib/characteristics/types.d.ts +7 -0
- package/lib/characteristics/types.d.ts.map +1 -0
- package/lib/characteristics/types.js +4 -0
- package/lib/characteristics/types.js.map +1 -0
- package/lib/characteristics/volt-amperes.d.ts +4 -0
- package/lib/characteristics/volt-amperes.d.ts.map +1 -0
- package/lib/characteristics/volt-amperes.js +15 -0
- package/lib/characteristics/volt-amperes.js.map +1 -0
- package/lib/characteristics/volts.d.ts +4 -0
- package/lib/characteristics/volts.d.ts.map +1 -0
- package/lib/characteristics/volts.js +15 -0
- package/lib/characteristics/volts.js.map +1 -0
- package/lib/characteristics/watts.d.ts +4 -0
- package/lib/characteristics/watts.d.ts.map +1 -0
- package/lib/characteristics/watts.js +15 -0
- package/lib/characteristics/watts.js.map +1 -0
- package/lib/config.d.ts +180 -0
- package/lib/config.d.ts.map +1 -0
- package/lib/config.js +167 -0
- package/lib/config.js.map +1 -0
- package/lib/homekit-device/bulb.d.ts +41 -0
- package/lib/homekit-device/bulb.d.ts.map +1 -0
- package/lib/homekit-device/bulb.js +307 -0
- package/lib/homekit-device/bulb.js.map +1 -0
- package/lib/homekit-device/create.d.ts +11 -0
- package/lib/homekit-device/create.d.ts.map +1 -0
- package/lib/homekit-device/create.js +18 -0
- package/lib/homekit-device/create.js.map +1 -0
- package/lib/homekit-device/index.d.ts +33 -0
- package/lib/homekit-device/index.d.ts.map +1 -0
- package/lib/homekit-device/index.js +120 -0
- package/lib/homekit-device/index.js.map +1 -0
- package/lib/homekit-device/plug.d.ts +43 -0
- package/lib/homekit-device/plug.d.ts.map +1 -0
- package/lib/homekit-device/plug.js +244 -0
- package/lib/homekit-device/plug.js.map +1 -0
- package/lib/index.d.ts +4 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +10 -0
- package/lib/index.js.map +1 -0
- package/lib/platform.d.ts +59 -0
- package/lib/platform.d.ts.map +1 -0
- package/lib/platform.js +301 -0
- package/lib/platform.js.map +1 -0
- package/lib/settings.d.ts +3 -0
- package/lib/settings.d.ts.map +1 -0
- package/lib/settings.js +6 -0
- package/lib/settings.js.map +1 -0
- package/lib/tapo/custom-characteristics/currentConsumptionCharacteristic.d.ts +3 -0
- package/lib/tapo/custom-characteristics/currentConsumptionCharacteristic.d.ts.map +1 -0
- package/lib/tapo/custom-characteristics/currentConsumptionCharacteristic.js +21 -0
- package/lib/tapo/custom-characteristics/currentConsumptionCharacteristic.js.map +1 -0
- package/lib/tapo/custom-characteristics/default-characteristic.d.ts +3 -0
- package/lib/tapo/custom-characteristics/default-characteristic.d.ts.map +1 -0
- package/lib/tapo/custom-characteristics/default-characteristic.js +19 -0
- package/lib/tapo/custom-characteristics/default-characteristic.js.map +1 -0
- package/lib/tapo/custom-characteristics/index.d.ts +3 -0
- package/lib/tapo/custom-characteristics/index.d.ts.map +1 -0
- package/lib/tapo/custom-characteristics/index.js +17 -0
- package/lib/tapo/custom-characteristics/index.js.map +1 -0
- package/lib/tapo/custom-characteristics/resetConsumptionCharacteristic.d.ts +3 -0
- package/lib/tapo/custom-characteristics/resetConsumptionCharacteristic.d.ts.map +1 -0
- package/lib/tapo/custom-characteristics/resetConsumptionCharacteristic.js +20 -0
- package/lib/tapo/custom-characteristics/resetConsumptionCharacteristic.js.map +1 -0
- package/lib/tapo/custom-characteristics/totalConsumptionCharacteristic.d.ts +3 -0
- package/lib/tapo/custom-characteristics/totalConsumptionCharacteristic.d.ts.map +1 -0
- package/lib/tapo/custom-characteristics/totalConsumptionCharacteristic.js +21 -0
- package/lib/tapo/custom-characteristics/totalConsumptionCharacteristic.js.map +1 -0
- package/lib/tapo/homekit-device/types.d.ts +30 -0
- package/lib/tapo/homekit-device/types.d.ts.map +1 -0
- package/lib/tapo/homekit-device/types.js +3 -0
- package/lib/tapo/homekit-device/types.js.map +1 -0
- package/lib/tapo/platform.d.ts +14 -0
- package/lib/tapo/platform.d.ts.map +1 -0
- package/lib/tapo/platform.js +3 -0
- package/lib/tapo/platform.js.map +1 -0
- package/lib/tapo/platformL510EAccessory.d.ts +31 -0
- package/lib/tapo/platformL510EAccessory.d.ts.map +1 -0
- package/lib/tapo/platformL510EAccessory.js +146 -0
- package/lib/tapo/platformL510EAccessory.js.map +1 -0
- package/lib/tapo/platformL520EAccessory.d.ts +42 -0
- package/lib/tapo/platformL520EAccessory.d.ts.map +1 -0
- package/lib/tapo/platformL520EAccessory.js +205 -0
- package/lib/tapo/platformL520EAccessory.js.map +1 -0
- package/lib/tapo/platformL530Accessory.d.ts +84 -0
- package/lib/tapo/platformL530Accessory.d.ts.map +1 -0
- package/lib/tapo/platformL530Accessory.js +439 -0
- package/lib/tapo/platformL530Accessory.js.map +1 -0
- package/lib/tapo/platformP100Accessory.d.ts +23 -0
- package/lib/tapo/platformP100Accessory.d.ts.map +1 -0
- package/lib/tapo/platformP100Accessory.js +72 -0
- package/lib/tapo/platformP100Accessory.js.map +1 -0
- package/lib/tapo/platformP110Accessory.d.ts +39 -0
- package/lib/tapo/platformP110Accessory.d.ts.map +1 -0
- package/lib/tapo/platformP110Accessory.js +146 -0
- package/lib/tapo/platformP110Accessory.js.map +1 -0
- package/lib/tapo/platformTPLinkAccessory.d.ts +29 -0
- package/lib/tapo/platformTPLinkAccessory.d.ts.map +1 -0
- package/lib/tapo/platformTPLinkAccessory.js +132 -0
- package/lib/tapo/platformTPLinkAccessory.js.map +1 -0
- package/lib/tapo/utils/energyUsage.d.ts +4 -0
- package/lib/tapo/utils/energyUsage.d.ts.map +1 -0
- package/lib/tapo/utils/energyUsage.js +8 -0
- package/lib/tapo/utils/energyUsage.js.map +1 -0
- package/lib/tapo/utils/l510e.d.ts +17 -0
- package/lib/tapo/utils/l510e.d.ts.map +1 -0
- package/lib/tapo/utils/l510e.js +47 -0
- package/lib/tapo/utils/l510e.js.map +1 -0
- package/lib/tapo/utils/l520e.d.ts +20 -0
- package/lib/tapo/utils/l520e.d.ts.map +1 -0
- package/lib/tapo/utils/l520e.js +65 -0
- package/lib/tapo/utils/l520e.js.map +1 -0
- package/lib/tapo/utils/l530.d.ts +22 -0
- package/lib/tapo/utils/l530.d.ts.map +1 -0
- package/lib/tapo/utils/l530.js +135 -0
- package/lib/tapo/utils/l530.js.map +1 -0
- package/lib/tapo/utils/newTpLinkCipher.d.ts +22 -0
- package/lib/tapo/utils/newTpLinkCipher.d.ts.map +1 -0
- package/lib/tapo/utils/newTpLinkCipher.js +88 -0
- package/lib/tapo/utils/newTpLinkCipher.js.map +1 -0
- package/lib/tapo/utils/p100.d.ts +117 -0
- package/lib/tapo/utils/p100.d.ts.map +1 -0
- package/lib/tapo/utils/p100.js +665 -0
- package/lib/tapo/utils/p100.js.map +1 -0
- package/lib/tapo/utils/p110.d.ts +16 -0
- package/lib/tapo/utils/p110.d.ts.map +1 -0
- package/lib/tapo/utils/p110.js +68 -0
- package/lib/tapo/utils/p110.js.map +1 -0
- package/lib/tapo/utils/powerUsage.d.ts +7 -0
- package/lib/tapo/utils/powerUsage.d.ts.map +1 -0
- package/lib/tapo/utils/powerUsage.js +10 -0
- package/lib/tapo/utils/powerUsage.js.map +1 -0
- package/lib/tapo/utils/tpLinkCipher.d.ts +12 -0
- package/lib/tapo/utils/tpLinkCipher.d.ts.map +1 -0
- package/lib/tapo/utils/tpLinkCipher.js +35 -0
- package/lib/tapo/utils/tpLinkCipher.js.map +1 -0
- package/lib/tapo/utils/tplinkAccessory.d.ts +22 -0
- package/lib/tapo/utils/tplinkAccessory.d.ts.map +1 -0
- package/lib/tapo/utils/tplinkAccessory.js +3 -0
- package/lib/tapo/utils/tplinkAccessory.js.map +1 -0
- package/lib/tapo/utils/usage.d.ts +6 -0
- package/lib/tapo/utils/usage.d.ts.map +1 -0
- package/lib/tapo/utils/usage.js +10 -0
- package/lib/tapo/utils/usage.js.map +1 -0
- package/lib/utils.d.ts +29 -0
- package/lib/utils.d.ts.map +1 -0
- package/lib/utils.js +129 -0
- package/lib/utils.js.map +1 -0
- package/package.json +116 -0
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.P110Accessory = void 0;
|
|
7
|
+
const p110_1 = __importDefault(require("./utils/p110"));
|
|
8
|
+
const platformTPLinkAccessory_1 = require("./platformTPLinkAccessory");
|
|
9
|
+
/**
|
|
10
|
+
* P110 Accessory
|
|
11
|
+
* An instance of this class is created for each accessory your platform registers
|
|
12
|
+
* Each accessory may expose multiple services of different service types.
|
|
13
|
+
*/
|
|
14
|
+
class P110Accessory extends platformTPLinkAccessory_1.TPLinkPlatformAccessory {
|
|
15
|
+
log;
|
|
16
|
+
platform;
|
|
17
|
+
accessory;
|
|
18
|
+
timeout;
|
|
19
|
+
updateInterval;
|
|
20
|
+
fakeGatoHistoryService;
|
|
21
|
+
constructor(log, platform, accessory, timeout, updateInterval) {
|
|
22
|
+
super(log, platform, accessory, timeout, updateInterval);
|
|
23
|
+
this.log = log;
|
|
24
|
+
this.platform = platform;
|
|
25
|
+
this.accessory = accessory;
|
|
26
|
+
this.timeout = timeout;
|
|
27
|
+
this.updateInterval = updateInterval;
|
|
28
|
+
this.tpLinkAccessory = new p110_1.default(this.log, accessory.context.device.host, platform.config.username, platform.config.password, this.timeout);
|
|
29
|
+
this.fakeGatoHistoryService = new this.platform.FakeGatoHistoryService('energy', accessory, {
|
|
30
|
+
log: this.log,
|
|
31
|
+
size: 4096,
|
|
32
|
+
storage: 'fs',
|
|
33
|
+
});
|
|
34
|
+
this.initialise(platform, updateInterval);
|
|
35
|
+
// get the Outlet service if it exists, otherwise create a new Outlet service
|
|
36
|
+
this.service = this.accessory.getService(this.platform.Service.Outlet) || this.accessory.addService(this.platform.Service.Outlet);
|
|
37
|
+
// set the service name, this is what is displayed as the default name on the Home app
|
|
38
|
+
// we are using the name we stored in the `accessory.context` in the `discoverDevices` method.
|
|
39
|
+
this.service.setCharacteristic(this.platform.Characteristic.Name, accessory.context.device.name);
|
|
40
|
+
}
|
|
41
|
+
init(platform, updateInterval) {
|
|
42
|
+
this.tpLinkAccessory.getDeviceInfo(true).then((sysInfo) => {
|
|
43
|
+
// set accessory information
|
|
44
|
+
this.accessory.getService(this.platform.Service.AccessoryInformation)
|
|
45
|
+
.setCharacteristic(this.platform.Characteristic.Manufacturer, 'TP-Link')
|
|
46
|
+
.setCharacteristic(this.platform.Characteristic.Model, 'Tapo P110')
|
|
47
|
+
.setCharacteristic(this.platform.Characteristic.SerialNumber, sysInfo.hw_id);
|
|
48
|
+
// each service must implement at-minimum the "required characteristics" for the given service type
|
|
49
|
+
// see https://developers.homebridge.io/#/service/Outlet
|
|
50
|
+
// register handlers for the On/Off Characteristic
|
|
51
|
+
this.service.getCharacteristic(this.platform.Characteristic.On)
|
|
52
|
+
.on('set', this.setOn.bind(this)) // SET - bind to the `setOn` method below
|
|
53
|
+
.on('get', this.getOn.bind(this)); // GET - bind to the `getOn` method below
|
|
54
|
+
this.service.addOptionalCharacteristic(this.platform.customCharacteristics.CurrentConsumptionCharacteristic);
|
|
55
|
+
this.service.getCharacteristic(this.platform.customCharacteristics.CurrentConsumptionCharacteristic)
|
|
56
|
+
.on('get', this.getCurrentConsumption.bind(this));
|
|
57
|
+
this.service.addOptionalCharacteristic(this.platform.customCharacteristics.TotalConsumptionCharacteristic);
|
|
58
|
+
this.service.getCharacteristic(this.platform.customCharacteristics.TotalConsumptionCharacteristic)
|
|
59
|
+
.on('get', this.getTotalConsumption.bind(this));
|
|
60
|
+
this.updateConsumption();
|
|
61
|
+
const interval = updateInterval ? updateInterval * 1000 : 10000;
|
|
62
|
+
setTimeout(() => {
|
|
63
|
+
this.updateState(interval);
|
|
64
|
+
}, interval);
|
|
65
|
+
}).catch(() => {
|
|
66
|
+
this.setNoResponse();
|
|
67
|
+
this.log.error('Get Device Info failed');
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
updateConsumption() {
|
|
71
|
+
this.log.debug('updateConsumption called');
|
|
72
|
+
this.tpLinkAccessory.getEnergyUsage().then((response) => {
|
|
73
|
+
this.log.debug('Get Characteristic Power consumption ->', JSON.stringify(response));
|
|
74
|
+
if (this.fakeGatoHistoryService && response && response.current_power) {
|
|
75
|
+
this.platform.log.debug('Get Characteristic Power consumption ->', response.current_power);
|
|
76
|
+
this.service.updateCharacteristic(this.platform.customCharacteristics.CurrentConsumptionCharacteristic, response.current_power / 1000);
|
|
77
|
+
this.fakeGatoHistoryService.addEntry({
|
|
78
|
+
time: new Date().getTime() / 1000,
|
|
79
|
+
power: this.tpLinkAccessory.getPowerConsumption().current,
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
}).catch((error) => {
|
|
83
|
+
this.log.debug('Failed to get energy usage: ' + error);
|
|
84
|
+
});
|
|
85
|
+
setTimeout(() => {
|
|
86
|
+
this.updateConsumption();
|
|
87
|
+
}, 600000);
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Handle the "GET" requests from HomeKit
|
|
91
|
+
* These are sent when HomeKit wants to know the current state of the accessory.
|
|
92
|
+
*
|
|
93
|
+
*/
|
|
94
|
+
getCurrentConsumption(callback) {
|
|
95
|
+
const consumption = this.tpLinkAccessory.getPowerConsumption();
|
|
96
|
+
// you must call the callback function
|
|
97
|
+
// the first argument should be null if there were no errors
|
|
98
|
+
// the second argument should be the value to return
|
|
99
|
+
// you must call the callback function
|
|
100
|
+
if (consumption) {
|
|
101
|
+
callback(null, consumption.current);
|
|
102
|
+
}
|
|
103
|
+
else {
|
|
104
|
+
callback(null, 0);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Handle the "GET" requests from HomeKit
|
|
109
|
+
* These are sent when HomeKit wants to know the current state of the accessory.
|
|
110
|
+
*
|
|
111
|
+
*/
|
|
112
|
+
getTotalConsumption(callback) {
|
|
113
|
+
const consumption = this.tpLinkAccessory.getPowerConsumption();
|
|
114
|
+
// you must call the callback function
|
|
115
|
+
// the first argument should be null if there were no errors
|
|
116
|
+
// the second argument should be the value to return
|
|
117
|
+
// you must call the callback function
|
|
118
|
+
if (consumption) {
|
|
119
|
+
callback(null, consumption.total);
|
|
120
|
+
}
|
|
121
|
+
else {
|
|
122
|
+
callback(null, 0);
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Handle the "SET" requests from HomeKit
|
|
127
|
+
*
|
|
128
|
+
*/
|
|
129
|
+
resetConsumption(value, callback) {
|
|
130
|
+
const now = Math.round(new Date().valueOf() / 1000);
|
|
131
|
+
const epoch = Math.round(new Date('2001-01-01T00:00:00Z').valueOf() / 1000);
|
|
132
|
+
this.service.updateCharacteristic(this.platform.customCharacteristics.ResetConsumptionCharacteristic, now - epoch);
|
|
133
|
+
this.service.updateCharacteristic(this.platform.customCharacteristics.TotalConsumptionCharacteristic, 0);
|
|
134
|
+
// you must call the callback function
|
|
135
|
+
// the first argument should be null if there were no errors
|
|
136
|
+
// the second argument should be the value to return
|
|
137
|
+
// you must call the callback function
|
|
138
|
+
callback(null);
|
|
139
|
+
}
|
|
140
|
+
updateState(interval) {
|
|
141
|
+
this.updateConsumption();
|
|
142
|
+
super.updateState(interval);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
exports.P110Accessory = P110Accessory;
|
|
146
|
+
//# sourceMappingURL=platformP110Accessory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"platformP110Accessory.js","sourceRoot":"","sources":["../../src/tapo/platformP110Accessory.ts"],"names":[],"mappings":";;;;;;AAGA,wDAAgC;AAChC,uEAAoE;AAEpE;;;;GAIG;AACH,MAAa,aAAc,SAAQ,iDAA6B;IAI5C;IACG;IACA;IACA;IACA;IAPJ,sBAAsB,CAAE;IAEzC,YACkB,GAAW,EACR,QAAsB,EACtB,SAA4B,EAC5B,OAAe,EACf,cAAuB;QAE1C,KAAK,CAAC,GAAG,EAAE,QAAQ,EAAE,SAAS,EAAE,OAAO,EAAE,cAAc,CAAC,CAAC;QANzC,QAAG,GAAH,GAAG,CAAQ;QACR,aAAQ,GAAR,QAAQ,CAAc;QACtB,cAAS,GAAT,SAAS,CAAmB;QAC5B,YAAO,GAAP,OAAO,CAAQ;QACf,mBAAc,GAAd,cAAc,CAAS;QAI1C,IAAI,CAAC,eAAe,GAAG,IAAI,cAAI,CAAC,IAAI,CAAC,GAAG,EAAE,SAAS,CAAC,OAAO,CAAC,MAAM,CAA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AI,CAAC,OAAO,CAAC,oBAAoB,CAAC,IAAI,CAAC,QAAQ,CAAC,qBAAqB,CAAC,8BAA8B,EAAE,CAAC,CAAC,CAAC;QACzG,sCAAsC;QACtC,4DAA4D;QAC5D,oDAAoD;QACpD,sCAAsC;QACtC,QAAQ,CAAC,IAAI,CAAC,CAAC;IACjB,CAAC;IAES,WAAW,CAAC,QAAe;QACnC,IAAI,CAAC,iBAAiB,EAAE,CAAC;QACzB,KAAK,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC;IAC9B,CAAC;CACF;AApJD,sCAoJC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { CharacteristicGetCallback, CharacteristicSetCallback, CharacteristicValue, Logger, PlatformAccessory, Service } from 'homebridge';
|
|
2
|
+
import type { TapoPlatform } from './platform';
|
|
3
|
+
import { TpLinkAccessory } from './utils/tplinkAccessory';
|
|
4
|
+
export declare abstract class TPLinkPlatformAccessory<T extends TpLinkAccessory> {
|
|
5
|
+
readonly log: Logger;
|
|
6
|
+
protected readonly platform: TapoPlatform;
|
|
7
|
+
protected readonly accessory: PlatformAccessory;
|
|
8
|
+
protected readonly timeout: number;
|
|
9
|
+
protected readonly updateInterval?: number | undefined;
|
|
10
|
+
protected tpLinkAccessory: T;
|
|
11
|
+
protected service: Service;
|
|
12
|
+
constructor(log: Logger, platform: TapoPlatform, accessory: PlatformAccessory, timeout: number, updateInterval?: number | undefined);
|
|
13
|
+
protected initialise(platform: TapoPlatform, updateInterval?: number): void;
|
|
14
|
+
protected abstract init(platform: TapoPlatform, updateInterval?: number): void;
|
|
15
|
+
/**
|
|
16
|
+
* Handle "SET" requests from HomeKit
|
|
17
|
+
* These are sent when the user changes the state of an accessory.
|
|
18
|
+
*/
|
|
19
|
+
setOn(value: CharacteristicValue, callback: CharacteristicSetCallback): void;
|
|
20
|
+
/**
|
|
21
|
+
* Handle the "GET" requests from HomeKit
|
|
22
|
+
* These are sent when HomeKit wants to know the current state of the accessory.
|
|
23
|
+
*
|
|
24
|
+
*/
|
|
25
|
+
getOn(callback: CharacteristicGetCallback): void;
|
|
26
|
+
protected updateState(interval: number): void;
|
|
27
|
+
protected setNoResponse(): void;
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=platformTPLinkAccessory.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"platformTPLinkAccessory.d.ts","sourceRoot":"","sources":["../../src/tapo/platformTPLinkAccessory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,yBAAyB,EAAE,mBAAmB,EAAE,MAAM,EAAE,iBAAiB,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAC3I,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC/C,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAE1D,8BAAsB,uBAAuB,CAAE,CAAC,SAAS,eAAe;aAMpD,GAAG,EAAE,MAAM;IAC3B,SAAS,CAAC,QAAQ,CAAC,QAAQ,EAAE,YAAY;IACzC,SAAS,CAAC,QAAQ,CAAC,SAAS,EAAE,iBAAiB;IAC/C,SAAS,CAAC,QAAQ,CAAC,OAAO,EAAE,MAAM;IAClC,SAAS,CAAC,QAAQ,CAAC,cAAc,CAAC;IARpC,SAAS,CAAC,eAAe,EAAG,CAAC,CAAC;IAC9B,SAAS,CAAC,OAAO,EAAG,OAAO,CAAC;gBAGV,GAAG,EAAE,MAAM,EACR,QAAQ,EAAE,YAAY,EACtB,SAAS,EAAE,iBAAiB,EAC5B,OAAO,EAAE,MAAM,EACf,cAAc,CAAC,oBAAQ;IAK5C,SAAS,CAAC,UAAU,CAAC,QAAQ,EAAE,YAAY,EAAE,cAAc,CAAC,EAAE,MAAM,GAAE,IAAI;IA0B1E,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,QAAQ,EAAE,YAAY,EAAE,cAAc,CAAC,EAAE,MAAM,GAAE,IAAI;IAE7E;;;OAGG;IACH,KAAK,CAAC,KAAK,EAAE,mBAAmB,EAAE,QAAQ,EAAE,yBAAyB;IAgBrE;;;;OAIG;IACH,KAAK,CAAC,QAAQ,EAAE,yBAAyB;IA2BzC,SAAS,CAAC,WAAW,CAAC,QAAQ,EAAC,MAAM;IAiCrC,SAAS,CAAC,aAAa,IAAG,IAAI;CAG/B"}
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TPLinkPlatformAccessory = void 0;
|
|
4
|
+
class TPLinkPlatformAccessory {
|
|
5
|
+
log;
|
|
6
|
+
platform;
|
|
7
|
+
accessory;
|
|
8
|
+
timeout;
|
|
9
|
+
updateInterval;
|
|
10
|
+
tpLinkAccessory;
|
|
11
|
+
service;
|
|
12
|
+
constructor(log, platform, accessory, timeout, updateInterval) {
|
|
13
|
+
this.log = log;
|
|
14
|
+
this.platform = platform;
|
|
15
|
+
this.accessory = accessory;
|
|
16
|
+
this.timeout = timeout;
|
|
17
|
+
this.updateInterval = updateInterval;
|
|
18
|
+
this.log.debug('Start adding accessory: ' + accessory.context.device.host);
|
|
19
|
+
}
|
|
20
|
+
initialise(platform, updateInterval) {
|
|
21
|
+
this.tpLinkAccessory.handshake().then(() => {
|
|
22
|
+
if (this.tpLinkAccessory.is_klap) {
|
|
23
|
+
setTimeout(() => {
|
|
24
|
+
this.tpLinkAccessory.handshake_new().then(() => {
|
|
25
|
+
this.init(platform, updateInterval);
|
|
26
|
+
}).catch(() => {
|
|
27
|
+
this.setNoResponse();
|
|
28
|
+
this.log.error('KLAP Handshake failed');
|
|
29
|
+
this.tpLinkAccessory.is_klap = false;
|
|
30
|
+
});
|
|
31
|
+
}, 100);
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
this.tpLinkAccessory.login().then(() => {
|
|
35
|
+
this.init(platform, updateInterval);
|
|
36
|
+
}).catch(() => {
|
|
37
|
+
this.setNoResponse();
|
|
38
|
+
this.log.error('Login failed');
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
}).catch(() => {
|
|
42
|
+
this.setNoResponse();
|
|
43
|
+
this.log.error('Handshake failed');
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Handle "SET" requests from HomeKit
|
|
48
|
+
* These are sent when the user changes the state of an accessory.
|
|
49
|
+
*/
|
|
50
|
+
setOn(value, callback) {
|
|
51
|
+
this.tpLinkAccessory.setPowerState(value).then((result) => {
|
|
52
|
+
if (result) {
|
|
53
|
+
this.platform.log.debug('Set Characteristic On ->', value);
|
|
54
|
+
this.tpLinkAccessory.getSysInfo().device_on = value;
|
|
55
|
+
// you must call the callback function
|
|
56
|
+
callback(null);
|
|
57
|
+
}
|
|
58
|
+
else {
|
|
59
|
+
callback(new Error('unreachable'), false);
|
|
60
|
+
}
|
|
61
|
+
}).catch((error) => {
|
|
62
|
+
this.log.error('Failed to set power state: ' + error);
|
|
63
|
+
callback(new Error('unreachable'), false);
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Handle the "GET" requests from HomeKit
|
|
68
|
+
* These are sent when HomeKit wants to know the current state of the accessory.
|
|
69
|
+
*
|
|
70
|
+
*/
|
|
71
|
+
getOn(callback) {
|
|
72
|
+
// implement your own code to check if the device is on
|
|
73
|
+
this.tpLinkAccessory.getDeviceInfo().then((response) => {
|
|
74
|
+
if (response) {
|
|
75
|
+
const isOn = response.device_on;
|
|
76
|
+
this.platform.log.debug('Get Characteristic On ->', isOn);
|
|
77
|
+
// you must call the callback function
|
|
78
|
+
// the first argument should be null if there were no errors
|
|
79
|
+
// the second argument should be the value to return
|
|
80
|
+
// you must call the callback function
|
|
81
|
+
if (isOn !== undefined) {
|
|
82
|
+
callback(null, isOn);
|
|
83
|
+
}
|
|
84
|
+
else {
|
|
85
|
+
callback(new Error('unreachable'), isOn);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
else {
|
|
89
|
+
callback(new Error('unreachable'), false);
|
|
90
|
+
}
|
|
91
|
+
}).catch((error) => {
|
|
92
|
+
this.log.debug('error: ' + error);
|
|
93
|
+
callback(new Error('unreachable'), 0);
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
updateState(interval) {
|
|
97
|
+
this.platform.log.debug('Updating state');
|
|
98
|
+
this.tpLinkAccessory.getDeviceInfo(true).then((response) => {
|
|
99
|
+
if (response) {
|
|
100
|
+
const isOn = response.device_on;
|
|
101
|
+
this.platform.log.debug('Get Characteristic On ->', isOn);
|
|
102
|
+
if (isOn !== undefined) {
|
|
103
|
+
this.service.updateCharacteristic(this.platform.Characteristic.On, isOn);
|
|
104
|
+
}
|
|
105
|
+
else {
|
|
106
|
+
this.platform.log.debug('On is undefined -> set no response');
|
|
107
|
+
this.setNoResponse();
|
|
108
|
+
}
|
|
109
|
+
setTimeout(() => {
|
|
110
|
+
this.updateState(interval);
|
|
111
|
+
}, interval);
|
|
112
|
+
}
|
|
113
|
+
else {
|
|
114
|
+
this.setNoResponse();
|
|
115
|
+
interval += 300000;
|
|
116
|
+
setTimeout(() => {
|
|
117
|
+
this.updateState(interval);
|
|
118
|
+
}, interval);
|
|
119
|
+
}
|
|
120
|
+
}).catch(() => {
|
|
121
|
+
this.setNoResponse();
|
|
122
|
+
setTimeout(() => {
|
|
123
|
+
this.updateState(interval + 300000);
|
|
124
|
+
}, interval);
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
setNoResponse() {
|
|
128
|
+
this.service.updateCharacteristic(this.platform.Characteristic.On, new Error('unreachable'));
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
exports.TPLinkPlatformAccessory = TPLinkPlatformAccessory;
|
|
132
|
+
//# sourceMappingURL=platformTPLinkAccessory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"platformTPLinkAccessory.js","sourceRoot":"","sources":["../../src/tapo/platformTPLinkAccessory.ts"],"names":[],"mapp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.js","sourceRoot":"","sources":["../../../src/tapo/utils/energyUsage.ts"],"names":[],"mappings":";;;AAAA,MAAa,WAAW;IACtB,aAAa,CAAU;CACxB;AAFD,kCAEC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Logger } from 'homebridge';
|
|
2
|
+
import { LightSysinfo } from '../homekit-device/types';
|
|
3
|
+
import P100 from './p100';
|
|
4
|
+
export default class L510E extends P100 {
|
|
5
|
+
readonly log: Logger;
|
|
6
|
+
readonly ipAddress: string;
|
|
7
|
+
readonly email: string;
|
|
8
|
+
readonly password: string;
|
|
9
|
+
readonly timeout: number;
|
|
10
|
+
private _lightSysInfo;
|
|
11
|
+
constructor(log: Logger, ipAddress: string, email: string, password: string, timeout: number);
|
|
12
|
+
getDeviceInfo(force?: boolean): Promise<LightSysinfo>;
|
|
13
|
+
setBrightness(brightness: number): Promise<boolean>;
|
|
14
|
+
protected setSysInfo(sysInfo: LightSysinfo): void;
|
|
15
|
+
getSysInfo(): LightSysinfo;
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=l510e.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"l510e.d.ts","sourceRoot":"","sources":["../../../src/tapo/utils/l510e.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AACpC,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,IAAI,MAAM,QAAQ,CAAC;AAE1B,MAAM,CAAC,OAAO,OAAO,KAAM,SAAQ,IAAI;aAKf,GAAG,EAAE,MAAM;aACX,SAAS,EAAE,MAAM;aACjB,KAAK,EAAE,MAAM;aACb,QAAQ,EAAE,MAAM;aAChB,OAAO,EAAE,MAAM;IAPrC,OAAO,CAAC,aAAa,CAAe;gBAGd,GAAG,EAAE,MAAM,EACX,SAAS,EAAE,MAAM,EACjB,KAAK,EAAE,MAAM,EACb,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,MAAM;IAM/B,aAAa,CAAC,KAAK,CAAC,EAAC,OAAO,GAAG,OAAO,CAAC,YAAY,CAAC;IAMpD,aAAa,CAAC,UAAU,EAAC,MAAM,GAAE,OAAO,CAAC,OAAO,CAAC;IAYvD,SAAS,CAAC,UAAU,CAAC,OAAO,EAAC,YAAY;IAKlC,UAAU,IAAG,YAAY;CAGjC"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const p100_1 = __importDefault(require("./p100"));
|
|
7
|
+
class L510E extends p100_1.default {
|
|
8
|
+
log;
|
|
9
|
+
ipAddress;
|
|
10
|
+
email;
|
|
11
|
+
password;
|
|
12
|
+
timeout;
|
|
13
|
+
_lightSysInfo;
|
|
14
|
+
constructor(log, ipAddress, email, password, timeout) {
|
|
15
|
+
super(log, ipAddress, email, password, timeout);
|
|
16
|
+
this.log = log;
|
|
17
|
+
this.ipAddress = ipAddress;
|
|
18
|
+
this.email = email;
|
|
19
|
+
this.password = password;
|
|
20
|
+
this.timeout = timeout;
|
|
21
|
+
this.log.debug('Constructing L510E on host: ' + ipAddress);
|
|
22
|
+
}
|
|
23
|
+
async getDeviceInfo(force) {
|
|
24
|
+
return super.getDeviceInfo(force).then(() => {
|
|
25
|
+
return this.getSysInfo();
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
async setBrightness(brightness) {
|
|
29
|
+
const payload = '{' +
|
|
30
|
+
'"method": "set_device_info",' +
|
|
31
|
+
'"params": {' +
|
|
32
|
+
'"brightness": ' + brightness +
|
|
33
|
+
'},' +
|
|
34
|
+
'"requestTimeMils": ' + Math.round(Date.now() * 1000) + '' +
|
|
35
|
+
'};';
|
|
36
|
+
return this.sendRequest(payload);
|
|
37
|
+
}
|
|
38
|
+
setSysInfo(sysInfo) {
|
|
39
|
+
this._lightSysInfo = sysInfo;
|
|
40
|
+
this._lightSysInfo.last_update = Date.now();
|
|
41
|
+
}
|
|
42
|
+
getSysInfo() {
|
|
43
|
+
return this._lightSysInfo;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
exports.default = L510E;
|
|
47
|
+
//# sourceMappingURL=l510e.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"l510e.js","sourceRoot":"","sources":["../../../src/tapo/utils/l510e.ts"],"names":[],"mappings":";;;;;AAEA,kDAA0B;AAE1B,MAAqB,KAAM,SAAQ,cAAI;IAKf;IACA;IACA;IACA;IACA;IAPd,aAAa,CAAe;IAEpC,YACsB,GAAW,EACX,SAAiB,EACjB,KAAa,EACb,QAAgB,EAChB,OAAe;QAEnC,KAAK,CAAC,GAAG,EAAE,SAAS,EAAE,KAAK,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAC;QAN5B,QAAG,GAAH,GAAG,CAAQ;QACX,cAAS,GAAT,SAAS,CAAQ;QACjB,UAAK,GAAL,KAAK,CAAQ;QACb,aAAQ,GAAR,QAAQ,CAAQ;QAChB,YAAO,GAAP,OAAO,CAAQ;QAGnC,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,8BAA8B,GAAG,SAAS,CAAC,CAAC;IAC7D,CAAC;IAED,KAAK,CAAC,aAAa,CAAC,KAAc;QAChC,OAAO,KAAK,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,GAAG,EAAE;YAC1C,OAAO,IAAI,CAAC,UAAU,EAAE,CAAC;QAC3B,CAAC,CAAC,CAAC;IACL,CAAC;IAED,KAAK,CAAC,aAAa,CAAC,UAAiB;QACnC,MAAM,OAAO,GAAG,GAAG;YACT,8BAA8B;YAC9B,aAAa;YACT,gBAAgB,GAAG,UAAU;YAC7B,IAAI;YACJ,qBAAqB,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,GAAG,EAAE;YAC1D,IAAI,CAAC;QAEnB,OAAO,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;IACnC,CAAC;IAES,UAAU,CAAC,OAAoB;QACvC,IAAI,CAAC,aAAa,GAAG,OAAO,CAAC;QAC7B,IAAI,CAAC,aAAa,CAAC,WAAW,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;IAC9C,CAAC;IAEM,UAAU;QACf,OAAO,IAAI,CAAC,aAAa,CAAC;IAC5B,CAAC;CACF;AAzCD,wBAyCC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Logger } from 'homebridge';
|
|
2
|
+
import { ColorTempLightSysinfo } from '../homekit-device/types';
|
|
3
|
+
import L510E from './l510e';
|
|
4
|
+
export default class L520E extends L510E {
|
|
5
|
+
readonly log: Logger;
|
|
6
|
+
readonly ipAddress: string;
|
|
7
|
+
readonly email: string;
|
|
8
|
+
readonly password: string;
|
|
9
|
+
readonly timeout: number;
|
|
10
|
+
private _colorTempSysInfo;
|
|
11
|
+
constructor(log: Logger, ipAddress: string, email: string, password: string, timeout: number);
|
|
12
|
+
getDeviceInfo(force?: boolean): Promise<ColorTempLightSysinfo>;
|
|
13
|
+
setColorTemp(color_temp: number): Promise<boolean>;
|
|
14
|
+
private transformColorTemp;
|
|
15
|
+
getColorTemp(): Promise<number>;
|
|
16
|
+
calculateColorTemp(tapo_color_temp: number): number;
|
|
17
|
+
protected setSysInfo(sysInfo: ColorTempLightSysinfo): void;
|
|
18
|
+
getSysInfo(): ColorTempLightSysinfo;
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=l520e.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"l520e.d.ts","sourceRoot":"","sources":["../../../src/tapo/utils/l520e.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AACpC,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,KAAK,MAAM,SAAS,CAAC;AAE5B,MAAM,CAAC,OAAO,OAAO,KAAM,SAAQ,KAAK;aAKhB,GAAG,EAAE,MAAM;aACX,SAAS,EAAE,MAAM;aACjB,KAAK,EAAE,MAAM;aACb,QAAQ,EAAE,MAAM;aAChB,OAAO,EAAE,MAAM;IAPrC,OAAO,CAAC,iBAAiB,CAAwB;gBAG3B,GAAG,EAAE,MAAM,EACX,SAAS,EAAE,MAAM,EACjB,KAAK,EAAE,MAAM,EACb,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,MAAM;IAM/B,aAAa,CAAC,KAAK,CAAC,EAAC,OAAO,GAAG,OAAO,CAAC,qBAAqB,CAAC;IAM7D,YAAY,CAAC,UAAU,EAAC,MAAM,GAAE,OAAO,CAAC,OAAO,CAAC;IAoBtD,OAAO,CAAC,kBAAkB;IAIpB,YAAY,IAAI,OAAO,CAAC,MAAM,CAAC;IAMrC,kBAAkB,CAAC,eAAe,EAAC,MAAM,GAAE,MAAM;IAKjD,SAAS,CAAC,UAAU,CAAC,OAAO,EAAC,qBAAqB;IAK3C,UAAU,IAAG,qBAAqB;CAG1C"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const l510e_1 = __importDefault(require("./l510e"));
|
|
7
|
+
class L520E extends l510e_1.default {
|
|
8
|
+
log;
|
|
9
|
+
ipAddress;
|
|
10
|
+
email;
|
|
11
|
+
password;
|
|
12
|
+
timeout;
|
|
13
|
+
_colorTempSysInfo;
|
|
14
|
+
constructor(log, ipAddress, email, password, timeout) {
|
|
15
|
+
super(log, ipAddress, email, password, timeout);
|
|
16
|
+
this.log = log;
|
|
17
|
+
this.ipAddress = ipAddress;
|
|
18
|
+
this.email = email;
|
|
19
|
+
this.password = password;
|
|
20
|
+
this.timeout = timeout;
|
|
21
|
+
this.log.debug('Constructing L510E on host: ' + ipAddress);
|
|
22
|
+
}
|
|
23
|
+
async getDeviceInfo(force) {
|
|
24
|
+
return super.getDeviceInfo(force).then(() => {
|
|
25
|
+
return this.getSysInfo();
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
async setColorTemp(color_temp) {
|
|
29
|
+
const transformedColorTemp = this.transformColorTemp(color_temp);
|
|
30
|
+
this.log.debug('Color Temp Tapo :' + transformedColorTemp);
|
|
31
|
+
const roundedValue = transformedColorTemp > 6500 ? 6500 : transformedColorTemp < 2500 ?
|
|
32
|
+
2500 : transformedColorTemp;
|
|
33
|
+
const payload = '{' +
|
|
34
|
+
'"method": "set_device_info",' +
|
|
35
|
+
'"params": {' +
|
|
36
|
+
'"hue": 0,' +
|
|
37
|
+
'"saturation": 0,' +
|
|
38
|
+
'"color_temp": ' + roundedValue +
|
|
39
|
+
'},' +
|
|
40
|
+
'"requestTimeMils": ' + Math.round(Date.now() * 1000) + '' +
|
|
41
|
+
'};';
|
|
42
|
+
return this.sendRequest(payload);
|
|
43
|
+
}
|
|
44
|
+
transformColorTemp(value) {
|
|
45
|
+
return Math.floor(1000000 / value);
|
|
46
|
+
}
|
|
47
|
+
async getColorTemp() {
|
|
48
|
+
return super.getDeviceInfo().then(() => {
|
|
49
|
+
return this.calculateColorTemp(this.getSysInfo().color_temp);
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
calculateColorTemp(tapo_color_temp) {
|
|
53
|
+
const newValue = this.transformColorTemp(tapo_color_temp);
|
|
54
|
+
return newValue > 400 ? 400 : (newValue < 154 ? 154 : newValue);
|
|
55
|
+
}
|
|
56
|
+
setSysInfo(sysInfo) {
|
|
57
|
+
this._colorTempSysInfo = sysInfo;
|
|
58
|
+
this._colorTempSysInfo.last_update = Date.now();
|
|
59
|
+
}
|
|
60
|
+
getSysInfo() {
|
|
61
|
+
return this._colorTempSysInfo;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
exports.default = L520E;
|
|
65
|
+
//# sourceMappingURL=l520e.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"l520e.js","sourceRoot":"","sources":["../../../src/tapo/utils/l520e.ts"],"names":[],"mappings":";;;;;AAEA,oDAA4B;AAE5B,MAAqB,KAAM,SAAQ,eAAK;IAKhB;IACA;IACA;IACA;IACA;IAPd,iBAAiB,CAAwB;IAEjD,YACsB,GAAW,EACX,SAAiB,EACjB,KAAa,EACb,QAAgB,EAChB,OAAe;QAEnC,KAAK,CAAC,GAAG,EAAE,SAAS,EAAE,KAAK,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAC;QAN5B,QAAG,GAAH,GAAG,CAAQ;QACX,cAAS,GAAT,SAAS,CAAQ;QACjB,UAAK,GAAL,KAAK,CAAQ;QACb,aAAQ,GAAR,QAAQ,CAAQ;QAChB,YAAO,GAAP,OAAO,CAAQ;QAGnC,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,8BAA8B,GAAG,SAAS,CAAC,CAAC;IAC7D,CAAC;IAED,KAAK,CAAC,aAAa,CAAC,KAAc;QAChC,OAAO,KAAK,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,GAAG,EAAE;YAC1C,OAAO,IAAI,CAAC,UAAU,EAAE,CAAC;QAC3B,CAAC,CAAC,CAAC;IACL,CAAC;IAED,KAAK,CAAC,YAAY,CAAC,UAAiB;QAClC,MAAM,oBAAoB,GAAG,IAAI,CAAC,kBAAkB,CAAC,UAAU,CAAC,CAAC;QACjE,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,mBAAmB,GAAG,oBAAoB,CAAC,CAAC;QAE3D,MAAM,YAAY,GAAG,oBAAoB,GAAG,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,oBAAoB,GAAG,IAAI,CAAC,CAAC;Y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
|
2
|
+
import { ColorLightSysinfo, ConsumptionInfo } from '../homekit-device/types';
|
|
3
|
+
import L520E from './l520e';
|
|
4
|
+
import { PowerUsage } from './powerUsage';
|
|
5
|
+
export default class L530 extends L520E {
|
|
6
|
+
readonly log: Logger;
|
|
7
|
+
readonly ipAddress: string;
|
|
8
|
+
readonly email: string;
|
|
9
|
+
readonly password: string;
|
|
10
|
+
readonly timeout: number;
|
|
11
|
+
private _colorLightSysInfo;
|
|
12
|
+
private _consumption;
|
|
13
|
+
constructor(log: Logger, ipAddress: string, email: string, password: string, timeout: number);
|
|
14
|
+
getDeviceInfo(force?: boolean): Promise<ColorLightSysinfo>;
|
|
15
|
+
setColor(hue: number, saturation: number): Promise<boolean>;
|
|
16
|
+
protected setSysInfo(sysInfo: ColorLightSysinfo): void;
|
|
17
|
+
getSysInfo(): ColorLightSysinfo;
|
|
18
|
+
getEnergyUsage(): Promise<PowerUsage>;
|
|
19
|
+
getPowerConsumption(): ConsumptionInfo;
|
|
20
|
+
private toHours;
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=l530.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"l530.d.ts","sourceRoot":"","sources":["../../../src/tapo/utils/l530.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AACpC,OAAO,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC7E,OAAO,KAAK,MAAM,SAAS,CAAC;AAC5B,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C,MAAM,CAAC,OAAO,OAAO,IAAK,SAAQ,KAAK;aAMf,GAAG,EAAE,MAAM;aACX,SAAS,EAAE,MAAM;aACjB,KAAK,EAAE,MAAM;aACb,QAAQ,EAAE,MAAM;aAChB,OAAO,EAAE,MAAM;IARrC,OAAO,CAAC,kBAAkB,CAAoB;IAC9C,OAAO,CAAC,YAAY,CAAkB;gBAGhB,GAAG,EAAE,MAAM,EACX,SAAS,EAAE,MAAM,EACjB,KAAK,EAAE,MAAM,EACb,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,MAAM;IAU/B,aAAa,CAAC,KAAK,CAAC,EAAC,OAAO,GAAG,OAAO,CAAC,iBAAiB,CAAC;IAMzD,QAAQ,CAAC,GAAG,EAAC,MAAM,EAAE,UAAU,EAAC,MAAM,GAAE,OAAO,CAAC,OAAO,CAAC;IAqB9D,SAAS,CAAC,UAAU,CAAC,OAAO,EAAC,iBAAiB;IAKvC,UAAU,IAAG,iBAAiB;IAI/B,cAAc,IAAG,OAAO,CAAC,UAAU,CAAC;IAiEnC,mBAAmB,IAAG,eAAe;IAU5C,OAAO,CAAC,OAAO;CAGhB"}
|