Exemplo n.º 1
0
 public function getCurrentEnvironmentValue($id)
 {
     $currentLight = Light::where("sensor_id", "=", $id)->orderBy('created_at', 'desc')->first();
     $currentSoilMoisture = SoilMoisture::where("sensor_id", "=", $id)->orderBy('created_at', 'desc')->first();
     $currentTemperature = Temperature::where("sensor_id", "=", $id)->orderBy('created_at', 'desc')->first();
     $currentAirHumidity = Humidity::where("sensor_id", "=", $id)->orderBy('created_at', 'desc')->first();
     $json = array();
     $json[0] = $currentLight;
     $json[1] = $currentTemperature;
     $json[2] = $currentAirHumidity;
     $json[3] = $currentSoilMoisture;
     return $json;
 }
Exemplo n.º 2
0
     }
     if ($notificationCheck->maxSoilMoisture != 0 && $notificationCheck->maxSoilMoisture < $soil) {
         $notificationController->sentMonitorNotification("Alert!! : " . $id . " reach maximum soil moisture >" . $notificationCheck->maxSoilMoisture, $id);
     }
     if ($notificationCheck->minLux != 0 && $notificationCheck->minLux > $humid) {
         $notificationController->sentMonitorNotification("Alert!! : " . $id . " reach minimum light <" . $notificationCheck->minLux . " lux", $id);
     }
     if ($notificationCheck->maxLux != 0 && $notificationCheck->maxLux < $humid) {
         $notificationController->sentMonitorNotification("Alert!! : " . $id . " reach maximum light >" . $notificationCheck->maxLux . " lux", $id);
     }
 }
 if ($checkHourly == 6) {
     $lightMin = Light::where('sensor_id', '=', $SensorPrimaryKey)->min('luxValue');
     $lightAverage = Light::where('sensor_id', '=', $SensorPrimaryKey)->avg('luxValue');
     $lightMax = Light::where('sensor_id', '=', $SensorPrimaryKey)->max('luxValue');
     Light::where('sensor_id', 'like', $SensorPrimaryKey)->delete();
     $temperatureMin = Temperature::where('sensor_id', '=', $SensorPrimaryKey)->min('celsiusValue');
     $temperatureAverage = Temperature::where('sensor_id', '=', $SensorPrimaryKey)->avg('celsiusValue');
     $temperatureMax = Temperature::where('sensor_id', '=', $SensorPrimaryKey)->max('celsiusValue');
     Temperature::where('sensor_id', 'like', $SensorPrimaryKey)->delete();
     $humidityMin = Humidity::where('sensor_id', '=', $SensorPrimaryKey)->min('humidityPercentage');
     $humidityAverage = Humidity::where('sensor_id', '=', $SensorPrimaryKey)->avg('humidityPercentage');
     $humidityMax = Humidity::where('sensor_id', '=', $SensorPrimaryKey)->max('humidityPercentage');
     Humidity::where('sensor_id', 'like', $SensorPrimaryKey)->delete();
     $soilMoistureMin = SoilMoisture::where('sensor_id', '=', $SensorPrimaryKey)->min('soilValue');
     $soilMoistureAverage = SoilMoisture::where('sensor_id', '=', $SensorPrimaryKey)->avg('soilValue');
     $soilMoistureMax = SoilMoisture::where('sensor_id', '=', $SensorPrimaryKey)->max('soilValue');
     SoilMoisture::where('sensor_id', 'like', $SensorPrimaryKey)->delete();
     $daily = new Daily();
     $daily->minLight = $lightMin;
     $daily->avgLight = $lightAverage;