From e8f1d8ace385f383128b4659160f884234cd4c5d Mon Sep 17 00:00:00 2001 From: Jacky Liang Date: Tue, 2 Apr 2024 13:31:02 -0400 Subject: [PATCH] Support for new portal version ### UPDATED - In config, `options` and `sensors` now comes with a default option. If the setting was missing due to Homebridge removing an empty option, Zod will enforce an empty array by default (partial credit to @cyberpower678 on issue #141). - Performance improvements for `ignoreSensorProblemStatus` checks. - Parse configuration warning message. ### FIXED - In config, `fingerprint` max length should be "10240" not "5120" (old value). - In config, `sensors` max items should be "147" not "148" due to the allocation for an extra "Alarm Ringing" switch. ### ADDED - Support for "28.0.0-57" portal version. --- config.schema.json | 8 +++----- package.json | 2 +- src/lib/api.ts | 1 + src/lib/items.ts | 2 ++ src/lib/platform.ts | 2 +- src/lib/schema.ts | 4 ++-- src/lib/utility.ts | 10 +++++----- src/types/constant.d.ts | 6 ++++-- 8 files changed, 19 insertions(+), 16 deletions(-) diff --git a/config.schema.json b/config.schema.json index e8267fd..b00b32c 100644 --- a/config.schema.json +++ b/config.schema.json @@ -63,7 +63,7 @@ "description": "After logging in and selecting \"Trust this device\", paste in the device fingerprint generated through the ADT Pulse Device Fingerprint Detector.", "placeholder": "e.g. VGhpc0lzQVNlY3VyZVBhc3N3b3JkMTIzIQ==", "minLength": 1, - "maxLength": 5120 + "maxLength": 10240 }, "mode": { "title": "Operational Mode", @@ -128,7 +128,6 @@ "options": { "title": "Advanced Options", "type": "array", - "required": true, "description": "Customize the features of this plugin. Please note these advanced options will disable expected functionality. Only enable them if necessary.", "items": { "type": "string", @@ -141,8 +140,7 @@ "sensors": { "title": "Sensors", "type": "array", - "required": true, - "description": "Define your sensors here. Sensors include devices like \"Door/Window Sensor\" or \"Motion Sensor\". Please note that Z-Wave accessories are not supported. A maximum of 148 sensors can be added (the plugin reserves 2 accessories for the gateway and security panel).", + "description": "Define your sensors here. Sensors include devices like \"Door/Window Sensor\" or \"Motion Sensor\". Please note that Z-Wave accessories are not supported. A maximum of 147 sensors can be added (3 slots are reserved for the gateway, security panel, and alarm ringing switch).", "items": { "type": "object", "properties": { @@ -238,7 +236,7 @@ } }, "minItems": 0, - "maxItems": 148 + "maxItems": 147 } } }, diff --git a/package.json b/package.json index 448443c..7f70204 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "homebridge-adt-pulse", "displayName": "Homebridge ADT Pulse", - "version": "3.2.15", + "version": "3.3.0", "description": "Homebridge security system platform for ADT Pulse", "main": "./build/index.js", "exports": "./build/index.js", diff --git a/src/lib/api.ts b/src/lib/api.ts index bd1183d..a2d79d0 100644 --- a/src/lib/api.ts +++ b/src/lib/api.ts @@ -369,6 +369,7 @@ export class ADTPulse { * '25.0.0-21' * '26.0.0-32' * '27.0.0-140' + * '28.0.0-57' * * @since 1.0.0 */ diff --git a/src/lib/items.ts b/src/lib/items.ts index b0b975d..9dfc069 100644 --- a/src/lib/items.ts +++ b/src/lib/items.ts @@ -533,6 +533,7 @@ export const itemDoSubmitHandlerRelativeUrls: ItemDoSubmitHandlerRelativeUrls = '/myhome/25.0.0-21/quickcontrol/serv/RunRRACommand', '/myhome/26.0.0-32/quickcontrol/serv/RunRRACommand', '/myhome/27.0.0-140/quickcontrol/serv/RunRRACommand', + '/myhome/28.0.0-57/quickcontrol/serv/RunRRACommand', ]; /** @@ -725,6 +726,7 @@ export const itemPortalVersions: ItemPortalVersions = [ '25.0.0-21', '26.0.0-32', '27.0.0-140', + '28.0.0-57', ]; /** diff --git a/src/lib/platform.ts b/src/lib/platform.ts index 0c53520..2990799 100644 --- a/src/lib/platform.ts +++ b/src/lib/platform.ts @@ -236,7 +236,7 @@ export class ADTPulsePlatform implements ADTPulsePlatformPlugin { // Check for a valid platform configuration before initializing. if (!parsedConfig.success) { this.#log.error('Plugin is unable to initialize due to an invalid platform configuration.'); - this.#log.warn('If you just upgraded from "v2 to v3" or from "v3 to v3.1", please update your configuration.'); + this.#log.warn('If you just upgraded from v2 to v3, the configuration has been changed. Please re-configure your plugin.'); this.#log.warn('Carefully observe the error below. The answer you are looking for is there.'); stackTracer('zod-error', parsedConfig.error.errors); diff --git a/src/lib/schema.ts b/src/lib/schema.ts index 0cdb517..6713a18 100644 --- a/src/lib/schema.ts +++ b/src/lib/schema.ts @@ -29,7 +29,7 @@ export const platformConfig = z.object({ options: z.array(z.union([ z.literal('disableAlarmRingingSwitch'), z.literal('ignoreSensorProblemStatus'), - ])), + ])).default([]), sensors: z.array(z.object({ name: z.string().min(1).max(50).optional(), adtName: z.string().min(1).max(100), @@ -45,5 +45,5 @@ export const platformConfig = z.object({ z.literal('temperature'), ]), adtZone: z.number().min(1).max(99), - })).min(0).max(148), + })).min(0).max(148).default([]), }); diff --git a/src/lib/utility.ts b/src/lib/utility.ts index 92a52a4..9f54023 100644 --- a/src/lib/utility.ts +++ b/src/lib/utility.ts @@ -890,7 +890,7 @@ export function getAccessoryCategory(deviceCategory: GetAccessoryCategoryDeviceC * @since 1.0.0 */ export function getDetectReportUrl(): GetDetectReportUrlReturns { - return 'https://7usev98x5actrwn6qb2m.ntfy.mrjackyliang.com'; + return 'https://f4ds5bzvu2c2tmxc47bh.ntfy.mrjackyliang.com'; } /** @@ -995,14 +995,14 @@ export function isPanelAlarmActive(panelStatuses: IsPanelAlarmActivePanelStatuse || panelStatuses.includes('Carbon Monoxide Alarm') || panelStatuses.includes('FIRE ALARM') || ( - panelStatuses.includes('Sensor Problem') + !ignoreSensorProblem + && panelStatuses.includes('Sensor Problem') && hasDisarmedTroubleButtons - && !ignoreSensorProblem ) || ( - panelStatuses.includes('Sensor Problems') + !ignoreSensorProblem + && panelStatuses.includes('Sensor Problems') && hasDisarmedTroubleButtons - && !ignoreSensorProblem ) || panelStatuses.includes('Uncleared Alarm') || panelStatuses.includes('WATER ALARM') diff --git a/src/types/constant.d.ts b/src/types/constant.d.ts index 00b4231..dea04f0 100644 --- a/src/types/constant.d.ts +++ b/src/types/constant.d.ts @@ -213,7 +213,8 @@ export type PortalPanelForceArmButtonRelativeUrl = | '/myhome/24.0.0-117/quickcontrol/serv/RunRRACommand' | '/myhome/25.0.0-21/quickcontrol/serv/RunRRACommand' | '/myhome/26.0.0-32/quickcontrol/serv/RunRRACommand' - | '/myhome/27.0.0-140/quickcontrol/serv/RunRRACommand'; + | '/myhome/27.0.0-140/quickcontrol/serv/RunRRACommand' + | '/myhome/28.0.0-57/quickcontrol/serv/RunRRACommand'; /** * Portal panel note. @@ -362,4 +363,5 @@ export type PortalVersion = | '24.0.0-117' | '25.0.0-21' | '26.0.0-32' - | '27.0.0-140'; + | '27.0.0-140' + | '28.0.0-57';