Skip to content

Commit

Permalink
Minor changes
Browse files Browse the repository at this point in the history
### UPDATED
- Zones can now be set up to 999

### ADDED
- Partial keypad/touchpad sensor detection
  • Loading branch information
mrjackyliang committed Dec 19, 2023
1 parent a3cb762 commit bd94cd9
Show file tree
Hide file tree
Showing 8 changed files with 38 additions and 4 deletions.
8 changes: 7 additions & 1 deletion config.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,12 @@
"glass"
]
},
{
"title": "Keypad/Touchpad",
"enum": [
"keypad"
]
},
{
"title": "Motion Sensor / Motion Sensor (Notable Events Only)",
"enum": [
Expand Down Expand Up @@ -208,7 +214,7 @@
"description": "Specify the <strong class=\"font-weight-bold\">exact zone</strong> associated with the sensor you want to add. Double-check the zone to ensure the correct sensor is added.",
"placeholder": "e.g. 99",
"minimum": 1,
"maximum": 99
"maximum": 999
}
}
},
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "homebridge-adt-pulse",
"displayName": "Homebridge ADT Pulse",
"version": "3.0.0-beta.7",
"version": "3.0.0-beta.8",
"description": "Homebridge security system platform for ADT Pulse",
"exports": "./build/src/index.js",
"type": "module",
Expand Down
22 changes: 21 additions & 1 deletion src/lib/accessory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,9 @@ export class ADTPulseAccessory {
case 'glass':
this.#services.Primary = this.#accessory.getService(service.MotionSensor) ?? this.#accessory.addService(service.MotionSensor);
break;
case 'keypad':
// TODO nothing done here yet
break;
case 'motion':
this.#services.Primary = this.#accessory.getService(service.MotionSensor) ?? this.#accessory.addService(service.MotionSensor);
break;
Expand Down Expand Up @@ -199,6 +202,9 @@ export class ADTPulseAccessory {
this.#services.Primary.getCharacteristic(this.#characteristic.MotionDetected)
.onGet(() => this.getSensorStatus(accessory.context));
break;
case 'keypad':
// TODO nothing done here yet
break;
case 'motion':
this.#services.Primary.getCharacteristic(this.#characteristic.MotionDetected)
.onGet(() => this.getSensorStatus(accessory.context));
Expand Down Expand Up @@ -237,9 +243,20 @@ export class ADTPulseAccessory {
const { name, type, zone } = context;

const sensor = this.#state.data.sensorsStatus.find((sensorStatus) => zone !== null && sensorStatus.name === name && sensorStatus.zone === zone);
const knownSensorTypes = [
'co',
'doorWindow',
'fire',
'flood',
'glass',
'keypad',
'motion',
'panic',
'temperature',
];

// If the sensor is not found or sensor type is invalid.
if (sensor === undefined || !['co', 'doorWindow', 'fire', 'flood', 'glass', 'motion', 'panic', 'temperature'].includes(type)) {
if (sensor === undefined || !knownSensorTypes.includes(type)) {
throw new this.#api.hap.HapStatusError(this.#api.hap.HAPStatus.RESOURCE_DOES_NOT_EXIST);
}

Expand Down Expand Up @@ -285,6 +302,9 @@ export class ADTPulseAccessory {
return true;
}
break;
case 'keypad':
// TODO nothing done here yet
break;
case 'motion':
if (status.includes('No Motion')) {
return false;
Expand Down
1 change: 1 addition & 0 deletions src/lib/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1866,6 +1866,7 @@ export class ADTPulse {
* 'Carbon Monoxide Detector'
* 'Fire (Smoke/Heat) Detector'
* 'Glass Break Detector'
* 'Keypad/Touchpad'
* 'Motion Sensor'
* 'Motion Sensor (Notable Events Only)'
* 'Silent Panic Button/Pendant'
Expand Down
1 change: 1 addition & 0 deletions src/lib/detect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -733,6 +733,7 @@ export async function detectedNewSensorsInformation(sensors: DetectedNewSensorsI
'Carbon Monoxide Detector',
'Fire (Smoke/Heat) Detector',
'Glass Break Detector',
'Keypad/Touchpad',
'Motion Sensor',
'Motion Sensor (Notable Events Only)',
'Silent Panic Button/Pendant',
Expand Down
3 changes: 2 additions & 1 deletion src/lib/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,11 @@ export const platformConfig = z.object({
z.literal('fire'),
z.literal('flood'),
z.literal('glass'),
z.literal('keypad'),
z.literal('motion'),
z.literal('panic'),
z.literal('temperature'),
]),
adtZone: z.number().min(1).max(99),
adtZone: z.number().min(1).max(999),
})).min(1).max(148),
});
3 changes: 3 additions & 0 deletions src/lib/utility.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,9 @@ export function condenseSensorType(sensorType: CondenseSensorTypeSensorType): Co
case 'Glass Break Detector':
condensed = 'glass';
break;
case 'Keypad/Touchpad':
condensed = 'keypad';
break;
case 'Motion Sensor':
case 'Motion Sensor (Notable Events Only)':
condensed = 'motion';
Expand Down
2 changes: 2 additions & 0 deletions src/types/constant.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ export type PluginDeviceType =
| 'flood'
| 'gateway'
| 'glass'
| 'keypad'
| 'motion'
| 'panel'
| 'panic'
Expand Down Expand Up @@ -231,6 +232,7 @@ export type PortalSensorDeviceType =
| 'Carbon Monoxide Detector'
| 'Fire (Smoke/Heat) Detector'
| 'Glass Break Detector'
| 'Keypad/Touchpad'
| 'Motion Sensor'
| 'Motion Sensor (Notable Events Only)'
| 'Silent Panic Button/Pendant'
Expand Down

0 comments on commit bd94cd9

Please sign in to comment.