@homebridge-plugins/homebridge-tuya 3.0.0-beta.13 → 3.0.0-beta.15
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 +1 -1
- package/dist/cloud/device/TuyaCloudDeviceManager.js +1 -1
- package/dist/cloud/device/TuyaCloudDeviceManager.js.map +1 -1
- package/dist/local/LocalDeviceManager.js +49 -9
- package/dist/local/LocalDeviceManager.js.map +1 -1
- package/dist/platform.js +1 -1
- package/dist/platform.js.map +1 -1
- package/dist/shared/TuyaDeviceManager.js +1 -1
- package/dist/shared/TuyaDeviceManager.js.map +1 -1
- package/dist/shared/TuyaHybridDeviceManager.js +1 -1
- package/dist/shared/TuyaHybridDeviceManager.js.map +1 -1
- package/dist/shared/accessory/AccessoryFactory.js +22 -0
- package/dist/shared/accessory/AccessoryFactory.js.map +1 -1
- package/dist/shared/accessory/AirConditionerAccessory.js +21 -15
- package/dist/shared/accessory/AirConditionerAccessory.js.map +1 -1
- package/dist/shared/accessory/IRAdapter.js +165 -0
- package/dist/shared/accessory/IRAdapter.js.map +1 -0
- package/dist/shared/accessory/IRFanAccessory.js +90 -0
- package/dist/shared/accessory/IRFanAccessory.js.map +1 -0
- package/dist/shared/accessory/characteristic/CurrentRelativeHumidity.js +3 -0
- package/dist/shared/accessory/characteristic/CurrentRelativeHumidity.js.map +1 -1
- package/dist/shared/accessory/characteristic/CurrentWetBulbGlobeTemperature.js +3 -2
- package/dist/shared/accessory/characteristic/CurrentWetBulbGlobeTemperature.js.map +1 -1
- package/dist/shared/accessory/characteristic/LockPhysicalControls.js +3 -0
- package/dist/shared/accessory/characteristic/LockPhysicalControls.js.map +1 -1
- package/dist/shared/accessory/characteristic/RelativeHumidityDehumidifierThreshold.js +3 -0
- package/dist/shared/accessory/characteristic/RelativeHumidityDehumidifierThreshold.js.map +1 -1
- package/dist/shared/accessory/characteristic/SwingMode.js +3 -0
- package/dist/shared/accessory/characteristic/SwingMode.js.map +1 -1
- package/dist/shared/util/ConfigMigrator.js +4 -2
- package/dist/shared/util/ConfigMigrator.js.map +1 -1
- package/package.json +1 -1
- package/test/airConditioner.test.ts +730 -0
- package/test/localDeviceManager.behavior.test.ts +179 -0
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { beforeEach, describe, expect, jest, test } from '@jest/globals';
|
|
2
2
|
import LocalDeviceManager from '../src/local/LocalDeviceManager';
|
|
3
3
|
import type { LocalConfig } from '../src/local/config';
|
|
4
|
+
import { TuyaPluginMode } from '../src/config';
|
|
5
|
+
import { TuyaDeviceSchemaType } from '../src/cloud/device/TuyaDevice';
|
|
4
6
|
import { ExLogger, initLogger } from '../src/shared/util/Logger';
|
|
5
7
|
|
|
6
8
|
const createdConnections: any[] = [];
|
|
@@ -168,4 +170,181 @@ describe('LocalDeviceManager command and local mapping behavior', () => {
|
|
|
168
170
|
expect(discovered?.ip).toBe('192.168.1.30');
|
|
169
171
|
expect(discovered?.product_id).toBe('prod1');
|
|
170
172
|
});
|
|
173
|
+
|
|
174
|
+
test('keeps DP mapping when a local override uses the same code as a no-op rename', async () => {
|
|
175
|
+
const config: LocalConfig = {
|
|
176
|
+
autoDiscoverDevices: false,
|
|
177
|
+
deviceOverrides: [{
|
|
178
|
+
id: 'dev-1',
|
|
179
|
+
configFor: TuyaPluginMode.local,
|
|
180
|
+
schema: [{
|
|
181
|
+
code: 'humidity_indoor',
|
|
182
|
+
newCode: 'humidity_indoor',
|
|
183
|
+
type: TuyaDeviceSchemaType.Integer,
|
|
184
|
+
property: { min: 0, max: 100, scale: 0, step: 1 },
|
|
185
|
+
}],
|
|
186
|
+
}],
|
|
187
|
+
devices: [{
|
|
188
|
+
tuyaDeviceId: 'dev-1',
|
|
189
|
+
ip: '192.168.1.10',
|
|
190
|
+
tuyaKey: 'abcdef1234567890',
|
|
191
|
+
protocolVersion: '3.5',
|
|
192
|
+
dpMapping: {
|
|
193
|
+
humidity_indoor: 6,
|
|
194
|
+
},
|
|
195
|
+
}],
|
|
196
|
+
};
|
|
197
|
+
|
|
198
|
+
const manager = new LocalDeviceManager(config);
|
|
199
|
+
await manager.initLocalDevices();
|
|
200
|
+
|
|
201
|
+
const device = manager.getDevice('dev-1');
|
|
202
|
+
const dpMap = (manager as any).dpMaps.get('dev-1');
|
|
203
|
+
const reverseMap = (manager as any).reverseDpMaps.get('dev-1');
|
|
204
|
+
|
|
205
|
+
expect(dpMap?.humidity_indoor).toBe(6);
|
|
206
|
+
expect(reverseMap?.[6]).toBe('humidity_indoor');
|
|
207
|
+
expect(device?.schema.some(schema => schema.code === 'humidity_indoor' && schema.type === TuyaDeviceSchemaType.Integer)).toBe(true);
|
|
208
|
+
});
|
|
209
|
+
|
|
210
|
+
test('applies local overrides without a rename using the original code', async () => {
|
|
211
|
+
const config: LocalConfig = {
|
|
212
|
+
autoDiscoverDevices: false,
|
|
213
|
+
deviceOverrides: [{
|
|
214
|
+
id: 'dev-1',
|
|
215
|
+
configFor: TuyaPluginMode.local,
|
|
216
|
+
schema: [{
|
|
217
|
+
code: 'humidity_indoor',
|
|
218
|
+
type: TuyaDeviceSchemaType.Integer,
|
|
219
|
+
property: { min: 0, max: 100, scale: 0, step: 1 },
|
|
220
|
+
}],
|
|
221
|
+
}],
|
|
222
|
+
devices: [{
|
|
223
|
+
tuyaDeviceId: 'dev-1',
|
|
224
|
+
ip: '192.168.1.10',
|
|
225
|
+
tuyaKey: 'abcdef1234567890',
|
|
226
|
+
protocolVersion: '3.5',
|
|
227
|
+
dpMapping: {
|
|
228
|
+
humidity_indoor: 6,
|
|
229
|
+
},
|
|
230
|
+
}],
|
|
231
|
+
};
|
|
232
|
+
|
|
233
|
+
const manager = new LocalDeviceManager(config);
|
|
234
|
+
await manager.initLocalDevices();
|
|
235
|
+
|
|
236
|
+
const device = manager.getDevice('dev-1');
|
|
237
|
+
const schema = device?.schema.find(item => item.code === 'humidity_indoor');
|
|
238
|
+
|
|
239
|
+
expect(schema).toBeDefined();
|
|
240
|
+
expect(schema?.type).toBe(TuyaDeviceSchemaType.Integer);
|
|
241
|
+
expect(device?.schema.every(item => !!item.code)).toBe(true);
|
|
242
|
+
});
|
|
243
|
+
|
|
244
|
+
test('applies local overrides', async () => {
|
|
245
|
+
const config: LocalConfig = {
|
|
246
|
+
autoDiscoverDevices: false,
|
|
247
|
+
devices: [],
|
|
248
|
+
deviceOverrides: [{
|
|
249
|
+
id: 'dev-1',
|
|
250
|
+
category: 'jsq',
|
|
251
|
+
configFor: TuyaPluginMode.local,
|
|
252
|
+
schema: [{
|
|
253
|
+
code: 'humidity_indoor',
|
|
254
|
+
type: TuyaDeviceSchemaType.Integer,
|
|
255
|
+
property: { min: 0, max: 100, scale: 0, step: 1 },
|
|
256
|
+
}],
|
|
257
|
+
}],
|
|
258
|
+
};
|
|
259
|
+
|
|
260
|
+
const manager = new LocalDeviceManager(config);
|
|
261
|
+
await manager.initLocalDevices();
|
|
262
|
+
|
|
263
|
+
(manager as any)._onDiscovered({
|
|
264
|
+
id: 'dev-1',
|
|
265
|
+
ip: '192.168.0.1',
|
|
266
|
+
version: '3.3',
|
|
267
|
+
productKey: 'prod1',
|
|
268
|
+
});
|
|
269
|
+
|
|
270
|
+
const device = manager.getDevice('dev-1');
|
|
271
|
+
|
|
272
|
+
expect(device).toBeDefined();
|
|
273
|
+
expect(device?.ip).toBe('192.168.0.1');
|
|
274
|
+
expect(device?.product_id).toBe('prod1');
|
|
275
|
+
expect(device?.category).toBe('jsq');
|
|
276
|
+
expect(device?.schema?.length).toBe(1);
|
|
277
|
+
expect(device?.schema?.[0].code).toBe('humidity_indoor');
|
|
278
|
+
});
|
|
279
|
+
|
|
280
|
+
test('do not apply cloud overrides to local devices', async () => {
|
|
281
|
+
const config: LocalConfig = {
|
|
282
|
+
autoDiscoverDevices: false,
|
|
283
|
+
devices: [],
|
|
284
|
+
deviceOverrides: [{
|
|
285
|
+
id: 'dev-1',
|
|
286
|
+
category: 'jsq',
|
|
287
|
+
configFor: TuyaPluginMode.cloud,
|
|
288
|
+
schema: [{
|
|
289
|
+
code: 'humidity_indoor',
|
|
290
|
+
type: TuyaDeviceSchemaType.Integer,
|
|
291
|
+
property: { min: 0, max: 100, scale: 0, step: 1 },
|
|
292
|
+
}],
|
|
293
|
+
}],
|
|
294
|
+
};
|
|
295
|
+
|
|
296
|
+
const manager = new LocalDeviceManager(config);
|
|
297
|
+
await manager.initLocalDevices();
|
|
298
|
+
|
|
299
|
+
(manager as any)._onDiscovered({
|
|
300
|
+
id: 'dev-1',
|
|
301
|
+
ip: '192.168.0.1',
|
|
302
|
+
version: '3.3',
|
|
303
|
+
productKey: 'prod1',
|
|
304
|
+
});
|
|
305
|
+
|
|
306
|
+
const device = manager.getDevice('dev-1');
|
|
307
|
+
|
|
308
|
+
expect(device).toBeDefined();
|
|
309
|
+
expect(device?.ip).toBe('192.168.0.1');
|
|
310
|
+
expect(device?.product_id).toBe('prod1');
|
|
311
|
+
expect(device?.category).toBe('unknown');
|
|
312
|
+
expect(device?.schema?.length).toBe(0);
|
|
313
|
+
});
|
|
314
|
+
|
|
315
|
+
test('applies overrides local device (configFor:both)', async () => {
|
|
316
|
+
const config: LocalConfig = {
|
|
317
|
+
autoDiscoverDevices: false,
|
|
318
|
+
devices: [],
|
|
319
|
+
deviceOverrides: [{
|
|
320
|
+
id: 'dev-1',
|
|
321
|
+
category: 'jsq',
|
|
322
|
+
configFor: TuyaPluginMode.both,
|
|
323
|
+
schema: [{
|
|
324
|
+
code: 'humidity_indoor',
|
|
325
|
+
type: TuyaDeviceSchemaType.Integer,
|
|
326
|
+
property: { min: 0, max: 100, scale: 0, step: 1 },
|
|
327
|
+
}],
|
|
328
|
+
}],
|
|
329
|
+
};
|
|
330
|
+
|
|
331
|
+
const manager = new LocalDeviceManager(config);
|
|
332
|
+
await manager.initLocalDevices();
|
|
333
|
+
|
|
334
|
+
(manager as any)._onDiscovered({
|
|
335
|
+
id: 'dev-1',
|
|
336
|
+
ip: '192.168.0.1',
|
|
337
|
+
version: '3.3',
|
|
338
|
+
productKey: 'prod1',
|
|
339
|
+
});
|
|
340
|
+
|
|
341
|
+
const device = manager.getDevice('dev-1');
|
|
342
|
+
|
|
343
|
+
expect(device).toBeDefined();
|
|
344
|
+
expect(device?.ip).toBe('192.168.0.1');
|
|
345
|
+
expect(device?.product_id).toBe('prod1');
|
|
346
|
+
expect(device?.category).toBe('jsq');
|
|
347
|
+
expect(device?.schema?.length).toBe(1);
|
|
348
|
+
expect(device?.schema?.[0].code).toBe('humidity_indoor');
|
|
349
|
+
});
|
|
171
350
|
});
|