$action = 1; } $h = 0; $m = 0; $s = 10; echo "setting timer: " . $name . ' -> ' . actionToTxt($action) . " Time=" . sprintf("%02d:%02d:%02d\n", $h, $m, $s); if (!setTimer($mac, $h, $m, $s, $action, $s20Table)) { echo "Set timer succeed\n"; } else { echo "Some problem on set timer\n"; } // //Let us check // while (1) { $timer = checkTimer($mac, $s20Table, $h, $m, $s, $action); $st = checkStatus($mac, $s20Table); if (!$timer) { echo "Timer is off, status = " . actionToTxt($st) . "\n"; break; } else { echo sprintf("%02d:%02d:%02d to => %s, current is %s\n", $h, $m, $s, actionToTxt($action), actionToTxt($st)); } ob_flush(); sleep(2); } } // // Test automatic switch off after on first device. // echo "\n\n\nTesting automatic switch off after on using switch " . $name . "\n";
function checkTimerSec($mac, $s20Table, &$act) { // // Check if countdown timer of device with mac $mac is set. // returns the number of seconds and updates value action // with 0 (Off) or 1 (On). // If no timer is programmed, returns 0. // if (checkTimer($mac, $s20Table, $h, $m, $s, $action)) { $act = $action; $seconds = $h * 3600 + $m * 60 + $s; } else { $act = $seconds = 0; } return $seconds; }