public function timerAction() { $res = "noAction"; require_once 'models/homeModel.php'; $model = new homeModel(); // get timers $devices = $model->getDeviceTimer(); $current_time = time(); foreach ($devices as $device) { $diff_sec = $current_time - $device['timer_time']; // 30 minutes if ($diff_sec > 60 * 30) { for ($x = 0; $x <= 3; $x++) { $this->execCommand($device['letter'], $device['code'], "0"); usleep(250000); } $res = $model->setDeviceStatus($device['id'], 0); } } echo $res; }