Пример #1
0
        private async Task <Nvr.Status> GetNvrStatus(UnifiVideoClient nvrClient, NvrConfig nvrConfig)
        {
            if (await nvrClient.Login(nvrConfig.UserName, nvrConfig.Password))
            {
                var status = await nvrClient.GetStatus();

                _logger.LogInformation($"Retrieved status from Unifi Video and found {status?.Cameras?.Count()} camera's.");
                return(status);
            }
            else
            {
                _logger.LogError("Failed to log on to the NVR");
            }
            return(null);
        }
Пример #2
0
        private async Task UpdateCameraRecordingState(UnifiVideoClient nvrClient, Nvr.Status status, PresenceRecordingSettings presenceConfig, bool shouldRecord)
        {
            foreach (var cameraId in presenceConfig.CameraIdsToSetToMotionRecordingIfNoOneIsPresent)
            {
                var camera            = status.Cameras.FirstOrDefault(p => p.Id == cameraId);
                var cameraDescription = GetCameraDescription(camera);

                _logger.LogInformation($"Camera {cameraDescription} is recording motion: {camera.RecordingSettings.MotionRecordEnabled}");
                if (camera != null && camera.RecordingSettings?.MotionRecordEnabled != shouldRecord)
                {
                    _logger.LogInformation($"Updating camera {cameraDescription}");
                    camera.RecordingSettings.MotionRecordEnabled = camera.EnableStatusLed = camera.LedFaceAlwaysOnWhenManaged = shouldRecord;
                    await nvrClient.UpdateCamera(camera);
                }
                else
                {
                    _logger.LogInformation($"Update for camera ({cameraDescription}) not required.");
                }
            }
        }