Ejemplo n.º 1
0
<?php

/**
 * Created by PhpStorm.
 * User: Назар
 * Date: 16.10.2015
 * Time: 19:59
 */
header('Content-Type:application/json');
include '../../../services/OutsideSensorsService.php';
$outside = new OutsideSensorsService();
$temperature = $outside->getTemperature();
print "{\"data\": \"";
print $temperature;
print "\"}";
Ejemplo n.º 2
0
<?php

/**
 * Created by PhpStorm.
 * User: Назар
 * Date: 16.10.2015
 * Time: 19:59
 */
header('Content-Type:application/json');
include '../../../services/OutsideSensorsService.php';
$outside = new OutsideSensorsService();
$humidity = $outside->getHumidity();
print "{\"data\": \"{$humidity}\"}";
<?php

/**
* run this script in cron every 1-5 minutest
*/
$condition = false;
require '../services/NotificationService.php';
require_once '../services/InsideSensorsService.php';
require_once '../services/OutsideSensorsService.php';
$notifications = new NotificationService();
$inside = new InsideSensorsService();
$insideT = $inside->getTemperature();
$insideH = $inside->getHumidity();
$outside = new OutsideSensorsService();
$outsideT = $outside->getTemperature();
$outsideH = $outside->getHumidity();
if ($outsideT === 'NaN' && $outsideH === 'NaN') {
    $condition = true;
}
if ($insideT === 'NaN' && $outsideH === 'NaN') {
    $condition = true;
}
if ($insideH === '0' && !file_exists("arduino.connection.inside.lock")) {
    //send notification
    $notifications->sendNotification('Inside_sensor_is_unconnected');
    $lock = fopen("arduino.connection.lock", "w");
    $date = date("Y-m-d H:i:s");
    fwrite($lock, "arduino locked at {$date} becouse inside sensors isn\\'t connected");
    fclose($lock);
} else {
    if (file_exists("arduino.connection.inside.lock")) {