homebridge-tydom 0.24.0 → 0.24.1
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/lib/accessories/securitySystem.js +4 -4
- package/lib/controller.js +3 -0
- package/lib/platform.js +15 -6
- package/package.json +1 -1
|
@@ -100,10 +100,10 @@ const setupSecuritySystem = async (accessory, controller) => {
|
|
|
100
100
|
log.warn(`Setting up legacy zones`);
|
|
101
101
|
// @NOTE could filter "UNUSED" zones from initialData
|
|
102
102
|
zones = [
|
|
103
|
-
{ id:
|
|
104
|
-
{ id:
|
|
105
|
-
{ id:
|
|
106
|
-
{ id:
|
|
103
|
+
{ id: 0, nameCustom: 'Zone 1' },
|
|
104
|
+
{ id: 1, nameCustom: 'Zone 2' },
|
|
105
|
+
{ id: 2, nameCustom: 'Zone 3' },
|
|
106
|
+
{ id: 3, nameCustom: 'Zone 4' }
|
|
107
107
|
];
|
|
108
108
|
}
|
|
109
109
|
// Pin code check
|
package/lib/controller.js
CHANGED
|
@@ -112,6 +112,9 @@ class TydomController extends events_1.EventEmitter {
|
|
|
112
112
|
if (excludedDevices.length && (0, utils_1.stringIncludes)(excludedDevices, deviceId)) {
|
|
113
113
|
return;
|
|
114
114
|
}
|
|
115
|
+
if (categoryFromSettings) {
|
|
116
|
+
this.log.info(`Using overriden category=${(0, utils_1.chalkNumber)(categoryFromSettings)} from settings for deviceId=${(0, utils_1.chalkNumber)(deviceId)} and endpointId=${(0, utils_1.chalkNumber)(endpointId)}`);
|
|
117
|
+
}
|
|
115
118
|
const category = categoryFromSettings || (0, tydom_1.resolveEndpointCategory)({ firstUsage, metadata, settings: deviceSettings });
|
|
116
119
|
if (!category) {
|
|
117
120
|
this.log.warn(`Unsupported firstUsage="${firstUsage}" for endpoint with deviceId="${deviceId}"`);
|
package/lib/platform.js
CHANGED
|
@@ -48,16 +48,25 @@ class TydomPlatform {
|
|
|
48
48
|
this.log.info(`Properly loaded ${this.accessories.size}-accessories`);
|
|
49
49
|
}
|
|
50
50
|
async handleControllerDevice(context) {
|
|
51
|
+
var _a, _b;
|
|
51
52
|
const { name, deviceId, category, accessoryId } = context;
|
|
52
53
|
const id = this.api.hap.uuid.generate(accessoryId);
|
|
53
54
|
this.log.info(`Found new tydom device named=${(0, utils_1.chalkString)(name)} with deviceId=${(0, utils_1.chalkNumber)(deviceId)} (id=${(0, utils_1.chalkKeyword)(id)})`);
|
|
54
55
|
this.log.debug(`Tydom with deviceId=${(0, utils_1.chalkNumber)(deviceId)} (id=${(0, utils_1.chalkKeyword)(id)}) context="${JSON.stringify(context)}"`);
|
|
56
|
+
const hasNewCategory = ((_a = this.accessories.get(id)) === null || _a === void 0 ? void 0 : _a.category) !== category;
|
|
57
|
+
(0, utils_1.debug)(`[${deviceId}] ${(_b = this.accessories.get(id)) === null || _b === void 0 ? void 0 : _b.category} vs ${category}`);
|
|
55
58
|
// Prevent automatic cleanup
|
|
56
59
|
this.cleanupAccessoriesIds.delete(id);
|
|
57
60
|
if (this.accessories.has(id)) {
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
+
if (!hasNewCategory) {
|
|
62
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
63
|
+
await this.updateAccessory(this.accessories.get(id), context);
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
else {
|
|
67
|
+
this.log.warn(`Deleting accessory with new category with id=${(0, utils_1.chalkNumber)(accessoryId)}`);
|
|
68
|
+
this.api.unregisterPlatformAccessories(env_1.PLUGIN_NAME, env_1.PLATFORM_NAME, [this.accessories.get(id)]);
|
|
69
|
+
}
|
|
61
70
|
}
|
|
62
71
|
const accessory = await this.createAccessory(name, id, category, context);
|
|
63
72
|
this.accessories.set(id, accessory);
|
|
@@ -94,15 +103,15 @@ class TydomPlatform {
|
|
|
94
103
|
const { platformAccessory: PlatformAccessory } = this.api;
|
|
95
104
|
const { group } = context;
|
|
96
105
|
const accessoryName = category === 13 /* Categories.WINDOW */ && group ? group.name || name : name;
|
|
97
|
-
this.log.info(`Creating accessory named
|
|
106
|
+
this.log.info(`Creating accessory named=${(0, utils_1.chalkString)(accessoryName)}, deviceId="${(0, utils_1.chalkNumber)(context.deviceId)} (id=${(0, utils_1.chalkKeyword)(id)})"`);
|
|
98
107
|
const accessory = new PlatformAccessory(accessoryName, id, category);
|
|
99
108
|
Object.assign(accessory.context, context);
|
|
100
109
|
await this.updateAccessory(accessory, context);
|
|
101
110
|
return accessory;
|
|
102
111
|
}
|
|
103
112
|
async updateAccessory(accessory, context) {
|
|
104
|
-
const { displayName:
|
|
105
|
-
this.log.info(`Updating accessory named
|
|
113
|
+
const { displayName: accessoryName, UUID: id } = accessory;
|
|
114
|
+
this.log.info(`Updating accessory named=${(0, utils_1.chalkString)(accessoryName)}, deviceId=${(0, utils_1.chalkNumber)(context.deviceId)} (id=${(0, utils_1.chalkKeyword)(id)})"`);
|
|
106
115
|
Object.assign(accessory.context, context);
|
|
107
116
|
const tydomAccessorySetup = (0, accessory_1.getTydomAccessorySetup)(accessory, context);
|
|
108
117
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|