homebridge#HAP TypeScript Examples
The following examples show how to use
homebridge#HAP.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: accessory.ts From homebridge-nest-cam with GNU General Public License v3.0 | 6 votes |
constructor(accessory: PlatformAccessory, camera: NestCam, config: PlatformConfig, log: Logging, hap: HAP) {
this.accessory = accessory;
this.camera = camera;
this.config = config;
this.log = log;
this.hap = hap;
// Setup events
camera.on(NestCamEvents.CAMERA_STATE_CHANGED, (value: boolean) => {
const service = this.accessory.getService(`${this.accessory.displayName} Streaming`);
service && service.updateCharacteristic(this.hap.Characteristic.On, value);
});
camera.on(NestCamEvents.CHIME_STATE_CHANGED, (value: boolean) => {
const service = this.accessory.getService(`${this.accessory.displayName} Chime`);
service && service.updateCharacteristic(this.hap.Characteristic.On, value);
});
camera.on(NestCamEvents.CHIME_ASSIST_STATE_CHANGED, (value: boolean) => {
const service = this.accessory.getService(`${this.accessory.displayName} Announcements`);
service && service.updateCharacteristic(this.hap.Characteristic.On, value);
});
camera.on(NestCamEvents.AUDIO_STATE_CHANGED, (value: boolean) => {
const service = this.accessory.getService(`${this.accessory.displayName} Audio`);
service && service.updateCharacteristic(this.hap.Characteristic.On, value);
});
camera.on(NestCamEvents.MOTION_DETECTED, (state: boolean, alertTypes: Array<string>) => {
this.setMotion(state, alertTypes);
});
camera.on(NestCamEvents.DOORBELL_RANG, () => {
this.setDoorbell();
});
}
Example #2
Source File: streaming-delegate.ts From homebridge-nest-cam with GNU General Public License v3.0 | 6 votes |
constructor(hap: HAP, camera: NestCam, config: NestConfig, log: Logging) {
this.hap = hap;
this.log = log;
this.config = config;
this.camera = camera;
this.customFfmpeg = config.options?.pathToFfmpeg;
this.videoProcessor = this.customFfmpeg || pathToFfmpeg || 'ffmpeg';
// Get the correct video codec
getCodecsOutput(this.videoProcessor)
.then((output) => {
const codec = config.options?.ffmpegCodec;
if (codec === 'copy' || (codec && output.includes(codec))) {
this.ffmpegCodec = codec;
} else {
this.log.error(`Unknown video codec ${codec}. Defaulting to libx264.`);
}
this.ffmpegSupportsLibfdk_acc = output.includes('libfdk_aac');
this.ffmpegSupportsLibspeex = output.includes('libspeex');
})
.catch(() => {
// skip
});
// Check if ffmpeg is installed
isFfmpegInstalled(this.videoProcessor)
.then((installed) => {
this.ffmpegInstalled = installed;
})
.catch(() => {
// skip
});
}
Example #3
Source File: index.ts From homebridge-fordpass with GNU General Public License v3.0 | 5 votes |
hap: HAP
Example #4
Source File: accessory.ts From homebridge-nest-cam with GNU General Public License v3.0 | 5 votes |
private readonly hap: HAP;
Example #5
Source File: index.ts From homebridge-nest-cam with GNU General Public License v3.0 | 5 votes |
hap: HAP
Example #6
Source File: streaming-delegate.ts From homebridge-nest-cam with GNU General Public License v3.0 | 5 votes |
private readonly hap: HAP;
Example #7
Source File: index.ts From homebridge-philips-air with BSD 2-Clause "Simplified" License | 5 votes |
hap: HAP
Example #8
Source File: index.ts From homebridge-electrolux-wellbeing with Apache License 2.0 | 5 votes |
hap: HAP
Example #9
Source File: new-streaming-delegate.ts From homebridge-plugin-eufy-security with Apache License 2.0 | 5 votes |
private readonly hap: HAP;
Example #10
Source File: wled-accessory.ts From homebridge-simple-wled with ISC License | 5 votes |
private hap: HAP;
Example #11
Source File: streamingDelegate.ts From homebridge-eufy-security with Apache License 2.0 | 5 votes |
constructor(platform: EufySecurityPlatform, device: Camera, cameraConfig: CameraConfig, api: API, hap: HAP) { // eslint-disable-line @typescript-eslint/explicit-module-boundary-types
this.log = platform.log;
this.hap = hap;
this.device = device;
this.cameraName = device.getName()!;
this.unbridge = false;
this.videoConfig = cameraConfig.videoConfig!;
this.videoProcessor = ffmpegPath || 'ffmpeg';
api.on(APIEvent.SHUTDOWN, () => {
for (const session in this.ongoingSessions) {
this.stopStream(session);
}
});
const options: CameraControllerOptions = {
cameraStreamCount: this.videoConfig.maxStreams || 2, // HomeKit requires at least 2 streams, but 1 is also just fine
delegate: this,
streamingOptions: {
supportedCryptoSuites: [hap.SRTPCryptoSuites.AES_CM_128_HMAC_SHA1_80],
video: {
resolutions: [
[320, 180, 30],
[320, 240, 15], // Apple Watch requires this configuration
[320, 240, 30],
[480, 270, 30],
[480, 360, 30],
[640, 360, 30],
[640, 480, 30],
[1280, 720, 30],
[1280, 960, 30],
[1920, 1080, 30],
[1600, 1200, 30]
],
codec: {
profiles: [hap.H264Profile.BASELINE, hap.H264Profile.MAIN, hap.H264Profile.HIGH],
levels: [hap.H264Level.LEVEL3_1, hap.H264Level.LEVEL3_2, hap.H264Level.LEVEL4_0]
}
},
audio: {
twoWayAudio: !!this.videoConfig.returnAudioTarget,
codecs: [
{
type: AudioStreamingCodecType.AAC_ELD,
samplerate: AudioStreamingSamplerate.KHZ_16
/*type: AudioStreamingCodecType.OPUS,
samplerate: AudioStreamingSamplerate.KHZ_24*/
}
]
}
}
};
this.controller = new hap.CameraController(options);
}
Example #12
Source File: streamingDelegate.ts From homebridge-eufy-security with Apache License 2.0 | 5 votes |
private readonly hap: HAP;