homebridge-zencontrol-tpi 1.1.0-next.1 → 1.1.0-next.2
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 +54 -0
- package/config.schema.json +6 -0
- package/dist/co2Accessory.js +37 -0
- package/dist/platform.js +40 -0
- package/package.json +1 -1
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
# homebridge-zencontrol-tpi
|
|
2
|
+
|
|
3
|
+
## 1.1.0-next.2
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 30f74dd: Add CO2 sensors
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- 74d8166: Include CHANGELOG.md in package so it is visible in Homebridge
|
|
12
|
+
- 11eee07: Fix missing humidity sensor updates
|
|
13
|
+
|
|
14
|
+
## 1.1.0-next.1
|
|
15
|
+
|
|
16
|
+
### Patch Changes
|
|
17
|
+
|
|
18
|
+
- d5392bc: Upgrade dependencies
|
|
19
|
+
|
|
20
|
+
## 1.1.0-next.0
|
|
21
|
+
|
|
22
|
+
### Minor Changes
|
|
23
|
+
|
|
24
|
+
- f97fd3f: Remove type names from system variables and detect only based on end of variable name
|
|
25
|
+
|
|
26
|
+
## 1.0.4
|
|
27
|
+
|
|
28
|
+
### Patch Changes
|
|
29
|
+
|
|
30
|
+
- 7c43d03: Update project configuration to specify a git repository to try to show changelog in Homebridge
|
|
31
|
+
|
|
32
|
+
## 1.0.3
|
|
33
|
+
|
|
34
|
+
### Patch Changes
|
|
35
|
+
|
|
36
|
+
- 771ecc3: Include changelog in package so it shows up in Homebridge
|
|
37
|
+
|
|
38
|
+
## 1.0.2
|
|
39
|
+
|
|
40
|
+
### Patch Changes
|
|
41
|
+
|
|
42
|
+
- bbc24df: Adjust logging levels so we can see messages received from the controller
|
|
43
|
+
|
|
44
|
+
## 1.0.1
|
|
45
|
+
|
|
46
|
+
### Patch Changes
|
|
47
|
+
|
|
48
|
+
- cf53e2a: Fix zencontrol-tpi-node dependency
|
|
49
|
+
|
|
50
|
+
## 1.0.0
|
|
51
|
+
|
|
52
|
+
### Major Changes
|
|
53
|
+
|
|
54
|
+
- 25a3935: Initial release
|
package/config.schema.json
CHANGED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
export class ZencontrolCO2PlatformAccessory {
|
|
2
|
+
constructor(platform, accessory) {
|
|
3
|
+
this.platform = platform;
|
|
4
|
+
this.accessory = accessory;
|
|
5
|
+
this.knownCO2 = null;
|
|
6
|
+
this.accessory.getService(this.platform.Service.AccessoryInformation)
|
|
7
|
+
.setCharacteristic(this.platform.Characteristic.Manufacturer, 'Zencontrol')
|
|
8
|
+
.setCharacteristic(this.platform.Characteristic.Model, accessory.context.model || 'Unknown')
|
|
9
|
+
.setCharacteristic(this.platform.Characteristic.SerialNumber, accessory.context.serial || 'Unknown');
|
|
10
|
+
// https://developers.homebridge.io/#/service/CarbonDioxideSensor
|
|
11
|
+
this.service = this.accessory.getService(this.platform.Service.CarbonDioxideSensor) || this.accessory.addService(this.platform.Service.CarbonDioxideSensor);
|
|
12
|
+
this.service.setCharacteristic(this.platform.Characteristic.Name, accessory.displayName);
|
|
13
|
+
this.service.getCharacteristic(this.platform.Characteristic.CarbonDioxideDetected)
|
|
14
|
+
.onGet(this.getCO2Detected.bind(this));
|
|
15
|
+
this.service.getCharacteristic(this.platform.Characteristic.CarbonDioxideLevel)
|
|
16
|
+
.onGet(this.getCurrentCO2Level.bind(this));
|
|
17
|
+
}
|
|
18
|
+
get displayName() {
|
|
19
|
+
return this.accessory.displayName;
|
|
20
|
+
}
|
|
21
|
+
async getCO2Detected() {
|
|
22
|
+
if (this.knownCO2 !== null && this.platform.config.co2AbnormalLevel && this.knownCO2 >= this.platform.config.co2AbnormalLevel) {
|
|
23
|
+
return this.platform.Characteristic.CarbonDioxideDetected.CO2_LEVELS_ABNORMAL;
|
|
24
|
+
}
|
|
25
|
+
else {
|
|
26
|
+
return this.platform.Characteristic.CarbonDioxideDetected.CO2_LEVELS_NORMAL;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
async getCurrentCO2Level() {
|
|
30
|
+
return this.knownCO2;
|
|
31
|
+
}
|
|
32
|
+
async receiveCO2(co2) {
|
|
33
|
+
this.knownCO2 = co2;
|
|
34
|
+
this.platform.log(`Received CO2 for ${this.displayName}: ${co2}`);
|
|
35
|
+
this.service.updateCharacteristic(this.platform.Characteristic.CarbonDioxideLevel, co2);
|
|
36
|
+
}
|
|
37
|
+
}
|
package/dist/platform.js
CHANGED
|
@@ -5,6 +5,7 @@ import { ZencontrolTemperaturePlatformAccessory } from './temperatureAccessory.j
|
|
|
5
5
|
import { ZencontrolHumidityPlatformAccessory } from './humidityAccessory.js';
|
|
6
6
|
import { ZencontrolRelayPlatformAccessory } from './relayAccessory.js';
|
|
7
7
|
import { ZencontrolLuxPlatformAccessory } from './luxAccessory.js';
|
|
8
|
+
import { ZencontrolCO2PlatformAccessory } from './co2Accessory.js';
|
|
8
9
|
/**
|
|
9
10
|
* HomebridgePlatform
|
|
10
11
|
* This class is the main constructor for your plugin, this is where you should
|
|
@@ -176,6 +177,16 @@ export class ZencontrolTPIPlatform {
|
|
|
176
177
|
});
|
|
177
178
|
acc.receiveLux(value);
|
|
178
179
|
}
|
|
180
|
+
else if (label && label.toLocaleLowerCase().endsWith(' co2')) {
|
|
181
|
+
const value = await this.zc.querySystemVariable(controller, variable);
|
|
182
|
+
const acc = this.addCO2Accessory({
|
|
183
|
+
address: systemVariableToAddressString(controller, variable),
|
|
184
|
+
label: label.substring(0, label.length - ' co2'.length),
|
|
185
|
+
model: 'System Variable',
|
|
186
|
+
serial: `SV ${controller.id}.${variable}`,
|
|
187
|
+
});
|
|
188
|
+
acc.receiveCO2(value);
|
|
189
|
+
}
|
|
179
190
|
}));
|
|
180
191
|
}
|
|
181
192
|
}
|
|
@@ -321,6 +332,25 @@ export class ZencontrolTPIPlatform {
|
|
|
321
332
|
this.discoveredCacheUUIDs.push(uuid);
|
|
322
333
|
return acc;
|
|
323
334
|
}
|
|
335
|
+
addCO2Accessory({ address, label, model, serial }) {
|
|
336
|
+
const uuid = this.api.hap.uuid.generate(`co2 @ ${address}`);
|
|
337
|
+
const existingAccessory = this.accessories.get(uuid);
|
|
338
|
+
let acc;
|
|
339
|
+
if (existingAccessory) {
|
|
340
|
+
this.log.debug('Restoring existing CO2 accessory from cache:', existingAccessory.displayName);
|
|
341
|
+
this.updateAccessory(existingAccessory, { address, label, model, serial });
|
|
342
|
+
acc = new ZencontrolCO2PlatformAccessory(this, existingAccessory);
|
|
343
|
+
}
|
|
344
|
+
else {
|
|
345
|
+
this.log.info('Adding new CO2 accessory:', label);
|
|
346
|
+
const accessory = new this.api.platformAccessory(label, uuid);
|
|
347
|
+
this.setupAccessory(accessory, { address, label, model, serial });
|
|
348
|
+
acc = new ZencontrolCO2PlatformAccessory(this, accessory);
|
|
349
|
+
}
|
|
350
|
+
this.accessoriesByAddress.set(address, acc);
|
|
351
|
+
this.discoveredCacheUUIDs.push(uuid);
|
|
352
|
+
return acc;
|
|
353
|
+
}
|
|
324
354
|
setupAccessory(accessory, { address, label, model, serial }) {
|
|
325
355
|
accessory.context.address = address;
|
|
326
356
|
accessory.context.model = model;
|
|
@@ -396,11 +426,21 @@ export class ZencontrolTPIPlatform {
|
|
|
396
426
|
this.log.warn(`Failed to update temperature accessory "${acc.displayName}" color: ${reason}`);
|
|
397
427
|
});
|
|
398
428
|
}
|
|
429
|
+
else if (acc instanceof ZencontrolHumidityPlatformAccessory) {
|
|
430
|
+
acc.receiveHumidity(value).catch((reason) => {
|
|
431
|
+
this.log.warn(`Failed to update humidity accessory "${acc.displayName}" color: ${reason}`);
|
|
432
|
+
});
|
|
433
|
+
}
|
|
399
434
|
else if (acc instanceof ZencontrolLuxPlatformAccessory) {
|
|
400
435
|
acc.receiveLux(value).catch((reason) => {
|
|
401
436
|
this.log.warn(`Failed to update lux accessory "${acc.displayName}" color: ${reason}`);
|
|
402
437
|
});
|
|
403
438
|
}
|
|
439
|
+
else if (acc instanceof ZencontrolCO2PlatformAccessory) {
|
|
440
|
+
acc.receiveCO2(value).catch((reason) => {
|
|
441
|
+
this.log.warn(`Failed to update CO2 accessory "${acc.displayName}" color: ${reason}`);
|
|
442
|
+
});
|
|
443
|
+
}
|
|
404
444
|
};
|
|
405
445
|
this.log.info('Starting live event monitoring');
|
|
406
446
|
await this.zc.startEventMonitoring();
|