generated from homebridge/homebridge-plugin-template
-
-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
46dbd07
commit bf4b05f
Showing
2 changed files
with
32 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { BasicAccessory } from '../interfaces'; | ||
import { ExposesEntryWithBinaryProperty, ExposesEntryWithProperty } from '../../z2mModels'; | ||
import { hap } from '../../hap'; | ||
import { BinarySensorHandler } from './binary'; | ||
|
||
export class MovingSensorHandler extends BinarySensorHandler { | ||
public static readonly exposesName: string = 'moving'; | ||
|
||
constructor(expose: ExposesEntryWithProperty, otherExposes: ExposesEntryWithBinaryProperty[], accessory: BasicAccessory) { | ||
super( | ||
accessory, | ||
expose as ExposesEntryWithBinaryProperty, | ||
otherExposes, | ||
MovingSensorHandler.generateIdentifier, | ||
'Motion Sensor (moving)', | ||
(n, t) => new hap.Service.MotionSensor(n, (MovingSensorHandler.exposesName + ' ' + (t ?? '')).trim()), | ||
hap.Characteristic.MotionDetected, | ||
true, | ||
false | ||
); | ||
} | ||
|
||
static generateIdentifier(endpoint: string | undefined) { | ||
let identifier = MovingSensorHandler.exposesName + '_' + hap.Service.MotionSensor.UUID; | ||
if (endpoint !== undefined) { | ||
identifier += '_' + endpoint.trim(); | ||
} | ||
return identifier; | ||
} | ||
} |