private async Task <SoilHumidityLogEntry> RetrieveSoilHumidityLogEntryFromDevice(DeviceConfiguration deviceConfig, WateringLocation wateringLocation) { bool success; double soilHumidityWateringArea = 0; try { soilHumidityWateringArea = await _greenHouseSparkDeviceService.RequestCurrentSoilMoisturePercentage(deviceConfig, wateringLocation); success = true; } catch (Exception e) { success = false; //Todo: log this error } if (success) { var soilHumidityLogEntry = new SoilHumidityLogEntry { LogDateUtc = DateTime.UtcNow, WateringLocation = wateringLocation, PercentageOfHumidity = soilHumidityWateringArea }; return(soilHumidityLogEntry); } else { return(null); } }
private async void RetrieveValuesFromSparkDevice(DeviceConfiguration deviceConfig) { AirHumidityLogEntry airAirHumidityLogEntry = await RetrieveAirHumidityLogEntryFromDevice(deviceConfig); if (airAirHumidityLogEntry != null) { _airHumidityLogDataService.Save(airAirHumidityLogEntry); } SoilHumidityLogEntry soilHumidityLogEntryWateringAreaOne = await RetrieveSoilHumidityLogEntryFromDevice(deviceConfig, WateringLocation.First); if (soilHumidityLogEntryWateringAreaOne != null) { _soilHumidityLogDataServiceService.Save(soilHumidityLogEntryWateringAreaOne); } SoilHumidityLogEntry soilHumidityLogEntryWateringAreaTwo = await RetrieveSoilHumidityLogEntryFromDevice(deviceConfig, WateringLocation.Second); if (soilHumidityLogEntryWateringAreaTwo != null) { _soilHumidityLogDataServiceService.Save(soilHumidityLogEntryWateringAreaTwo); } }