public function sendInfo()
 {
     // get the header field "x-monitoring-auth"
     $hashKey = $this->app->getAuthToken();
     // $contentPath = $this->app->getContextPath();
     $sensorList = array();
     $sql = 'SELECT
     sn.group_id, sn.name_id, sn.name, sn.description, sn.icon,
     sc.temperature, sc.humidity, sc.date
   FROM `sensor-names` AS sn
     INNER JOIN `sensor-currents` AS sc ON sn.group_id = sc.group_id AND sn.name_id = sc.name_id
   WHERE sn.rule_id = 1 OR sn.rule_id IN
     (SELECT rule_id
       FROM `sensor-hasher-rules` AS shr
         INNER JOIN `sensor-hasher` AS sh ON shr.hash_key = sh.hash_key AND sh.enabled = \'Y\'
       WHERE shr.hash_key = ?)';
     $pdo = DB::openDatabase($this->app);
     $stmt = $pdo->prepare($sql);
     $stmt->execute(array($hashKey));
     while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) {
         $id = HashService::encode($row['group_id'], $row['name_id']);
         $sensorList[] = array('id' => $id, 'name' => $row['name'], 'description' => $row['description'], 'icon' => $row['icon'], 'temperature' => (int) $row['temperature'], 'humidity' => (int) $row['humidity'], 'date' => $row['date']);
     }
     // build the result object...
     $result = array('status' => Define::RESULT_OKAY, 'sensors' => $sensorList);
     $this->app->sendResult($result);
 }
 public function save($sensor)
 {
     $data = $this->prepareSensorData($sensor);
     /** @var \PDO $pdo */
     $pdo = DB::openDatabase($this->app);
     // update the current temperature and humidity
     $this->updateSensor($pdo, $data);
     // insert the sensor data
     $id = $this->insertSensor($pdo, $data);
     $result = array('status' => Define::RESULT_OKAY, 'id' => $id);
     $this->app->sendResult($result);
 }