Exemple #1
0
        private async Task <DeviceStatus> GetExactDeviceStatus(Guid deviceId)
        {
            SensorActivity pirActivity = await _movementService.GetSensorStatusAsync(deviceId, SensorType.PIR);

            SensorActivity rangeActivity = await _movementService.GetSensorStatusAsync(deviceId, SensorType.Range);

            TimeSpan expiry = _settingsService.GetSensorActivityExpiry();

            OccupationStatus status = pirActivity.IsActive(expiry) || rangeActivity.IsActive(expiry)
                                      ? OccupationStatus.Occupied
                                      : OccupationStatus.Empty;

            return(new DeviceStatus()
            {
                DeviceInfo = Devices.All.FirstOrDefault(f => f.ID.Equals(deviceId)),
                Status = status,
                LastActivity = GetMinDate(pirActivity?.EntryDate, rangeActivity?.EntryDate)
            });
        }