function remove() { $cron = cron::byClassAndFunction('zwave', 'pull'); if (is_object($cron)) { $cron->remove(); } }
public static function health() { $return = array(); $demon_state = self::deamonRunning(); $return[] = array('test' => __('Démon local', __FILE__), 'result' => $demon_state ? __('OK', __FILE__) : __('NOK', __FILE__), 'advice' => $demon_state ? '' : __('Peut être normal si vous êtes en déporté', __FILE__), 'state' => $demon_state); $version = openzwave::getVersion('openzwave'); $return[] = array('test' => __('Version d\'openzwave', __FILE__), 'result' => $version, 'advice' => $demon_state ? '' : __('Mettez à jour les dépendances', __FILE__), 'state' => version_compare(config::byKey('openzwave_version', 'openzwave'), $version, '<=')); $compilation = openzwave::compilationOk(); $return[] = array('test' => __('Compilation', __FILE__), 'result' => $compilation ? __('OK', __FILE__) : __('NOK', __FILE__), 'advice' => $compilation ? '' : __('Mettez à jour les dépendances', __FILE__), 'state' => $compilation); if (config::byKey('jeeNetwork::mode') == 'master') { $cron = cron::byClassAndFunction('openzwave', 'pull'); $running = false; if (is_object($cron)) { $running = $cron->running(); } $return[] = array('test' => __('Tâche Z-Wave', __FILE__), 'result' => $running ? __('OK', __FILE__) : __('NOK', __FILE__), 'advice' => $running ? '' : __('Allez sur la page du moteur des tâches et vérifiez lancer la tache openzwave::pull', __FILE__), 'state' => $running); foreach (jeeNetwork::byPlugin('openzwave') as $jeeNetwork) { try { $demon_state = $jeeNetwork->sendRawRequest('deamonRunning', array('plugin' => 'openzwave')); } catch (Exception $e) { $demon_state = false; } $return[] = array('test' => __('Démon sur ', __FILE__) . $jeeNetwork->getName(), 'result' => $demon_state ? __('OK', __FILE__) : __('NOK', __FILE__), 'advice' => '', 'state' => $demon_state); $version = $jeeNetwork->sendRawRequest('getVersion', array('plugin' => 'openzwave', 'module' => 'openzwave')); $return[] = array('test' => __('Version d\'openzwave sur ', __FILE__) . $jeeNetwork->getName(), 'result' => $version, 'advice' => $demon_state ? '' : __('Mettez à jour les dépendances', __FILE__), 'state' => version_compare(config::byKey('openzwave_version', 'openzwave'), $version, '<=')); $compilation = $jeeNetwork->sendRawRequest('compilationOk', array('plugin' => 'openzwave')); $return[] = array('test' => __('Compilation sur', __FILE__) . $jeeNetwork->getName(), 'result' => $compilation ? __('OK', __FILE__) : __('NOK', __FILE__), 'advice' => $compilation ? '' : __('Mettez à jour les dépendances', __FILE__), 'state' => $compilation); } } return $return; }
function xpl_remove() { $cron = cron::byClassAndFunction('xpl', 'deamon'); if (is_object($cron)) { $cron->remove(); } }
function domogeek_remove() { $cron = cron::byClassAndFunction('domogeek', 'pull'); if (is_object($cron)) { $cron->remove(); } }
function ewattch_remove() { $cron = cron::byClassAndFunction('ewattch', 'pull'); if (is_object($cron)) { $cron->remove(); } }
function tesla_remove() { $cron = cron::byClassAndFunction('tesla', 'pull'); if (is_object($cron)) { $cron->remove(); } }
function sonos3_remove() { $cron = cron::byClassAndFunction('sonos3', 'pull'); if (is_object($cron)) { $cron->remove(); } }
function openzwave_remove() { if (openzwave::deamonRunning()) { openzwave::stopDeamon(); } $cron = cron::byClassAndFunction('openzwave', 'pull'); if (is_object($cron)) { $cron->remove(); } }
function mySensors_remove() { $cron = cron::byClassAndFunction('mySensors', 'pull'); if (is_object($cron)) { $cron->remove(); } if (method_exists('mySensors', 'stopDeamon')) { mySensors::stopDeamon(); } }
public static function health() { $return = array(); $cron = cron::byClassAndFunction('ewattch', 'pull'); $running = false; if (is_object($cron)) { $running = $cron->running(); } $return[] = array('test' => __('Tâche de synchronisation', __FILE__), 'result' => $running ? __('OK', __FILE__) : __('NOK', __FILE__), 'advice' => $running ? '' : __('Allez sur la page du moteur des tâches et vérifiez lancer la tache ewattch::pull', __FILE__), 'state' => $running); return $return; }
function gCalendar_remove() { $cron = cron::byClassAndFunction('gCalendar', 'pull'); if (is_object($cron)) { $cron->remove(); } // supprimer les fichiers cache et le répertoire // array_map('unlink', glob(GCALENDAR_CACHE_PATH . "gCalendar_*.tmp.xml")); if (rmdir(GCALENDAR_CACHE_PATH) === true) { log::add('gCalendar', 'info', 'gCalendar_remove(): Le répertoire (' . GCALENDAR_CACHE_PATH . ') et ses fichiers ont correctement été supprimés.'); } else { log::add('gCalendar', 'error', 'gCalendar_remove(): Impossible de supprimer le répertoire: ' . GCALENDAR_CACHE_PATH); } }
function arduidom_remove() { $cron = cron::byClassAndFunction('arduidom', 'checkdaemon'); if (is_object($cron)) { $cron->remove(); } arduidom::stopdaemon(1); arduidom::stopdaemon(2); arduidom::stopdaemon(3); arduidom::stopdaemon(4); arduidom::stopdaemon(5); arduidom::stopdaemon(6); arduidom::stopdaemon(7); arduidom::stopdaemon(8); }
function ecodevice_remove() { $cron = cron::byClassAndFunction('ecodevice', 'pull'); if (is_object($cron)) { $cron->remove(); } $cron = cron::byClassAndFunction('ecodevice', 'cron'); if (is_object($cron)) { $cron->remove(); } foreach (eqLogic::byType('ecodevice_compteur') as $SubeqLogic) { $SubeqLogic->remove(); } foreach (eqLogic::byType('ecodevice_teleinfo') as $SubeqLogic) { $SubeqLogic->remove(); } foreach (eqLogic::byType('ecodevice') as $eqLogic) { $eqLogic->remove(); } }
function openzwave_update() { if (!file_exists(dirname(__FILE__) . '/../data')) { mkdir(dirname(__FILE__) . '/../data'); if (file_exists('/opt/python-openzwave/xml_backups')) { shell_exec('cp -R /opt/python-openzwave/xml_backups ' . dirname(__FILE__) . '/../data'); shell_exec('cp -R /opt/python-openzwave/zwcfg_*.xml ' . dirname(__FILE__) . '/../data'); shell_exec('rm -rf /opt/python-openzwave/xml_backups'); shell_exec('rm -rf /opt/python-openzwave/zwcfg_*.xml'); } } $cron = cron::byClassAndFunction('openzwave', 'pull'); if (is_object($cron)) { $cron->remove(); } if (count(eqLogic::byType('zwave')) > 0) { log::add('openzwave', 'error', 'Attention vous etes sur la nouvelle version d\'openzwave, des actions de votre part sont necessaire merci d\'aller voir https://jeedom.fr/blog/?p=1576'); } openzwave::syncconfOpenzwave(); }
$cron->setClass('plugin'); $cron->setFunction('cron'); $cron->setSchedule('* * * * * *'); $cron->setTimeout(60); $cron->save(); $cron = cron::byClassAndFunction('plugin', 'cron15'); if (!is_object($cron)) { echo "Création de plugin::cron15\n"; $cron = new cron(); } $cron->setClass('plugin'); $cron->setFunction('cron15'); $cron->setSchedule('*/15 * * * * *'); $cron->setTimeout(60); $cron->save(); $cron = cron::byClassAndFunction('plugin', 'cron30'); if (!is_object($cron)) { echo "Création de plugin::cron30\n"; $cron = new cron(); } $cron->setClass('plugin'); $cron->setFunction('cron30'); $cron->setSchedule('*/30 * * * * *'); $cron->setTimeout(60); $cron->save(); $dynamic_apache_path = dirname(__FILE__) . '/../core/config/apache_jeedom_dynamic_rules'; if (!file_exists($dynamic_apache_path)) { touch($dynamic_apache_path); } if (jeedom::isCapable('sudo')) { if (!file_exists('/var/log/auth.log')) {
public function checkCmdAlert($_value) { if ($this->getConfiguration('jeedomCheckCmdOperator') == '' || $this->getConfiguration('jeedomCheckCmdTest') == '' || $this->getConfiguration('jeedomCheckCmdTime') == '' || is_nan($this->getConfiguration('jeedomCheckCmdTime'))) { return; } $check = jeedom::evaluateExpression($_value . $this->getConfiguration('jeedomCheckCmdOperator') . $this->getConfiguration('jeedomCheckCmdTest')); if ($check == 1 || $check || $check == '1') { if ($this->getConfiguration('jeedomCheckCmdTime') == 0) { $this->executeAlertCmdAction(); return; } $cron = cron::byClassAndFunction('cmd', 'cmdAlert', array('cmd_id' => intval($this->getId()))); if (!is_object($cron)) { $cron = new cron(); } $cron->setClass('cmd'); $cron->setFunction('cmdAlert'); $cron->setOnce(1); $cron->setOption(array('cmd_id' => intval($this->getId()))); $next = strtotime('+ ' . ($this->getConfiguration('jeedomCheckCmdTime') + 1) . ' minutes ' . date('Y-m-d H:i:s')); $schedule = date('i', $next) . ' ' . date('H', $next) . ' ' . date('d', $next) . ' ' . date('m', $next) . ' * ' . date('Y', $next); $cron->setSchedule($schedule); $cron->setLastRun(date('Y-m-d H:i:s')); $cron->save(); } else { $cron = cron::byClassAndFunction('cmd', 'cmdAlert', array('cmd_id' => intval($this->getId()))); if (is_object($cron)) { $cron->remove(); } } }
public static function cron() { //Rafraichissement des valeurs des modules foreach (eqLogic::byType('zwave') as $eqLogic) { if ($eqLogic->getIsEnable() == 1) { $scheduler = $eqLogic->getConfiguration('refreshDelay', ''); if ($scheduler != '') { try { $c = new Cron\CronExpression($scheduler, new Cron\FieldFactory()); if ($c->isDue()) { try { foreach ($eqLogic->getCmd('info') as $cmd) { if ($cmd->getConfiguration('doNotAutoRefresh', 0) == 0) { $cmd->forceUpdate(); } } } catch (Exception $exc) { log::add('zwave', 'error', __('Erreur pour ', __FILE__) . $eqLogic->getHumanName() . ' : ' . $exc->getMessage()); } } } catch (Exception $exc) { log::add('zwave', 'error', __('Expression cron non valide pour ', __FILE__) . $eqLogic->getHumanName() . ' : ' . $scheduler); } } } } if (config::byKey('jeeNetwork::mode') == 'slave') { $cron = cron::byClassAndFunction('zwave', 'pull'); if (is_object($cron)) { $cron->remove(); } } }
$jsonrpc->makeSuccess(utils::o2a(plugin::listPlugin($activateOnly, $orderByCaterogy))); } /* * ************************Object*************************** */ if ($jsonrpc->getMethod() == 'object::all') { $jsonrpc->makeSuccess(utils::o2a(object::all())); } if ($jsonrpc->getMethod() == 'object::byId') { $object = object::byId($params['id']); if (!is_object($object)) { throw new Exception('Objet introuvable : ' . $params['id'], -32601); } $jsonrpc->makeSuccess(utils::o2a($object)); } if ($jsonrpc->getMethod() == 'object::full') { $cache = cache::byKey('api::object::full'); $cron = cron::byClassAndFunction('object', 'fullData'); if (!is_object($cron)) { $cron = new cron(); } $cron->setClass('object'); $cron->setFunction('fullData'); $cron->setSchedule('* * * * * 2000'); $cron->setTimeout(10); $cron->save(); if (!$cron->running()) { $cron->run(true); } if ($cache->getValue() != '') { $jsonrpc->makeSuccess(json_decode($cache->getValue(), true)); } $jsonrpc->makeSuccess(array());
private function poll() { if (!$this->attached()) { $this->sendHeartbeat(); $this->retryConnectToHub++; if ($this->retryConnectToHub > XPL_MAX_RETRY_CONNEXION_TO_HUB) { log::add('xpl', 'error', 'xPL Hub non trouvé, veuillez le redemarrer', 'xplHubNotFound'); $cron = cron::byClassAndFunction('xpl', 'deamon'); if (is_object($cron)) { $cron->setEnable(0); $cron->save(); $cron->stop(); } } return; } $this->retryConnectToHub = 0; if (time() - $this->thisDevice->lastHeartBeat() >= $this->thisDevice->heartBeatInterval() * 60) { $this->sendHeartbeat(); } //Loop all devices to see if they have timed out foreach ($this->devices as $key => $device) { if (time() - $device->lastHeartBeat() >= $device->heartBeatInterval() * 60 * 2) { log::add('xpl', 'info', 'Device removed (timeout) : ' . $device->deviceName()); //This is not a prefeered way of removing the item from an array //Since we are iterating the loop will miss to check the new item. //Here, it will be checked next time poll is called unset($this->devices[$key]); xPL::removedDeviceFromxPLNetwork($device->deviceName()); continue; } } }
if (count($matches) == 4 && @is_numeric($matches[1][0]) && @$matches[1][0] != '' && @is_numeric($matches[2][0]) && @$matches[2][0] != '' && @is_numeric($matches[3][0]) && @$matches[3][0] != '') { $value = 'data[0].' . $value; } $cmd->setConfiguration('value', $value); if ($eqLogic->getConfiguration('device') == 'fibaro.fgrm221') { if ($cmd->getConfiguration('class') == '0x25' && $this->getConfiguration('data[0].val') && $this->getType() == 'info') { $cmd->setConfiguration('class', '0x26'); } } if ($eqLogic->getConfiguration('device') == 'fibaro.fgs221') { if ($cmd->getConfiguration('instanceId') == 1) { $cmd->setConfiguration('instanceId', 0); } if ($cmd->getConfiguration('instanceId') == 2) { $cmd->setConfiguration('instanceId', 1); } } $cmd->save(); } } $cron = cron::byClassAndFunction('zwave', 'pull'); if (is_object($cron)) { $cron->halt(); $cron->remove(); } $plugin = plugin::byId('zwave'); if (is_object($plugin)) { $plugin->setIsEnable(0); } echo "\nFin de la migration vers openzwave!!!!!!"; echo "\n/!\\IL EST VIVEMENT CONSEILLE DE REDEMARRER JEEDOM/!\\ ";
public function reschedule() { $sunrise = $this->getCmd(null, 'sunrise')->execCmd(); $sunset = $this->getCmd(null, 'sunset')->execCmd(); if ($sunrise == '' || !is_numeric($sunrise) || $sunrise < 500 || $sunrise > 1000) { $sunrise = 500; } if ($sunset == '' || !is_numeric($sunset) || $sunset > 2300 || $sunset < 1600) { $sunset = 1600; } $next = null; if (date('Gi') + 100 > $sunrise && date('Gi') + 100 < $sunset) { $next = $sunset; } else { $next = $sunrise; } if ($next == null || $next == '' || !is_numeric($next)) { return; } if ($next < date('Gi') + 10) { if (strlen($next) == 3) { $next = date('Y-m-d', strtotime('+1 day' . date('Y-m-d'))) . ' 0' . substr($next, 0, 1) . ':' . substr($next, 1, 3); } else { $next = date('Y-m-d', strtotime('+1 day' . date('Y-m-d'))) . ' ' . substr($next, 0, 2) . ':' . substr($next, 2, 4); } } else { if (strlen($next) == 3) { $next = date('Y-m-d') . ' 0' . substr($next, 0, 1) . ':' . substr($next, 1, 3); } else { $next = date('Y-m-d') . ' ' . substr($next, 0, 2) . ':' . substr($next, 2, 4); } } $cron = cron::byClassAndFunction('weather', 'pull', array('weather_id' => intval($this->getId()))); if ($next != null) { if (!is_object($cron)) { $cron = new cron(); $cron->setClass('weather'); $cron->setFunction('pull'); $cron->setOption(array('weather_id' => intval($this->getId()))); $cron->setLastRun(date('Y-m-d H:i:s')); } $next = strtotime($next); $cron->setSchedule(date('i', $next) . ' ' . date('H', $next) . ' ' . date('d', $next) . ' ' . date('m', $next) . ' * ' . date('Y', $next)); $cron->save(); } else { if (is_object($cron)) { $cron->remove(); } } }
<?php $cron = cron::byClassAndFunction('plugin', 'cronDaily'); if (!is_object($cron)) { $cron = new cron(); $cron->setClass('plugin'); $cron->setFunction('cronDaily'); $cron->setSchedule('00 00 * * * *'); $cron->setTimeout(5); $cron->save(); } $cron = cron::byClassAndFunction('plugin', 'cronHourly'); if (!is_object($cron)) { $cron = new cron(); $cron->setClass('plugin'); $cron->setFunction('cronHourly'); $cron->setSchedule('00 * * * * *'); $cron->setTimeout(5); $cron->save(); }
<?php $cron = cron::byClassAndFunction('history', 'archive'); if (is_object($cron)) { $cron->setSchedule('05 00 * * * *'); $cron->setTimeout(60); $cron->save(); }
<?php $cron = cron::byClassAndFunction('history', 'archive'); if (is_object($cron)) { $cron->setSchedule('00 * * * * *'); $cron->save(); } $cron = cron::byClassAndFunction('jeedom', 'persist'); if (is_object($cron)) { $cron->setSchedule('*/5 * * * * *'); $cron->save(); } $cron = cron::byClassAndFunction('cmd', 'collect'); if (is_object($cron)) { $cron->setSchedule('* * * * * *'); $cron->save(); }
public static function changeMode($_mode) { switch ($_mode) { case 'master': if (config::byKey('jeeNetwork::mode') != 'master') { $cron = new cron(); $cron->setClass('history'); $cron->setFunction('historize'); $cron->setSchedule('*/5 * * * * *'); $cron->setTimeout(5); $cron->save(); $cron = new cron(); $cron->setClass('scenario'); $cron->setFunction('check'); $cron->setSchedule('* * * * * *'); $cron->setTimeout(5); $cron->save(); $cron = new cron(); $cron->setClass('cmd'); $cron->setFunction('collect'); $cron->setSchedule('*/5 * * * * *'); $cron->setTimeout(5); $cron->save(); $cron = new cron(); $cron->setClass('history'); $cron->setFunction('archive'); $cron->setSchedule('00 * * * * *'); $cron->setTimeout(20); $cron->save(); config::save('jeeNetwork::mode', 'master'); } break; case 'slave': if (config::byKey('jeeNetwork::mode') != 'slave') { foreach (eqLogic::all() as $eqLogic) { $eqLogic->remove(); } foreach (object::all() as $object) { $object->remove(); } foreach (update::all() as $update) { switch ($update->getType()) { case 'core': break; case 'plugin': try { $plugin = plugin::byId($update->getLogicalId()); if (is_object($plugin) && $plugin->getAllowRemote() != 1) { $update->deleteObjet(); } } catch (Exception $e) { } break; default: $update->deleteObjet(); break; } } foreach (view::all() as $view) { $view->remove(); } foreach (plan::all() as $plan) { $plan->remove(); } foreach (scenario::all() as $scenario) { $scenario->remove(); } foreach (listener::all() as $listener) { $listener->remove(); } $cron = cron::byClassAndFunction('history', 'historize'); if (is_object($cron)) { $cron->remove(); } $cron = cron::byClassAndFunction('scenario', 'check'); if (is_object($cron)) { $cron->remove(); } $cron = cron::byClassAndFunction('cmd', 'collect'); if (is_object($cron)) { $cron->remove(); } $cron = cron::byClassAndFunction('history', 'archive'); if (is_object($cron)) { $cron->remove(); } $user = new user(); $user->setLogin('jeedom_master'); $user->setPassword(config::genKey(255)); $user->setRights('admin', 1); $user->save(); config::save('jeeNetwork::mode', 'slave'); } break; } }