예제 #1
0
 public function getDirectUrlAccess()
 {
     return network::getNetworkAccess('external') . '/core/php/authentification.php?login='******'&smdp=' . $this->getPassword();
 }
예제 #2
0
        } catch (Exception $e) {
        }
    }
}
$urlMasterLocal = false;
try {
    $request_http = new com_http(network::getNetworkAccess('internal', 'proto:127.0.0.1:port:comp') . '/plugins/openzwave/core/php/jeeZwave.php?apikey=' . config::byKey('api') . '&test=1');
    $request_http->setNoSslCheck(false);
    if ($request_http->exec(1, 1) == 'OK') {
        $urlMasterLocal = true;
    }
} catch (Exception $e) {
}
$urlMasterDistant = false;
try {
    $request_http = new com_http(network::getNetworkAccess('internal', 'proto:ip:port:comp') . '/plugins/openzwave/core/php/jeeZwave.php?apikey=' . config::byKey('api') . '&test=1');
    $request_http->setNoSslCheck(false);
    if ($request_http->exec(1, 1) == 'OK') {
        $urlMasterDistant = true;
    }
} catch (Exception $e) {
}
?>
<form class="form-horizontal">
	<fieldset>
		<?php 
echo '<div class="form-group">';
echo '<label class="col-sm-4 control-label">{{Retour local}}</label>';
if (!$urlMasterLocal) {
    echo '<div class="col-sm-1"><span class="label label-danger tooltips" style="font-size : 1em;" title="{{Vérifiez votre configuration sur la page de configuration réseaux, celle-ci est incorrecte et le démon ne pourra communiquer avec Jeedom}}">NOK</span></div>';
} else {
예제 #3
0
 public static function setTags($_expression, &$_scenario = null, $_quote = false, $_nbCall = 0)
 {
     if ($_nbCall > 10) {
         return $_expression;
     }
     $replace1 = array('#seconde#' => (int) date('s'), '#heure#' => (int) date('G'), '#minute#' => (int) date('i'), '#jour#' => (int) date('d'), '#mois#' => (int) date('m'), '#annee#' => (int) date('Y'), '#time#' => date('Gi'), '#timestamp#' => time(), '#seconde#' => (int) date('s'), '#date#' => date('md'), '#semaine#' => date('W'), '#sjour#' => '"' . date_fr(date('l')) . '"', '#smois#' => '"' . date_fr(date('F')) . '"', '#njour#' => (int) date('w'), '#hostname#' => '"' . gethostname() . '"', '#IP#' => '"' . network::getNetworkAccess('internal', 'ip') . '"', '#trigger#' => '');
     if (is_object($_scenario)) {
         $cmd = cmd::byId(str_replace('#', '', $_scenario->getRealTrigger()));
         if (is_object($cmd)) {
             $replace1['#trigger#'] = $cmd->getHumanName();
         } else {
             $replace1['#trigger#'] = $_scenario->getRealTrigger();
         }
     }
     if ($_scenario != null) {
         $replace1 = array_merge($replace1, $_scenario->getTags());
     }
     $replace2 = array();
     preg_match_all("/([a-zA-Z][a-zA-Z_]*?)\\((.*?)\\)/", $_expression, $matches, PREG_SET_ORDER);
     foreach ($matches as $match) {
         $function = $match[1];
         $replace_string = $match[0];
         if (substr_count($match[2], '(') != substr_count($match[2], ')')) {
             $pos = strpos($_expression, $match[2]) + strlen($match[2]);
             while (substr_count($match[2], '(') > substr_count($match[2], ')')) {
                 $match[2] .= $_expression[$pos];
                 $pos++;
                 if ($pos > strlen($_expression)) {
                     break;
                 }
             }
             $arguments = self::setTags($match[2], $_scenario, $_quote, $_nbCall++);
             $result = str_replace($match[2], $arguments, $_expression);
             while (substr_count($result, '(') > substr_count($result, ')')) {
                 $result .= ')';
             }
             $result = self::setTags($result, $_scenario, $_quote, $_nbCall++);
             return cmd::cmdToValue(str_replace(array_keys($replace1), array_values($replace1), $result), $_quote);
         } else {
             $arguments = explode(',', $match[2]);
         }
         if (method_exists(__CLASS__, $function)) {
             if ($function == 'trigger') {
                 if (!isset($arguments[0])) {
                     $arguments[0] = '';
                 }
                 $replace2[$replace_string] = self::trigger($arguments[0], $_scenario, $_quote);
             } else {
                 $replace2[$replace_string] = call_user_func_array(__CLASS__ . "::" . $function, $arguments);
             }
         } else {
             if (function_exists($function)) {
                 foreach ($arguments as &$argument) {
                     $argument = evaluate(self::setTags($argument, $_scenario, $_quote));
                 }
                 $replace2[$replace_string] = call_user_func_array($function, $arguments);
             }
         }
     }
     return cmd::cmdToValue(str_replace(array_keys($replace1), array_values($replace1), str_replace(array_keys($replace2), array_values($replace2), $_expression)), $_quote);
 }
 public static function runDeamon($_debug = false)
 {
     if (config::byKey('allowStartDeamon', 'openzwave', 1) == 0) {
         return;
     }
     try {
         self::stop();
         self::stopDeamon();
     } catch (Exception $e) {
     }
     log::add('openzwave', 'info', 'Lancement du démon openzwave');
     $port = config::byKey('port', 'openzwave');
     if ($port != 'auto') {
         $port = jeedom::getUsbMapping($port, true);
         if (@(!file_exists($port))) {
             throw new Exception(__('Le port : ', __FILE__) . print_r($port, true) . __(' n\'existe pas', __FILE__));
         }
         exec('sudo chmod 777 ' . $port . ' > /dev/null 2>&1');
     }
     if (config::byKey('jeeNetwork::mode') == 'slave') {
         $serverId = config::byKey('jeeNetwork::slave::id');
         $callback = config::byKey('jeeNetwork::master::ip') . '/plugins/openzwave/core/php/jeeZwave.php';
         $apikey = config::byKey('jeeNetwork::master::apikey');
     } else {
         $serverId = 0;
         $callback = network::getNetworkAccess('internal', 'proto:127.0.0.1:port:comp') . '/plugins/openzwave/core/php/jeeZwave.php';
         $apikey = config::byKey('api');
     }
     $port_server = config::byKey('port_server', 'openzwave', 8083);
     $openzwave_path = dirname(__FILE__) . '/../../ressources/zwaveserver';
     $config_path = dirname(__FILE__) . '/../../ressources/openzwave/config';
     $data_path = dirname(__FILE__) . '/../../data';
     if (!file_exists($data_path)) {
         exec('mkdir ' . $data_path . ' && chmod 775 -R ' . $data_path . ' && chown -R www-data:www-data ' . $data_path);
     }
     $log = $_debug ? 'Debug' : 'Error';
     $cmd = '/usr/bin/python ' . $openzwave_path . '/openZWave.py ';
     $cmd .= ' --pidfile=/tmp/openzwave.pid';
     $cmd .= ' --device=' . $port;
     $cmd .= ' --log=' . $log;
     $cmd .= ' --port=' . $port_server;
     $cmd .= ' --config_folder=' . $config_path;
     $cmd .= ' --data_folder=' . $data_path;
     $cmd .= ' --callback=' . $callback;
     $cmd .= ' --apikey=' . $apikey;
     $cmd .= ' --serverId=' . $serverId;
     log::add('openzwave', 'info', 'Lancement démon openzwave : ' . $cmd);
     $result = exec($cmd . ' >> ' . log::getPathToLog('openzwave') . ' 2>&1 &');
     if (strpos(strtolower($result), 'error') !== false || strpos(strtolower($result), 'traceback') !== false) {
         log::add('openzwave', 'error', $result);
         return false;
     }
     $i = 0;
     while ($i < 30) {
         if (self::deamonRunning()) {
             break;
         }
         sleep(1);
         $i++;
     }
     if ($i >= 10) {
         log::add('openzwave', 'error', 'Impossible de lancer le démon openzwave, vérifiez le port', 'unableStartDeamon');
         return false;
     }
     message::removeAll('openzwave', 'unableStartDeamon');
     log::add('openzwave', 'info', 'Démon openzwave lancé');
 }
예제 #5
0
파일: cmd.class.php 프로젝트: jimibi/core
 public function getDirectUrlAccess()
 {
     $url = '/core/api/jeeApi.php?apikey=' . config::byKey('api') . '&type=cmd&id=' . $this->getId();
     if ($this->getType() == 'action') {
         switch ($this->getSubType()) {
             case 'slider':
                 $url .= '&slider=50';
                 break;
             case 'color':
                 $url .= '&color=#123456';
                 break;
             case 'message':
                 $url .= '&title=montitre&message=monmessage';
                 break;
         }
     }
     return network::getNetworkAccess('external') . $url;
 }
예제 #6
0
                    <label class="col-sm-4 control-label">{{Ne pas utiliser le widget spécifique}}</label>
                    <div class="col-sm-1">
                    <input type="checkbox" class="eqLogicAttr bootstrapSwitch" data-l1key="configuration" data-l2key="noSpecifyWidget" />
                    </div>
                </div>
            </fieldset>
        </form>
    </div>
    <div class="col-sm-6">

    </div>
</div>

<legend>Commandes</legend>
<div class="alert alert-info">Exemple d’URL à appeler avec tasker : <?php 
echo network::getNetworkAccess('external');
?>
/core/api/jeeApi.php?api=<?php 
echo config::byKey('api');
?>
&type=geoloc&id=#ID_CMD#&value=%LOCN</div>
<a class="btn btn-success btn-sm cmdAction" data-action="add"><i class="fa fa-plus-circle"></i> {{Commandes}}</a><br/><br/>
<table id="table_cmd" class="table table-bordered table-condensed">
    <thead>
        <tr>
            <th style="width: 50px;">{{ID}}</th>
            <th style="width: 200px;">{{Nom}}</th>
            <th style="width: 200px;">{{Type}}</th>
            <th>{{Options}}</th>
            <th style="width: 100px;">{{Paramètres}}</th>
            <th style="width: 150px;"></th>
예제 #7
0
        <div class="col-sm-9">
         <input type="checkbox" class="eqLogicAttr bootstrapSwitch" data-label-text="{{Activer}}" data-l1key="isEnable" checked/>
         <input type="checkbox" class="eqLogicAttr bootstrapSwitch" data-label-text="{{Visible}}" data-l1key="isVisible" checked/>
       </div>
     </div>
     <div class="form-group">
     <label class="col-sm-3 control-label">{{Domaine}}</label>
      <div class="col-sm-3">
        <input type="text" class="eqLogicAttr form-control" data-l1key="logicalId" placeholder="{{Nom du domaine}}"/>
      </div>
    </div>
    <div class="form-group">
      <label class="col-lg-3 control-label">{{URL de retour}}</label>
      <div class="col-lg-9">
        <span><?php 
echo network::getNetworkAccess('external') . '/plugins/slack/core/php/jeeSlack.php?apikey=' . config::byKey('api');
?>
</span>
      </div>
    </div>
  </fieldset>
</form>

<legend>{{Commande}}</legend>
<a class="btn btn-success btn-sm cmdAction" data-action="add"><i class="fa fa-plus-circle"></i> {{Ajouter une commande}}</a><br/><br/>
<table id="table_cmd" class="table table-bordered table-condensed">
  <thead>
    <tr>
      <th>{{Nom}}</th><th>{{Webhook}}</th><th>{{Destination}}</th><th>{{Options}}</th>
    </tr>
  </thead>
예제 #8
0
파일: jeeApi.php 프로젝트: GaelGRIFFON/core
     }
     throw new Exception('La paramètre "state" ne peut être vide et doit avoir pour valeur [run,stop,enable;disable]');
 }
 /*             * ************************JeeNetwork*************************** */
 if ($jsonrpc->getMethod() == 'jeeNetwork::handshake') {
     if (config::byKey('jeeNetwork::mode') != 'slave') {
         throw new Exception('Impossible d\'ajouter une box jeedom non esclave à un réseau Jeedom');
     }
     $auiKey = config::byKey('auiKey');
     if ($auiKey == '') {
         $auiKey = config::genKey(255);
         config::save('auiKey', $auiKey);
     }
     $return = array('mode' => config::byKey('jeeNetwork::mode'), 'nbUpdate' => update::nbNeedUpdate(), 'version' => jeedom::version(), 'nbMessage' => message::nbMessage(), 'auiKey' => $auiKey, 'jeedom::url' => config::byKey('jeedom::url'), 'ngrok::port' => config::byKey('ngrok::port'));
     if (!filter_var(network::getNetworkAccess('external', 'ip'), FILTER_VALIDATE_IP) && network::getNetworkAccess('external', 'ip') != '') {
         $return['jeedom::url'] = network::getNetworkAccess('internal');
     }
     foreach (plugin::listPlugin(true) as $plugin) {
         if ($plugin->getAllowRemote() == 1) {
             $return['plugin'][] = $plugin->getId();
         }
     }
     $address = isset($params['address']) && $params['address'] != '' ? $params['address'] : getClientIp();
     config::save('jeeNetwork::master::ip', $address);
     config::save('jeeNetwork::master::apikey', $params['apikey_master']);
     config::save('jeeNetwork::slave::id', $params['slave_id']);
     if (config::byKey('internalAddr') == '') {
         config::save('internalAddr', $params['slave_ip']);
     }
     jeeNetwork::testMaster();
     $jsonrpc->makeSuccess($return);
예제 #9
0
 public static function deamon_start($_debug = false)
 {
     self::deamon_stop();
     $deamon_info = self::deamon_info();
     if ($deamon_info['launchable'] != 'ok') {
         throw new Exception(__('Veuillez vérifier la configuration', __FILE__));
     }
     log::remove('openzwavecmd');
     $port = config::byKey('port', 'openzwave');
     if ($port != 'auto') {
         $port = jeedom::getUsbMapping($port);
     }
     if (config::byKey('jeeNetwork::mode') == 'slave') {
         $serverId = config::byKey('jeeNetwork::slave::id');
         $callback = config::byKey('jeeNetwork::master::ip') . '/plugins/openzwave/core/php/jeeZwave.php';
         $apikey = config::byKey('jeeNetwork::master::apikey');
     } else {
         $serverId = 0;
         $callback = network::getNetworkAccess('internal', 'proto:127.0.0.1:port:comp') . '/plugins/openzwave/core/php/jeeZwave.php';
         $apikey = config::byKey('api');
     }
     $port_server = config::byKey('port_server', 'openzwave', 8083);
     $openzwave_path = dirname(__FILE__) . '/../../ressources/zwaveserver';
     $config_path = dirname(__FILE__) . '/../../ressources/openzwave/config';
     $data_path = dirname(__FILE__) . '/../../data';
     if (!file_exists($data_path)) {
         exec('mkdir ' . $data_path . ' && chmod 775 -R ' . $data_path . ' && chown -R www-data:www-data ' . $data_path);
     }
     $log = $_debug ? 'Debug' : 'Error';
     $cmd = '/usr/bin/python ' . $openzwave_path . '/openZWave.py ';
     $cmd .= ' --pidfile=/tmp/openzwave.pid';
     $cmd .= ' --device=' . $port;
     $cmd .= ' --log=' . $log;
     $cmd .= ' --port=' . $port_server;
     $cmd .= ' --config_folder=' . $config_path;
     $cmd .= ' --data_folder=' . $data_path;
     $cmd .= ' --callback=' . $callback;
     $cmd .= ' --apikey=' . $apikey;
     $cmd .= ' --serverId=' . $serverId;
     log::add('openzwavecmd', 'info', 'Lancement démon openzwave : ' . $cmd);
     $result = exec($cmd . ' >> ' . log::getPathToLog('openzwavecmd') . ' 2>&1 &');
     if (strpos(strtolower($result), 'error') !== false || strpos(strtolower($result), 'traceback') !== false) {
         log::add('openzwavecmd', 'error', $result);
         return false;
     }
     $i = 0;
     while ($i < 30) {
         $deamon_info = self::deamon_info();
         if ($deamon_info['state'] == 'ok') {
             break;
         }
         sleep(1);
         $i++;
     }
     if ($i >= 30) {
         log::add('openzwavecmd', 'error', 'Impossible de lancer le démon openzwave, relancer le démon en debug et vérifiez la log', 'unableStartDeamon');
         return false;
     }
     message::removeAll('openzwave', 'unableStartDeamon');
     log::add('openzwavecmd', 'info', 'Démon openzwave lancé');
 }
예제 #10
0
 <div class="col-sm-6">
    <legend>DNS Jeedom</legend>
    <div class="alert alert-warning">{{Attention cette fonctionnalité n'est pas disponible dans le service pack community (voir votre service pack sur  votre page profils sur le market)}}</div>
    <div class="form-group">
        <label class="col-xs-4 control-label">{{Utiliser les DNS Jeedom}}</label>
        <div class="col-xs-8">
            <input type="checkbox" class="configKey bootstrapSwitch" data-l1key="market::allowDNS" />
        </div>
    </div>
    <div class="alert alert-info">{{Toute modification nécessite de redémarrer le service DNS Jeedom (ligne "Gestion" puis "Redémarrer")}}</div>
    <div class="form-group">
        <label class="col-xs-4 control-label">{{Statut http}}</label>
        <div class="col-xs-8">
            <?php 
if (config::byKey('market::allowDNS') == 1 && $externalTest) {
    echo '<span class="label label-success" style="font-size : 1em;">{{Démarré : }} <a href="' . network::getNetworkAccess('external') . '" target="_blank" style="color:white;text-decoration: underline;">' . network::getNetworkAccess('external') . '</a></span>';
} else {
    echo '<span class="label label-warning tooltips" title="{{Normal si vous n\'avez pas coché la case : Utiliser les DNS Jeedom}}">{{Arrêté}}</span>';
}
?>
       </div>
   </div>
   <div class="form-group">
       <label class="col-xs-4 control-label">{{Gestion}}</label>
       <div class="col-xs-8">
         <a class="btn btn-success" id="bt_restartNgrok"><i class='fa fa-play'></i> {{(Re)démarrer}}</a>
         <a class="btn btn-danger" id="bt_haltNgrok"><i class='fa fa-stop'></i> {{Arrêter}}</a>
     </div>

 </div>
</div>
예제 #11
0
 public function handshake()
 {
     $jsonrpc = $this->getJsonRpc();
     $params = array('apikey_master' => config::byKey('api'), 'address' => network::getNetworkAccess('internal'), 'slave_ip' => $this->getRealIp(), 'slave_id' => $this->getId());
     if ($jsonrpc->sendRequest('jeeNetwork::handshake', $params, 60)) {
         $result = $jsonrpc->getResult();
         $this->setStatus('ok');
         $this->setPlugin($result['plugin']);
         $this->setConfiguration('nbUpdate', $result['nbUpdate']);
         $this->setConfiguration('url', $result['jeedom::url']);
         $this->setConfiguration('version', $result['version']);
         $this->setConfiguration('auiKey', $result['auiKey']);
         $this->setConfiguration('ngrok::port', $result['ngrok::port']);
         $this->setConfiguration('lastCommunication', date('Y-m-d H:i:s'));
         if ($this->getConfiguration('nbMessage') != $result['nbMessage'] && $result['nbMessage'] > 0) {
             log::add('jeeNetwork', 'error', __('Le jeedom esclave : ', __FILE__) . $this->getName() . __(' a de nouveaux messages : ', __FILE__) . $result['nbMessage']);
         }
         $this->setConfiguration('nbMessage', $result['nbMessage']);
     } else {
         $this->setStatus('error');
         throw new Exception($jsonrpc->getError(), $jsonrpc->getErrorCode());
     }
 }
예제 #12
0
 public static function deamon_start($_debug = false)
 {
     //// Démarrage du démon
     $daemonmode = self::get_daemon_mode();
     if ($daemonmode == "STARTING" || $daemonmode == "KILLING" || $daemonmode == "FLASHING") {
         //log::add('arduidom', 'debug', "Another session of starting daemon in progress... wait 1 minute before retry...");
         if ($_debug == false) {
             return false;
         }
     }
     self::set_daemon_mode("STARTING");
     sleep(1);
     // Delai de sécurité anti-collisions du start
     if ($_debug == false) {
         config::save('generalDebug', 0, 'arduidom');
     } else {
         config::save('generalDebug', 1, 'arduidom');
     }
     $ressource_path = realpath(dirname(__FILE__) . '/../../ressources');
     if ($_debug) {
         log::add('arduidom', 'debug', "************************** --------------------------------------------------------------------------------------");
     }
     if ($_debug) {
         log::add('arduidom', 'debug', "* daemon_start(debug={$_debug}) *");
     }
     if ($_debug) {
         log::add('arduidom', 'debug', "**************************");
     }
     $nbArduinos = intval(config::byKey("ArduinoQty", "arduidom", 1, true));
     $daemon_path = realpath(dirname(__FILE__) . '/../../ressources');
     //// Termine les démons restants
     touch($daemon_path . "/arduidomx.kill");
     sleep(1.5);
     if ($_debug) {
         log::add('arduidom', 'info', 'kill daemon(s)...');
     }
     $pid_file = $daemon_path . "/arduidomx.pid";
     if (file_exists($pid_file)) {
         $pid = intval(trim(file_get_contents($pid_file)));
         if (substr(jeedom::version(), 0, 1) == 2) {
             $killresult = system::kill($pid);
         }
         if (substr(jeedom::version(), 0, 1) == 2) {
             if ($_debug) {
                 log::add('arduidom', 'debug', 'system::kill(' . $pid . ") = " . $killresult);
             }
         }
         if ($_debug) {
             log::add('arduidom', 'debug', "removing file " . $daemon_path . "/arduidomx.pid");
         }
         unlink($daemon_path . "/arduidomx.pid");
     }
     if ($_debug) {
         log::add('arduidom', 'debug', "system::fuserk(" . intval(58201) . ")");
     }
     if (substr(jeedom::version(), 0, 1) == 2) {
         system::fuserk(intval(58200));
     }
     if (substr(jeedom::version(), 0, 1) == 2) {
         system::fuserk(intval(58201));
     }
     if (file_exists(log::getPathToLog('arduidom_daemon'))) {
         unlink(log::getPathToLog('arduidom_daemon'));
     }
     touch(log::getPathToLog('arduidom_daemon'));
     chown(log::getPathToLog('arduidom_daemon'), "www-data");
     chmod(log::getPathToLog('arduidom_daemon'), 0777);
     //// Recreation du XML de config
     if (file_exists($ressource_path . '/config_arduidom.xml')) {
         unlink($ressource_path . '/config_arduidom.xml');
     }
     $replace_config = array('#ArduinoVersion#' => config::byKey("ArduinoRequiredVersion", "arduidom", ""), '#ArduinoQty#' => config::byKey("arduinoqty", "arduidom", 0), '#log_path#' => log::getPathToLog('arduidom'), '#pid_path#' => $ressource_path . '/arduidomx.pid');
     for ($i = 1; $i <= 8; $i++) {
         $replace_config['#A' . $i . '_serial_port#'] = config::byKey('A' . $i . '_port', 'arduidom', '');
     }
     if (config::byKey('jeeNetwork::mode') == 'slave') {
         $replace_config['#sockethost#'] = network::getNetworkAccess('internal', 'ip', '127.0.0.1');
         $replace_config['#socketport#'] = 58300;
         $replace_config['#trigger_url#'] = config::byKey('jeeNetwork::master::ip') . '/plugins/arduidom/core/php/jeeArduidom.php';
         $replace_config['#trigger_nice#'] = str_replace('class', 'php', realpath(dirname(__FILE__))) . '/jeeArduidom.php';
         $replace_config['#apikey#'] = config::byKey('jeeNetwork::master::apikey');
     } else {
         $replace_config['#sockethost#'] = '0.0.0.0';
         //'127.0.0.1';
         $replace_config['#socketport#'] = 58200;
         $replace_config['#trigger_url#'] = network::getNetworkAccess('internal', 'proto:127.0.0.1:port:comp') . '/plugins/arduidom/core/php/jeeArduidom.php';
         $replace_config['#trigger_nice#'] = str_replace('class', 'php', realpath(dirname(__FILE__))) . '/jeeArduidom.php';
         $replace_config['#apikey#'] = config::byKey('api');
     }
     $config = file_get_contents($ressource_path . '/config_template.xml');
     $config = template_replace($replace_config, $config);
     file_put_contents($ressource_path . '/config_arduidom.xml', $config);
     chmod($ressource_path . '/config_arduidom.xml', 0777);
     //// Verifie si le python est necessaire... (inutile si aucun arduino USB)
     //$usb_arduinos = 0;
     //if ($_debug) log::add('arduidom','DEBUG','strpos1:' . strpos(config::byKey('A1_port', 'arduidom', '', 1), "/dev"));
     //if ($_debug) log::add('arduidom','DEBUG','strpos2:' . strpos(config::byKey('A2_port', 'arduidom', '', 1), "/dev"));
     //for ($a = 1; $a <= 8; $a++) {
     //    if (strpos(config::byKey('A' . $a . '_port', 'arduidom', '', true), "dev/") != false) $usb_arduinos += 1;
     //}
     //if ($usb_arduinos > 0) {
     if (true) {
         $cmd = 'nohup nice -n 19 /usr/bin/python ' . $ressource_path . '/arduidomx.py';
         if ($_debug) {
             $cmd .= ' -lDEBUG';
         }
         unlink($ressource_path . '/arduidomx.kill');
         $cmd .= ' >> ' . log::getPathToLog('arduidom_cmd') . ' 2>&1 &';
         config::save('daemonstarted', 0, 'arduidom');
         log::add('arduidom', 'info', 'Lancement démon : ' . $cmd);
         //// Execution du Python...
         $result = exec($cmd);
         if (strpos(strtolower($result), 'error') !== false || strpos(strtolower($result), 'traceback') !== false) {
             log::add('arduidom', 'error', $result);
             self::set_daemon_mode("ERROR");
             return false;
         }
         log::add('arduidom', 'info', 'Attente du démarrage complet du démon... (30 secondes max.)');
         $timeout = time();
         while (config::byKey('daemonstarted', 'arduidom', 0, true) == 0) {
             sleep(1);
             if (time() - $timeout >= 30) {
                 self::set_daemon_mode("ERROR");
                 // daemonstarted = Etat du démon : 0=non demarré - 1=démon OK - 2=erreur version
                 if (config::byKey('daemonstarted', 'arduidom', 0, true) == 0) {
                     log::add('arduidom', 'error', ' Dépassement du délai de démarrage du démon...');
                     if (substr(jeedom::version(), 0, 1) == 2) {
                         event::add('jeedom::alert', array('level' => 'error', 'message' => __("Dépassement du délai de démarrage du démon...", __FILE__)));
                     }
                 }
                 return false;
             }
         }
         if (config::byKey('daemonstarted', 'arduidom', 0, true) == 2) {
             self::set_daemon_mode("ERROR");
             // daemonstarted = Etat du démon : 0=non demarré - 1=démon OK - 2=erreur version
             log::add('arduidom', 'error', " Un ou plusieurs Arduino n\\'ont pas la version du sketch requise ! Veuillez téléverser le sketch fourni avec le plugin.");
             if (substr(jeedom::version(), 0, 1) == 2) {
                 event::add('jeedom::alert', array('level' => 'error', 'message' => __("Un ou plusieurs Arduino n\\'ont pas la version du sketch requise ! Veuillez téléverser le sketch fourni avec le plugin.", __FILE__)));
             }
             return false;
         }
     } else {
         if ($_debug) {
             log::add('arduidom', 'info', 'Skipping python program, no USB arduino configured.');
         }
     }
     //// Verifications, SetPin, RestoreStates
     $errorCounter = 0;
     $nbArduinos = intval(config::byKey("ArduinoQty", "arduidom", 1));
     self::set_daemon_mode("STARTED");
     // necessaire pour le restorestates
     for ($d = 1; $d <= $nbArduinos; $d++) {
         $result = self::setPinMapping($d);
         if ($result != "OK") {
             $errorCounter += 1;
         }
         log::add('arduidom', 'debug', 'arduino ' . $d . ' : Pin Mapping = ' . $result);
         $result = self::restoreStates($d);
         if ($result != "OK") {
             $errorCounter += 1;
         }
         log::add('arduidom', 'debug', 'arduino ' . $d . ' : Restore State = ' . $result);
     }
     if ($errorCounter > 0) {
         self::set_daemon_mode("ERROR");
         log::add('arduidom', 'error', $errorCounter . ' Erreur(s) pendant le lancement du démon...');
         return false;
     }
     self::set_daemon_mode("OK");
     message::removeAll('arduidom', 'unableStartDeamon');
     log::add('arduidom', 'info', 'Démon arduidom lancé sans erreur.');
     return true;
 }