homebridge-gree-ac 1.0.1 → 2.0.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/CHANGELOG.md +19 -0
- package/LICENSE +176 -21
- package/README.md +180 -42
- package/config.schema.json +277 -0
- package/dist/commands.d.ts +121 -0
- package/dist/commands.d.ts.map +1 -0
- package/dist/commands.js +123 -0
- package/dist/commands.js.map +1 -0
- package/dist/crypto.d.ts +6 -0
- package/dist/crypto.d.ts.map +1 -0
- package/dist/crypto.js +19 -0
- package/dist/crypto.js.map +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +7 -0
- package/dist/index.js.map +1 -0
- package/dist/platform.d.ts +35 -0
- package/dist/platform.d.ts.map +1 -0
- package/dist/platform.js +203 -0
- package/dist/platform.js.map +1 -0
- package/dist/platformAccessory.d.ts +89 -0
- package/dist/platformAccessory.d.ts.map +1 -0
- package/dist/platformAccessory.js +867 -0
- package/dist/platformAccessory.js.map +1 -0
- package/dist/settings.d.ts +51 -0
- package/dist/settings.d.ts.map +1 -0
- package/dist/settings.js +50 -0
- package/dist/settings.js.map +1 -0
- package/dist/tsAccessory.d.ts +36 -0
- package/dist/tsAccessory.d.ts.map +1 -0
- package/dist/tsAccessory.js +65 -0
- package/dist/tsAccessory.js.map +1 -0
- package/greedevice.jpg +0 -0
- package/greemac.jpg +0 -0
- package/package.json +51 -23
- package/uiconfig.jpg +0 -0
- package/app/commandEnums.js +0 -137
- package/app/deviceFactory.js +0 -286
- package/app/encryptionService.js +0 -39
- package/example.config.json +0 -20
- package/index.js +0 -339
package/dist/platform.js
ADDED
|
@@ -0,0 +1,203 @@
|
|
|
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.GreeACPlatform = void 0;
|
|
7
|
+
const dgram_1 = __importDefault(require("dgram"));
|
|
8
|
+
const crypto_1 = __importDefault(require("./crypto"));
|
|
9
|
+
const settings_1 = require("./settings");
|
|
10
|
+
const platformAccessory_1 = require("./platformAccessory");
|
|
11
|
+
const tsAccessory_1 = require("./tsAccessory");
|
|
12
|
+
/**
|
|
13
|
+
* HomebridgePlatform
|
|
14
|
+
* This class is the main constructor for your plugin, this is where you should
|
|
15
|
+
* parse the user config and discover/register accessories with Homebridge.
|
|
16
|
+
*/
|
|
17
|
+
class GreeACPlatform {
|
|
18
|
+
constructor(log, config, api) {
|
|
19
|
+
this.log = log;
|
|
20
|
+
this.config = config;
|
|
21
|
+
this.api = api;
|
|
22
|
+
this.Service = this.api.hap.Service;
|
|
23
|
+
this.Characteristic = this.api.hap.Characteristic;
|
|
24
|
+
this.handleMessage = (msg, rinfo) => {
|
|
25
|
+
this.log.debug('handleMessage', msg.toString());
|
|
26
|
+
try {
|
|
27
|
+
const message = JSON.parse(msg.toString());
|
|
28
|
+
if (message.i !== 1 || message.t !== 'pack') {
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
const pack = crypto_1.default.decrypt(message.pack);
|
|
32
|
+
if (pack.t === 'dev') {
|
|
33
|
+
this.registerDevice({
|
|
34
|
+
...pack,
|
|
35
|
+
address: rinfo.address,
|
|
36
|
+
port: rinfo.port,
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
catch (err) {
|
|
41
|
+
this.log.error('handleMessage Error:', err);
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
this.registerDevice = (deviceInfo) => {
|
|
45
|
+
var _a, _b;
|
|
46
|
+
const devcfg = this.config.devices.find((item) => item.mac === deviceInfo.mac) || {};
|
|
47
|
+
const deviceConfig = {
|
|
48
|
+
...devcfg,
|
|
49
|
+
...((devcfg.speedSteps && devcfg.speedSteps !== 3 && devcfg.speedSteps !== 5) || devcfg.speedSteps === 0 ?
|
|
50
|
+
{ speedSteps: 5 } : {}),
|
|
51
|
+
...((devcfg.temperatureSensor && ['disabled', 'child', 'separate'].includes(devcfg.temperatureSensor.toLowerCase())) ?
|
|
52
|
+
{ temperatureSensor: devcfg.temperatureSensor.toLowerCase() } : { temperatureSensor: 'disabled' }),
|
|
53
|
+
...(devcfg.minimumTargetTemperature && (devcfg.minimumTargetTemperature < settings_1.DEFAULT_DEVICE_CONFIG.minimumTargetTemperature ||
|
|
54
|
+
devcfg.minimumTargetTemperature > settings_1.DEFAULT_DEVICE_CONFIG.maximumTargetTemperature) ?
|
|
55
|
+
{ minimumTargetTemperature: settings_1.DEFAULT_DEVICE_CONFIG.minimumTargetTemperature } : {}),
|
|
56
|
+
...(devcfg.maximumTargetTemperature && (devcfg.maximumTargetTemperature < settings_1.DEFAULT_DEVICE_CONFIG.minimumTargetTemperature ||
|
|
57
|
+
devcfg.maximumTargetTemperature > settings_1.DEFAULT_DEVICE_CONFIG.maximumTargetTemperature) ?
|
|
58
|
+
{ maximumTargetTemperature: settings_1.DEFAULT_DEVICE_CONFIG.maximumTargetTemperature } : {}),
|
|
59
|
+
};
|
|
60
|
+
Object.entries(settings_1.DEFAULT_DEVICE_CONFIG).forEach(([key, value]) => {
|
|
61
|
+
if (deviceConfig[key] === undefined) {
|
|
62
|
+
deviceConfig[key] = value;
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
let accessory = this.devices[deviceInfo.mac];
|
|
66
|
+
let accessory_ts = this.devices[deviceInfo.mac + '_ts'];
|
|
67
|
+
if ((deviceConfig === null || deviceConfig === void 0 ? void 0 : deviceConfig.disabled) || !/^[a-f0-9]{12}$/.test(deviceConfig.mac)) {
|
|
68
|
+
if (!this.skippedDevices[deviceInfo.mac]) {
|
|
69
|
+
this.log.info(`accessory ${deviceInfo.mac} skipped`);
|
|
70
|
+
this.skippedDevices[deviceInfo.mac] = true;
|
|
71
|
+
}
|
|
72
|
+
if (accessory) {
|
|
73
|
+
this.api.unregisterPlatformAccessories(settings_1.PLUGIN_NAME, settings_1.PLATFORM_NAME, [accessory]);
|
|
74
|
+
delete this.devices[deviceConfig.mac];
|
|
75
|
+
}
|
|
76
|
+
if (accessory_ts) {
|
|
77
|
+
this.api.unregisterPlatformAccessories(settings_1.PLUGIN_NAME, settings_1.PLATFORM_NAME, [accessory_ts]);
|
|
78
|
+
delete this.devices[deviceConfig.mac + '_ts'];
|
|
79
|
+
}
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
if (accessory && this.initializedDevices[accessory.UUID]) {
|
|
83
|
+
// already initalized
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
if (!accessory) {
|
|
87
|
+
const deviceName = (_a = deviceConfig === null || deviceConfig === void 0 ? void 0 : deviceConfig.name) !== null && _a !== void 0 ? _a : (deviceInfo.name || deviceInfo.mac);
|
|
88
|
+
this.log.debug(`Initializing new accessory ${deviceInfo.mac} with name ${deviceName}...`);
|
|
89
|
+
const uuid = this.api.hap.uuid.generate(deviceInfo.mac);
|
|
90
|
+
accessory = new this.api.platformAccessory(deviceName, uuid, 21 /* Categories.AIR_CONDITIONER */);
|
|
91
|
+
this.devices[deviceInfo.mac] = accessory;
|
|
92
|
+
this.api.registerPlatformAccessories(settings_1.PLUGIN_NAME, settings_1.PLATFORM_NAME, [accessory]);
|
|
93
|
+
}
|
|
94
|
+
if (!accessory_ts && deviceConfig.temperatureSensor === 'separate') {
|
|
95
|
+
const deviceName_ts = 'Temperature Sensor - ' + ((_b = deviceConfig === null || deviceConfig === void 0 ? void 0 : deviceConfig.name) !== null && _b !== void 0 ? _b : (deviceInfo.name || deviceInfo.mac));
|
|
96
|
+
this.log.debug(`Initializing new accessory ${deviceInfo.mac} with name ${deviceName_ts}...`);
|
|
97
|
+
const uuid = this.api.hap.uuid.generate(deviceInfo.mac + '_ts');
|
|
98
|
+
accessory_ts = new this.api.platformAccessory(deviceName_ts, uuid, 10 /* Categories.SENSOR */);
|
|
99
|
+
this.devices[deviceInfo.mac + '_ts'] = accessory_ts;
|
|
100
|
+
this.api.registerPlatformAccessories(settings_1.PLUGIN_NAME, settings_1.PLATFORM_NAME, [accessory_ts]);
|
|
101
|
+
}
|
|
102
|
+
if (accessory_ts && deviceConfig.temperatureSensor !== 'separate') {
|
|
103
|
+
this.api.unregisterPlatformAccessories(settings_1.PLUGIN_NAME, settings_1.PLATFORM_NAME, [accessory_ts]);
|
|
104
|
+
delete this.devices[deviceConfig.mac + '_ts'];
|
|
105
|
+
}
|
|
106
|
+
let tsService;
|
|
107
|
+
if (accessory_ts && deviceConfig.temperatureSensor === 'separate') {
|
|
108
|
+
// mark temperature sensor devices as initialized
|
|
109
|
+
accessory_ts.context.device = deviceInfo;
|
|
110
|
+
accessory_ts.context.deviceType = 'TemperatureSensor';
|
|
111
|
+
this.initializedDevices[accessory_ts.UUID] = true;
|
|
112
|
+
tsService = new tsAccessory_1.GreeAirConditionerTS(this, accessory_ts, deviceConfig);
|
|
113
|
+
}
|
|
114
|
+
if (accessory) {
|
|
115
|
+
// mark devices as initialized
|
|
116
|
+
accessory.context.device = deviceInfo;
|
|
117
|
+
accessory.context.deviceType = 'HeaterCooler';
|
|
118
|
+
this.initializedDevices[accessory.UUID] = true;
|
|
119
|
+
return new platformAccessory_1.GreeAirConditioner(this, accessory, deviceConfig, this.config.port, tsService);
|
|
120
|
+
}
|
|
121
|
+
};
|
|
122
|
+
this.socket = dgram_1.default.createSocket({ type: 'udp4', reuseAddr: true });
|
|
123
|
+
this.devices = {};
|
|
124
|
+
this.initializedDevices = {};
|
|
125
|
+
this.skippedDevices = {};
|
|
126
|
+
this.scanCount = 0;
|
|
127
|
+
this.log.debug('Finished initializing platform:', this.config.name);
|
|
128
|
+
// When this event is fired it means Homebridge has restored all cached accessories from disk.
|
|
129
|
+
// Dynamic Platform plugins should only register new accessories after this event was fired,
|
|
130
|
+
// in order to ensure they weren't added to homebridge already. This event can also be used
|
|
131
|
+
// to start discovery of new accessories.
|
|
132
|
+
this.api.on('didFinishLaunching', () => {
|
|
133
|
+
log.debug('Executed didFinishLaunching callback');
|
|
134
|
+
this.socket.on('message', this.handleMessage);
|
|
135
|
+
// run the method to discover / register your devices as accessories
|
|
136
|
+
this.discoverDevices();
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* This function is invoked when homebridge restores cached accessories from disk at startup.
|
|
141
|
+
* It should be used to setup event handlers for characteristics and update respective values.
|
|
142
|
+
*/
|
|
143
|
+
configureAccessory(accessory) {
|
|
144
|
+
var _a;
|
|
145
|
+
this.log.info('Loading accessory from cache: ', accessory.displayName, accessory.context.device);
|
|
146
|
+
// add the restored accessory to the accessories cache so we can track if it has already been registered
|
|
147
|
+
if ((_a = accessory.context.device) === null || _a === void 0 ? void 0 : _a.mac) {
|
|
148
|
+
if (accessory.context.deviceType === undefined || accessory.context.deviceType === 'HeaterCooler') {
|
|
149
|
+
// this is the main accessory
|
|
150
|
+
this.devices[accessory.context.device.mac] = accessory;
|
|
151
|
+
}
|
|
152
|
+
if (accessory.context.deviceType === 'TemperatureSensor') {
|
|
153
|
+
// this is the temperature sensor
|
|
154
|
+
this.devices[accessory.context.device.mac + '_ts'] = accessory;
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* Accessories must only be registered once, previously created accessories
|
|
160
|
+
* must not be registered again to prevent "duplicate UUID" errors.
|
|
161
|
+
*/
|
|
162
|
+
discoverDevices() {
|
|
163
|
+
if (this.config.port !== undefined && typeof this.config.port === 'number' && this.config.port === this.config.port &&
|
|
164
|
+
this.config.port >= 0 && this.config.port <= 65535) {
|
|
165
|
+
this.socket.bind(this.config.port, () => {
|
|
166
|
+
this.log.info(`UDP server bind to port ${this.config.port}`);
|
|
167
|
+
this.socket.setBroadcast(true);
|
|
168
|
+
this.timer = setInterval(() => {
|
|
169
|
+
this.scanCount += 1;
|
|
170
|
+
if (this.scanCount > this.config.scanCount && this.timer) {
|
|
171
|
+
this.log.info('Scan finished.');
|
|
172
|
+
clearInterval(this.timer);
|
|
173
|
+
this.socket.close();
|
|
174
|
+
// remove accessories not found on network
|
|
175
|
+
Object.entries(this.devices).forEach(([key, value]) => {
|
|
176
|
+
if (!this.initializedDevices[value.UUID]) {
|
|
177
|
+
this.log.debug('Cleanup -> Remove', value.displayName, key, value.UUID);
|
|
178
|
+
delete this.config.devices[key];
|
|
179
|
+
}
|
|
180
|
+
});
|
|
181
|
+
}
|
|
182
|
+
else {
|
|
183
|
+
this.broadcastScan();
|
|
184
|
+
}
|
|
185
|
+
}, this.config.scanTimeout * 1000); // scanTimeout in seconds
|
|
186
|
+
});
|
|
187
|
+
}
|
|
188
|
+
else {
|
|
189
|
+
this.log.warn('Warning: Port is missing or misconfigured');
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
broadcastScan() {
|
|
193
|
+
const message = Buffer.from(JSON.stringify({ t: 'scan' }));
|
|
194
|
+
this.socket.send(message, 0, message.length, settings_1.UDP_SCAN_PORT, this.config.scanAddress, (error) => {
|
|
195
|
+
this.log.debug(`Broadcast '${message}' ${this.config.scanAddress}:${settings_1.UDP_SCAN_PORT}`);
|
|
196
|
+
if (error) {
|
|
197
|
+
this.log.error('Error:', error.message);
|
|
198
|
+
}
|
|
199
|
+
});
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
exports.GreeACPlatform = GreeACPlatform;
|
|
203
|
+
//# sourceMappingURL=platform.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"platform.js","sourceRoot":"","sources":["../src/platform.ts"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAC1B,sDAA8B;AAG9B,yCAA8F;AAC9F,2DAAyD;AACzD,+CAAqD;AAErD;;;;GAIG;AACH,MAAa,cAAc;IAYzB,YACkB,GAAW,EACX,MAAsB,EACtB,GAAQ;QAFR,QAAG,GAAH,GAAG,CAAQ;QACX,WAAM,GAAN,MAAM,CAAgB;QACtB,Q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AK,CAAC,mBAAmB,EAAE,KAAK,CAAC,WAAW,EAAE,GAAG,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC;gCACxE,OAAO,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;6BACjC;wBACH,CAAC,CAAC,CAAC;qBACJ;yBAAM;wBACL,IAAI,CAAC,aAAa,EAAE,CAAC;qBACtB;gBACH,CAAC,EAAE,IAAI,CAAC,MAAM,CAAC,WAAW,GAAG,IAAI,CAAC,CAAC,CAAC,yBAAyB;YAC/D,CAAC,CAAC,CAAC;SACJ;aAAM;YACL,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,2CAA2C,CAAC,CAAC;SAC5D;IACH,CAAC;IA6GD,aAAa;QACX,MAAM,OAAO,GAAG,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC;QAC3D,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC,EAAE,OAAO,CAAC,MAAM,EAAE,wBAAa,EAAE,IAAI,CAAC,MAAM,CAAC,WAAW,EAAE,CAAC,KAAK,EAAE,EAAE;YAC7F,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,cAAc,OAAO,KAAK,IAAI,CAAC,MAAM,CAAC,WAAW,IAAI,wBAAa,EAAE,CAAC,CAAC;YACrF,IAAI,KAAK,EAAE;gBACT,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,QAAQ,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC;aACzC;QACH,CAAC,CAAC,CAAC;IACL,CAAC;CACF;AA7MD,wCA6MC"}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { PlatformAccessory, CharacteristicValue } from 'homebridge';
|
|
2
|
+
import { GreeACPlatform } from './platform';
|
|
3
|
+
import { DeviceConfig } from './settings';
|
|
4
|
+
import { GreeAirConditionerTS } from './tsAccessory';
|
|
5
|
+
/**
|
|
6
|
+
* Platform Accessory
|
|
7
|
+
* An instance of this class is created for each accessory your platform registers
|
|
8
|
+
* Each accessory may expose multiple services of different service types.
|
|
9
|
+
*/
|
|
10
|
+
export declare class GreeAirConditioner {
|
|
11
|
+
private readonly platform;
|
|
12
|
+
private readonly accessory;
|
|
13
|
+
private readonly deviceConfig;
|
|
14
|
+
private readonly port;
|
|
15
|
+
private readonly platform_ts;
|
|
16
|
+
private HeaterCooler;
|
|
17
|
+
private TemperatureSensor;
|
|
18
|
+
private socket;
|
|
19
|
+
private key;
|
|
20
|
+
private cols;
|
|
21
|
+
private bound;
|
|
22
|
+
private status;
|
|
23
|
+
private updateTimer;
|
|
24
|
+
constructor(platform: GreeACPlatform, accessory: PlatformAccessory, deviceConfig: DeviceConfig, port: number, platform_ts: GreeAirConditionerTS);
|
|
25
|
+
/**
|
|
26
|
+
* Handle "SET" requests from HomeKit
|
|
27
|
+
* These are sent when the user changes the state of an accessory
|
|
28
|
+
*/
|
|
29
|
+
setActive(value: CharacteristicValue): Promise<void>;
|
|
30
|
+
setTargetHeaterCoolerState(value: CharacteristicValue): Promise<void>;
|
|
31
|
+
setTargetTemperature(value: CharacteristicValue): Promise<void>;
|
|
32
|
+
setTemperatureDisplayUnits(value: CharacteristicValue): Promise<void>;
|
|
33
|
+
setSwingMode(value: CharacteristicValue): Promise<void>;
|
|
34
|
+
setRotationSpeed(value: CharacteristicValue): Promise<void>;
|
|
35
|
+
/**
|
|
36
|
+
* Handle the "GET" requests from HomeKit
|
|
37
|
+
* These are sent when HomeKit wants to know the current state of the accessory
|
|
38
|
+
*
|
|
39
|
+
* GET requests should return as fast as possbile. A long delay here will result in
|
|
40
|
+
* HomeKit being unresponsive and a bad user experience in general.
|
|
41
|
+
*
|
|
42
|
+
* If your device takes time to respond you should update the status of your device
|
|
43
|
+
* asynchronously instead using the `updateCharacteristic` method instead.
|
|
44
|
+
|
|
45
|
+
* @example
|
|
46
|
+
* this.service.updateCharacteristic(this.platform.Characteristic.On, true)
|
|
47
|
+
|
|
48
|
+
* if you need to return an error to show the device as "Not Responding" in the Home app:
|
|
49
|
+
* throw new this.platform.api.hap.HapStatusError(this.platform.api.hap.HAPStatus.SERVICE_COMMUNICATION_FAILURE);
|
|
50
|
+
*/
|
|
51
|
+
getActive(): Promise<CharacteristicValue>;
|
|
52
|
+
getCurrentHeaterCoolerState(): Promise<CharacteristicValue>;
|
|
53
|
+
getTargetHeaterCoolerState(): Promise<CharacteristicValue>;
|
|
54
|
+
getCurrentTemperature(service: string): Promise<CharacteristicValue>;
|
|
55
|
+
getTargetTemperature(target: string): Promise<CharacteristicValue>;
|
|
56
|
+
getTemperatureDisplayUnits(): Promise<CharacteristicValue>;
|
|
57
|
+
getSwingMode(): Promise<CharacteristicValue>;
|
|
58
|
+
getRotationSpeed(): Promise<CharacteristicValue>;
|
|
59
|
+
getDeviceLabel(): string;
|
|
60
|
+
getCols(): string[];
|
|
61
|
+
getKeyName(obj: any, value: any, subkey?: any): string;
|
|
62
|
+
calcDeviceTargetTemp(temp: number): number;
|
|
63
|
+
calcDeviceTargetOffset(temp: number): number;
|
|
64
|
+
getTargetTempFromDevice(temp: any, offset: any): number;
|
|
65
|
+
get power(): boolean;
|
|
66
|
+
set power(value: boolean);
|
|
67
|
+
get mode(): any;
|
|
68
|
+
set mode(value: any);
|
|
69
|
+
get currentTemperature(): number;
|
|
70
|
+
get targetTemperature(): number;
|
|
71
|
+
set targetTemperature(value: number);
|
|
72
|
+
get units(): any;
|
|
73
|
+
set units(value: any);
|
|
74
|
+
get swingMode(): any;
|
|
75
|
+
set swingMode(value: any);
|
|
76
|
+
get speed(): any;
|
|
77
|
+
set speed(value: any);
|
|
78
|
+
get quietMode(): any;
|
|
79
|
+
set quietMode(value: any);
|
|
80
|
+
get powerfulMode(): any;
|
|
81
|
+
set powerfulMode(value: any);
|
|
82
|
+
updateStatus(props: string[]): void;
|
|
83
|
+
handleMessage: (msg: any, rinfo: any) => void;
|
|
84
|
+
sendMessage(message: any): void;
|
|
85
|
+
sendBindRequest(): void;
|
|
86
|
+
sendCommand(cmd: any): void;
|
|
87
|
+
requestDeviceStatus(): void;
|
|
88
|
+
}
|
|
89
|
+
//# sourceMappingURL=platformAccessory.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"platformAccessory.d.ts","sourceRoot":"","sources":["../src/platformAccessory.ts"],"names":[],"mappings":"AACA,OAAO,EAAW,iBAAiB,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAE7E,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAC5C,OAAO,EAAE,YAAY,EAAqB,MAAM,YAAY,CAAC;AAC7D,OAAO,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;AAIrD;;;;GAIG;AACH,qBAAa,kBAAkB;IAW3B,OAAO,CAAC,QAAQ,CAAC,QAAQ;IACzB,OAAO,CAAC,QAAQ,CAAC,SAAS;IAC1B,OAAO,CAAC,QAAQ,CAAC,YAAY;IAC7B,OAAO,CAAC,QAAQ,CAAC,IAAI;IACrB,OAAO,CAAC,QAAQ,CAAC,WAAW;IAd9B,OAAO,CAAC,YAAY,CAAU;IAC9B,OAAO,CAAC,iBAAiB,CAAsB;IAC/C,OAAO,CAAC,MAAM,CAAe;IAC7B,OAAO,CAAC,GAAG,CAAqB;IAChC,OAAO,CAAC,IAAI,CAA4B;IACxC,OAAO,CAAC,KAAK,CAAU;IACvB,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,WAAW,CAA6B;gBAG7B,QAAQ,EAAE,cAAc,EACxB,SAAS,EAAE,iBAAiB,EAC5B,YAAY,EAAE,YAAY,EAC1B,IAAI,EAAE,MAAM,EACZ,WAAW,EAAE,oBAAoB;IAoHpD;;;OAGG;IACG,SAAS,CAAC,KAAK,EAAE,mBAAmB;IAMpC,0BAA0B,CAAC,KAAK,EAAE,mBAAmB;IAiBrD,oBAAoB,CAAC,KAAK,EAAE,mBAAmB;IAK/C,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