Exemplo n.º 1
0
/**
 * Prints a list of devices
 *
 */
function printDevices($devices, $title = NULL)
{
    if (!is_null($devices) && is_array($devices) && !empty($devices)) {
        if (!is_null($title)) {
            printMessageWithBorder($title);
        }
        foreach ($devices as $device) {
            printWSBasicInfo($device);
        }
    }
}
Exemplo n.º 2
0
function printCameraInformation(Netatmo\Objects\NACamera $camera)
{
    !is_null($camera->getName()) ? printMessageWithBorder($camera->getName()) : printMessageWithBorder($camera->getId());
    echo "id: " . $camera->getId() . "\n";
    echo "Monitoring status: " . $camera->getVar(Netatmo\Common\NACameraInfo::CI_STATUS) . "\n";
    echo "SD card status: " . $camera->getVar(Netatmo\Common\NACameraInfo::CI_SD_STATUS) . "\n";
    echo "Power status: " . $camera->getVar(Netatmo\Common\NACameraInfo::CI_ALIM_STATUS) . "\n";
    if ($camera->getGlobalStatus()) {
        $globalStatus = "OK";
    } else {
        $globalStatus = "NOK";
    }
    echo "Global Status: " . $globalStatus . "\n";
}
        handleError("An error occured while setting a manual setpoint " . $ex->getMessage() . "\n");
    }
    //Finally set back to the intial mode
    try {
        switch ($initialMode) {
            case "away":
                $client->setToAwayMode($device["_id"], $module_id, $initialEndtime);
                break;
            case "manual":
                $client->setToManualMode($device["_id"], $module_id, $initialTemp, $initialEndtime);
                break;
            case "program":
                $client->setToProgramMode($device["_id"], $module_id);
                break;
            case "frost_guard":
                $client->setToFrostGuardMode($device["_id"], $module_id, $initialEndtime);
                break;
            case "off":
                $client->turnOff($device["_id"], $module_id);
                break;
            case "max":
                $client->setToMaxMode($device["_id"], $module_id, $initialEndtime);
                break;
        }
        printMessageWithBorder("Back to original mode: " . $initialMode);
        sleep(20);
        //wait for thermostat synchronization to make sure, it's back in its initial mode
    } catch (NAClientException $ex) {
        handleError("An error occured while setting back the initial mode: " . $ex->getMessage() . " \n");
    }
}
        handleError("An error occured while retrieving last event of " . $person->getPseudo() . "\n");
    }
    if (!empty($eventList)) {
        printMessageWithBorder("Events until last time " . $person->getPseudo() . " was seen");
        foreach ($eventList as $event) {
            printEventInformation($event, $tz);
        }
        // let's retrieve 10 events that happens right before last event of the given person
        $lastIndex = count($eventList) - 1;
        $lastEvent = $eventList[$lastIndex];
        $event = $eventList[0];
        try {
            $response = $client->getNextEvents($home->getId(), $lastEvent->getId(), 10);
            $data = $response->getData();
        } catch (NASDKException $ex) {
            handleError("An error occured while retrieving events: " . $ex->getMessage() . "\n");
        }
        if (!empty($data)) {
            printMessageWithBorder("The 10 events that happened right before " . $person->getPseudo() . " was seen");
            foreach ($data as $event) {
                printEventInformation($event, $tz);
            }
        }
        try {
            printMessageWithBorder("Event's snapshot");
            echo $event->getSnapshot() . "\n";
        } catch (NASDKException $ex) {
            handleError("An error occured while retrieving event's snapshot: " . $ex->getMessage() . "\n");
        }
    }
}