homebridge-unifi-protect
Version:
Homebridge UniFi Protect plugin providing complete HomeKit integration for the entire UniFi Protect ecosystem with full support for most features including HomeKit Secure Video, multiple controllers, blazing fast performance, and much more.
16 lines • 772 B
JavaScript
// Compute a doorbell's effective chime volume: the mean of the per-doorbell ring volume across every chime assigned to it (a chime can serve multiple doorbells), or 0
// when none is assigned. Pure over config records so the read-through getter and the volume observer share one definition of "this doorbell's volume".
export const chimeVolumeFor = (chimes, cameraId) => {
let total = 0;
let count = 0;
for (const chime of chimes) {
const ring = chime.cameraIds.includes(cameraId) ? chime.ringSettings.find(setting => setting.cameraId === cameraId) : undefined;
if (!ring) {
continue;
}
total += ring.volume;
count++;
}
return count ? (total / count) : 0;
};
//# sourceMappingURL=chime-volume.js.map