homebridge-tydom 0.32.1 → 0.32.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/dist/index.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { n as PLUGIN_NAME, t as PLATFORM_NAME } from "./env-B2-Dw8C2.mjs";
|
|
2
2
|
//#region src/index.ts
|
|
3
3
|
process.setSourceMapsEnabled(true);
|
|
4
|
-
const { default: TydomPlatform } = await import("./platform-
|
|
4
|
+
const { default: TydomPlatform } = await import("./platform-CJBHeITb.mjs");
|
|
5
5
|
var src_default = (homebridge) => {
|
|
6
6
|
homebridge.registerPlatform(PLUGIN_NAME, PLATFORM_NAME, TydomPlatform);
|
|
7
7
|
};
|
|
@@ -4381,19 +4381,28 @@ const isZoneArmed = (alarmData, zoneProp) => {
|
|
|
4381
4381
|
if (alarmMode === "ON") return true;
|
|
4382
4382
|
return alarmData.find((prop) => prop.name === zoneProp)?.value === "ON";
|
|
4383
4383
|
};
|
|
4384
|
+
/**
|
|
4385
|
+
* The arming mode a data snapshot describes, ignoring whether the siren is on.
|
|
4386
|
+
*
|
|
4387
|
+
* This is what `SecuritySystemTargetState` asks for, and the reason it cannot
|
|
4388
|
+
* share `getStateForAlarmData`: the target has no `ALARM_TRIGGERED`, so the
|
|
4389
|
+
* return type excludes it and HAP can never be handed a value it would reject.
|
|
4390
|
+
*/
|
|
4391
|
+
const getTargetStateForAlarmData = (alarmData, aliases, settings) => {
|
|
4392
|
+
const alarmMode = alarmData.find((prop) => prop.name === "alarmMode")?.value;
|
|
4393
|
+
if (alarmMode === "ON") return ALARM_STATE.AWAY_ARM;
|
|
4394
|
+
if (typeof alarmMode === "string" && ["ZONE", "PART"].includes(alarmMode)) return getStateForActiveZones(getActiveZones(alarmData, settings), aliases);
|
|
4395
|
+
return ALARM_STATE.DISARMED;
|
|
4396
|
+
};
|
|
4384
4397
|
/** The HomeKit state for a full alarm data snapshot. */
|
|
4385
4398
|
const getStateForAlarmData = (alarmData, aliases, settings) => {
|
|
4386
|
-
const
|
|
4387
|
-
const alarmState = find("alarmState");
|
|
4388
|
-
const alarmMode = find("alarmMode");
|
|
4399
|
+
const alarmState = alarmData.find((prop) => prop.name === "alarmState")?.value;
|
|
4389
4400
|
if (typeof alarmState === "string" && [
|
|
4390
4401
|
"DELAYED",
|
|
4391
4402
|
"ON",
|
|
4392
4403
|
"QUIET"
|
|
4393
4404
|
].includes(alarmState)) return ALARM_STATE.ALARM_TRIGGERED;
|
|
4394
|
-
|
|
4395
|
-
if (typeof alarmMode === "string" && ["ZONE", "PART"].includes(alarmMode)) return getStateForActiveZones(getActiveZones(alarmData, settings), aliases);
|
|
4396
|
-
return ALARM_STATE.DISARMED;
|
|
4405
|
+
return getTargetStateForAlarmData(alarmData, aliases, settings);
|
|
4397
4406
|
};
|
|
4398
4407
|
//#endregion
|
|
4399
4408
|
//#region src/accessories/security-system-accessory.ts
|
|
@@ -4449,7 +4458,7 @@ var SecuritySystemAccessory = class extends BaseAccessory {
|
|
|
4449
4458
|
});
|
|
4450
4459
|
service.getCharacteristic(SecuritySystemTargetState).onGet(async () => {
|
|
4451
4460
|
debugGet(SecuritySystemTargetState, service);
|
|
4452
|
-
const nextValue = await this.#
|
|
4461
|
+
const nextValue = await this.#targetState();
|
|
4453
4462
|
debugGetResult(SecuritySystemTargetState, service, nextValue);
|
|
4454
4463
|
return nextValue;
|
|
4455
4464
|
}).onSet(async (value) => {
|
|
@@ -4475,6 +4484,17 @@ var SecuritySystemAccessory = class extends BaseAccessory {
|
|
|
4475
4484
|
const data = await this.#read();
|
|
4476
4485
|
return getStateForAlarmData(data, this.#settings.aliases ?? {}, this.#settings);
|
|
4477
4486
|
}
|
|
4487
|
+
/**
|
|
4488
|
+
* The mode the panel is set to, which is what the target characteristic asks.
|
|
4489
|
+
*
|
|
4490
|
+
* Deliberately not `#currentState`: that one answers `ALARM_TRIGGERED` while
|
|
4491
|
+
* the siren is going, and the target has no such value, so HAP rejected it.
|
|
4492
|
+
* A ringing alarm says nothing about what the panel was armed to anyway.
|
|
4493
|
+
*/
|
|
4494
|
+
async #targetState() {
|
|
4495
|
+
const data = await this.#read();
|
|
4496
|
+
return getTargetStateForAlarmData(data, this.#settings.aliases ?? {}, this.#settings);
|
|
4497
|
+
}
|
|
4478
4498
|
async #readZoneLabels() {
|
|
4479
4499
|
if (this.#legacy) {
|
|
4480
4500
|
this.platform.log.warn(`Setting up legacy zones`);
|
|
@@ -4562,11 +4582,15 @@ var SecuritySystemAccessory = class extends BaseAccessory {
|
|
|
4562
4582
|
return;
|
|
4563
4583
|
}
|
|
4564
4584
|
const aliases = this.#settings.aliases ?? {};
|
|
4565
|
-
const
|
|
4566
|
-
|
|
4567
|
-
|
|
4568
|
-
|
|
4585
|
+
const isStay = target === SecuritySystemTargetState.STAY_ARM;
|
|
4586
|
+
const alias = isStay ? "stay" : "night";
|
|
4587
|
+
const targetZones = aliases[alias];
|
|
4588
|
+
if (!Array.isArray(targetZones) || targetZones.length === 0) {
|
|
4589
|
+
this.platform.log.warn(`Cannot arm ${this.name} to ${isStay ? "Home" : "Night"}: no zones are configured for that mode, so nothing was sent and the Home app will report the change as failed. Add {"settings": {"${this.deviceId}": {"aliases": {"${alias}": [1]}}}} listing the zones it should arm, numbered as they are on the panel's keypad.`);
|
|
4590
|
+
return;
|
|
4569
4591
|
}
|
|
4592
|
+
await this.#setZones(targetZones, "ON");
|
|
4593
|
+
if (this.#service) debugSetResult(SecuritySystemTargetState, this.#service, target, "ON");
|
|
4570
4594
|
}
|
|
4571
4595
|
async #setZones(zoneIds, value) {
|
|
4572
4596
|
if (!this.#legacy) {
|
|
@@ -4583,15 +4607,12 @@ var SecuritySystemAccessory = class extends BaseAccessory {
|
|
|
4583
4607
|
});
|
|
4584
4608
|
}
|
|
4585
4609
|
#handleData(updates) {
|
|
4586
|
-
const {
|
|
4610
|
+
const { ContactSensorState, On } = this.platform.Characteristic;
|
|
4587
4611
|
const aliases = this.#settings.aliases ?? {};
|
|
4588
4612
|
for (const { name, value } of updates) {
|
|
4589
4613
|
if (name === "alarmMode") {
|
|
4590
4614
|
const nextValue = value === "OFF" ? ALARM_STATE.DISARMED : value === "ON" ? ALARM_STATE.AWAY_ARM : value === "PART" || value === "ZONE" ? getStateForActiveZones(getActiveZones(updates, this.#settings), aliases) : void 0;
|
|
4591
|
-
if (nextValue !== void 0
|
|
4592
|
-
debugSetUpdate(SecuritySystemCurrentState, this.#service, nextValue);
|
|
4593
|
-
this.#service.updateCharacteristic(SecuritySystemCurrentState, nextValue);
|
|
4594
|
-
}
|
|
4615
|
+
if (nextValue !== void 0) this.#setState(nextValue);
|
|
4595
4616
|
if (value === "OFF") this.#syncZoneSwitches([]);
|
|
4596
4617
|
else if (value === "ON") this.#syncZoneSwitches(null);
|
|
4597
4618
|
continue;
|
|
@@ -4669,11 +4690,22 @@ var SecuritySystemAccessory = class extends BaseAccessory {
|
|
|
4669
4690
|
service.updateCharacteristic(On, nextValue);
|
|
4670
4691
|
}
|
|
4671
4692
|
}
|
|
4693
|
+
/**
|
|
4694
|
+
* Settle both arming characteristics from an authoritative mode.
|
|
4695
|
+
*
|
|
4696
|
+
* The target moves with the current state, so that arming from the panel's
|
|
4697
|
+
* own keypad does not leave HomeKit showing the old mode — a stale target is
|
|
4698
|
+
* what makes "arm away" in the Home app look like it did nothing. The
|
|
4699
|
+
* parameter type excludes `ALARM_TRIGGERED`, so the target can never be
|
|
4700
|
+
* handed a value it would reject.
|
|
4701
|
+
*/
|
|
4672
4702
|
#setState(state) {
|
|
4673
4703
|
if (!this.#service) return;
|
|
4674
|
-
const { SecuritySystemCurrentState } = this.platform.Characteristic;
|
|
4704
|
+
const { SecuritySystemCurrentState, SecuritySystemTargetState } = this.platform.Characteristic;
|
|
4675
4705
|
debugSetUpdate(SecuritySystemCurrentState, this.#service, state);
|
|
4676
4706
|
this.#service.updateCharacteristic(SecuritySystemCurrentState, state);
|
|
4707
|
+
debugSetUpdate(SecuritySystemTargetState, this.#service, state);
|
|
4708
|
+
this.#service.updateCharacteristic(SecuritySystemTargetState, state);
|
|
4677
4709
|
}
|
|
4678
4710
|
};
|
|
4679
4711
|
const createSecuritySystemAccessory = (deps) => {
|
|
@@ -5620,4 +5652,4 @@ var TydomPlatform = class {
|
|
|
5620
5652
|
//#endregion
|
|
5621
5653
|
export { TydomPlatform as default };
|
|
5622
5654
|
|
|
5623
|
-
//# sourceMappingURL=platform-
|
|
5655
|
+
//# sourceMappingURL=platform-CJBHeITb.mjs.map
|