homebridge-zencontrol-tpi 1.1.0-next.0 → 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 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/README.md CHANGED
@@ -4,6 +4,17 @@ A plugin for Homebridge that enables control over lights using Zencontrol Third
4
4
 
5
5
  ## Testing
6
6
 
7
+ ## Contributing
8
+
9
+ This project uses `npm` and [`changesets`](https://github.com/changesets/changesets) for its build process.
10
+
11
+ When committing a change, please create a changeset:
12
+
13
+ ```shell
14
+ npm exec changeset
15
+ git commit -a "feat: ..."
16
+ ```
17
+
7
18
  ## Releasing
8
19
 
9
20
  ### Pre-release
@@ -11,7 +22,7 @@ A plugin for Homebridge that enables control over lights using Zencontrol Third
11
22
  To enter pre-release mode:
12
23
 
13
24
  ```shell
14
- pnpm changeset pre enter next
25
+ npm exec changeset pre enter next
15
26
  git add .changeset/pre.json
16
27
  git commit -m "publish: enter prerelease"
17
28
  ```
@@ -19,7 +30,16 @@ git commit -m "publish: enter prerelease"
19
30
  Once you've made changes and committed one or more changesets; bump the version:
20
31
 
21
32
  ```shell
22
- pnpm changeset version
33
+ npm run release:version
23
34
  git commit -a -m "publish: prerelease"
24
- pnpm changeset publish
35
+ npm run release
36
+ ```
37
+
38
+ To exit pre-release mode:
39
+
40
+ ```shell
41
+ npm exec changeset pre exit
42
+ npm run release:version
43
+ git commit -a -m "publish: release"
44
+ npm run release
25
45
  ```
@@ -53,6 +53,12 @@
53
53
  }
54
54
  }
55
55
  },
56
+ "co2AbnormalLevel": {
57
+ "type": "integer",
58
+ "title": "CO2 Abnormal Level",
59
+ "required": false,
60
+ "default": 1000
61
+ },
56
62
  "debug": {
57
63
  "type": "boolean",
58
64
  "title": "Debug logging",
@@ -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
@@ -140,7 +141,7 @@ export class ZencontrolTPIPlatform {
140
141
  }));
141
142
  for (let variable = 0; variable < ZenConst.MAX_SYSVAR; variable++) {
142
143
  promises.push(this.zc.querySystemVariableName(controller, variable).then(async (label) => {
143
- if (label && label.toLocaleLowerCase().indexOf('temperature') !== -1) {
144
+ if (label && label.toLocaleLowerCase().endsWith(' temperature')) {
144
145
  let value = await this.zc.querySystemVariable(controller, variable);
145
146
  /* This API doesn't respect magnitude so we have to guess */
146
147
  if (value !== null) {
@@ -148,19 +149,44 @@ export class ZencontrolTPIPlatform {
148
149
  value /= 10;
149
150
  }
150
151
  }
151
- const acc = this.addTemperatureAccessory({ address: systemVariableToAddressString(controller, variable), label, model: 'System Variable', serial: `SV ${controller.id}.${variable}` });
152
+ const acc = this.addTemperatureAccessory({
153
+ address: systemVariableToAddressString(controller, variable),
154
+ label: label.substring(0, label.length - ' temperature'.length),
155
+ model: 'System Variable',
156
+ serial: `SV ${controller.id}.${variable}`,
157
+ });
152
158
  acc.receiveTemperature(value);
153
159
  }
154
- else if (label && label.toLocaleLowerCase().indexOf('humidity') !== -1) {
160
+ else if (label && label.toLocaleLowerCase().endsWith(' humidity')) {
155
161
  const value = await this.zc.querySystemVariable(controller, variable);
156
- const acc = this.addHumidityAccessory({ address: systemVariableToAddressString(controller, variable), label, model: 'System Variable', serial: `SV ${controller.id}.${variable}` });
162
+ const acc = this.addHumidityAccessory({
163
+ address: systemVariableToAddressString(controller, variable),
164
+ label: label.substring(0, label.length - ' humidity'.length),
165
+ model: 'System Variable',
166
+ serial: `SV ${controller.id}.${variable}`,
167
+ });
157
168
  acc.receiveHumidity(value);
158
169
  }
159
- else if (label && label.toLocaleLowerCase().indexOf('lux') !== -1) {
170
+ else if (label && label.toLocaleLowerCase().endsWith(' lux')) {
160
171
  const value = await this.zc.querySystemVariable(controller, variable);
161
- const acc = this.addLuxAccessory({ address: systemVariableToAddressString(controller, variable), label, model: 'System Variable', serial: `SV ${controller.id}.${variable}` });
172
+ const acc = this.addLuxAccessory({
173
+ address: systemVariableToAddressString(controller, variable),
174
+ label: label.substring(0, label.length - ' lux'.length),
175
+ model: 'System Variable',
176
+ serial: `SV ${controller.id}.${variable}`,
177
+ });
162
178
  acc.receiveLux(value);
163
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
+ }
164
190
  }));
165
191
  }
166
192
  }
@@ -306,6 +332,25 @@ export class ZencontrolTPIPlatform {
306
332
  this.discoveredCacheUUIDs.push(uuid);
307
333
  return acc;
308
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
+ }
309
354
  setupAccessory(accessory, { address, label, model, serial }) {
310
355
  accessory.context.address = address;
311
356
  accessory.context.model = model;
@@ -381,11 +426,21 @@ export class ZencontrolTPIPlatform {
381
426
  this.log.warn(`Failed to update temperature accessory "${acc.displayName}" color: ${reason}`);
382
427
  });
383
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
+ }
384
434
  else if (acc instanceof ZencontrolLuxPlatformAccessory) {
385
435
  acc.receiveLux(value).catch((reason) => {
386
436
  this.log.warn(`Failed to update lux accessory "${acc.displayName}" color: ${reason}`);
387
437
  });
388
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
+ }
389
444
  };
390
445
  this.log.info('Starting live event monitoring');
391
446
  await this.zc.startEventMonitoring();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "homebridge-zencontrol-tpi",
3
- "version": "1.1.0-next.0",
3
+ "version": "1.1.0-next.2",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -24,16 +24,16 @@
24
24
  "author": "Karl von Randow",
25
25
  "license": "Apache-2.0",
26
26
  "devDependencies": {
27
- "@changesets/cli": "^2.29.7",
28
- "@eslint/js": "^9.36.0",
29
- "@types/node": "^24.5.2",
30
- "eslint": "^9.36.0",
31
- "homebridge": "^1.11.0",
32
- "typescript": "^5.9.2",
33
- "typescript-eslint": "^8.44.1"
27
+ "@changesets/cli": "^2.29.8",
28
+ "@eslint/js": "^9.39.2",
29
+ "@types/node": "^25.0.3",
30
+ "eslint": "^9.39.2",
31
+ "homebridge": "^1.11.1",
32
+ "typescript": "^5.9.3",
33
+ "typescript-eslint": "^8.51.0"
34
34
  },
35
35
  "dependencies": {
36
- "homebridge-lib": "^7.1.8",
36
+ "homebridge-lib": "^7.2.0",
37
37
  "zencontrol-tpi-node": "^1.0.0"
38
38
  },
39
39
  "publishConfig": {