示例#1
0
}
// Some stupid local vars
$v = "";
$oval = true;
// Just init the value
// ----------------------------------------------------------------------------------------
// MAIN LOOP DAEMON
//
// Loop forever unless a serious error is found.
//
while ($noError) {
    sleep($interval);
    // Polling all zway devices for their value
    //
    $log->lwrite("------------------- ZWAY DUMP LOOP ----------------------", 0);
    if (false === ($zway_data = zway_dump($ch, 0))) {
        $log->lwrite("ERROR zway_dump", 0);
        // Read All.
        sleep(3);
        continue;
    }
    $zparse = json_decode($zway_data, true);
    $time_now = time();
    $time_start = time() - 24 * 60 * 60;
    // Time minus a day ago
    // First print come statistics
    $log->lwrite("count devices : " . count($zparse['devices']), 2);
    // Including controller
    $log->lwrite("curl messages: " . $curl_msgs . ", errors: " . $curl_errs, 2);
    $dkeys = array_keys($zparse['devices']);
    // Device keyrs, array containing all device id's
示例#2
0
$ch = curl_init();
if ($ch == false) {
    $log->lwrite("curl_init error");
}
// ========================= MAIN MAIN MAIN MAIN MAIN =====================================
$time_now = time();
//$start_time = @date('[d/M/y, H:i:s]'); echo "Start loop at ".$start_time."\n";
// ----------------------------------------------------------------------------------------
// READ DATABASE
//
$lampi_config = load_database();
$dev_config = $lampi_config['devices'];
// ----------------------------------------------------------------------------------------
// ZWAY CONFIG
//
$zway_config = zway_dump($ch, 0);
$zparse = json_decode($zway_config, true);
$log->lwrite("count config: " . count($dev_config), 2);
// $log->lwrite("Dumping zway config:: ".$zway_config."\n");
// ----------------------------------------------------------------------------------------
// LOOP DAEMON
//
for ($i = 0; $i < count($dev_config); $i++) {
    $id = $dev_config[$i]['id'];
    if ($dev_config[$i]['brand'] == "7") {
        //$unit = $dev_config[$i]['unit'];
        $gaddr = $dev_config[$i]['gaddr'];
        $val = $dev_config[$i]['val'];
        $name = $dev_config[$i]['name'];
        $type = $dev_config[$i]['type'];
        $v = "";