Example #1
0
                            break;
                        }
                    }
                }
                foreach ($eqLogic->getCmd('info', $result['instance'] . '.' . $result['CommandClass'], null, true) as $cmd) {
                    if ($cmd->getConfiguration('value') == 'data[' . $result['index'] . '].val') {
                        $cmd->handleUpdateValue($result);
                    }
                }
            }
        }
    }
}
if (isset($results['controller'])) {
    if (isset($results['controller']['state'])) {
        $jeeNetwork = jeeNetwork::byId($results['serverId']);
        if (is_object($jeeNetwork) || $results['serverId'] == 0) {
            event::add('zwave::controller.data.controllerState', array('name' => $results['serverId'] == 0 ? 'local' : $jeeNetwork->getName(), 'state' => $results['controller']['state']['value'], 'serverId' => $results['serverId']));
        }
    }
    if (isset($results['controller']['excluded'])) {
        event::add('jeedom::alert', array('level' => 'warning', 'message' => __('Un périphérique Z-Wave est en cours d\'exclusion. Logical ID : ', __FILE__) . $results['controller']['excluded']['value']));
        sleep(2);
        openzwave::syncEqLogicWithOpenZwave($results['serverId'], $results['controller']['excluded']['value']);
    }
    if (isset($results['controller']['included'])) {
        for ($i = 0; $i < 10; $i++) {
            event::add('jeedom::alert', array('level' => 'warning', 'message' => __('Nouveau module Z-Wave détecté. Début de l\'intégration.Pause de ', __FILE__) . (10 - $i) . __(' pour synchronisation avec le module', __FILE__)));
            sleep(1);
        }
        event::add('jeedom::alert', array('level' => 'warning', 'message' => __('Inclusion en cours...', __FILE__)));
         $jsonrpc = $jeeNetwork->getJsonRpc();
         if (!$jsonrpc->sendRequest('stopDeamon', array('plugin' => 'openzwave'))) {
             throw new Exception($jsonrpc->getError(), $jsonrpc->getErrorCode());
         }
     } else {
         openzwave::stopDeamon();
         if (openzwave::deamonRunning()) {
             throw new Exception(__('Impossible d\'arrêter le démon', __FILE__));
         }
         config::save('allowStartDeamon', 0, 'openzwave');
     }
     ajax::success();
 }
 if (init('action') == 'startDeamon') {
     if (init('type', 'local') == 'remote') {
         $jeeNetwork = jeeNetwork::byId(init('id'));
         if (!is_object($jeeNetwork)) {
             throw new Exception(__('Impossible de trouver l\'esclave : ', __FILE__) . init('id'));
         }
         $jsonrpc = $jeeNetwork->getJsonRpc();
         if (!$jsonrpc->sendRequest('runDeamon', array('plugin' => 'openzwave', 'debug' => init('debug', 0)))) {
             throw new Exception($jsonrpc->getError(), $jsonrpc->getErrorCode());
         }
     } else {
         config::save('allowStartDeamon', 1, 'openzwave');
         $port = config::byKey('port', 'openzwave', 'none');
         if ($port == 'none') {
             ajax::success();
         }
         openzwave::stopDeamon();
         if (openzwave::deamonRunning()) {
 public static function sendToController($destination, $sensor, $command, $acknowledge, $type, $payload)
 {
     if (config::byKey('externalDeamon', 'mySensors', 0) == 2) {
         $jeeSlave = jeeNetwork::byId(config::byKey('jeeSlave', 'mySensors'));
         $urlNode = getIpFromString($jeeSlave->getIp());
     } else {
         $urlNode = "127.0.0.1";
     }
     log::add('mySensors', 'info', $urlNode);
     $msg = $destination . ";" . $sensor . ";" . $command . ";" . $acknowledge . ";" . $type . ";" . $payload;
     log::add('mySensors', 'info', $msg);
     $fp = fsockopen($urlNode, 8019, $errno, $errstr);
     if (!$fp) {
         echo "ERROR: {$errno} - {$errstr}<br />\n";
     } else {
         fwrite($fp, $msg);
         fclose($fp);
     }
 }
Example #4
0
     jeedom::rebootSystem();
     $jsonrpc->makeSuccess('ok');
 }
 if ($jsonrpc->getMethod() == 'jeeNetwork::update') {
     jeedom::update('', 0);
     $jsonrpc->makeSuccess('ok');
 }
 if ($jsonrpc->getMethod() == 'jeeNetwork::checkUpdate') {
     update::checkAllUpdate();
     $jsonrpc->makeSuccess('ok');
 }
 if ($jsonrpc->getMethod() == 'jeeNetwork::receivedBackup') {
     if (config::byKey('jeeNetwork::mode') == 'slave') {
         throw new Exception(__('Seul un maître peut recevoir une sauvegarde', __FILE__));
     }
     $jeeNetwork = jeeNetwork::byId($params['slave_id']);
     if (!is_object($jeeNetwork)) {
         throw new Exception(__('Aucun esclave correspondant à l\'id : ', __FILE__) . $params['slave_id']);
     }
     if (substr(config::byKey('backup::path'), 0, 1) != '/') {
         $backup_dir = dirname(__FILE__) . '/../../' . config::byKey('backup::path');
     } else {
         $backup_dir = config::byKey('backup::path');
     }
     $uploaddir = $backup_dir . '/slave/';
     if (!file_exists($uploaddir)) {
         mkdir($uploaddir);
     }
     if (!file_exists($uploaddir)) {
         throw new Exception('Répertoire de téléversement non trouvé : ' . $uploaddir);
     }
 public static function getNetworkNameByServerId($_serverId = '')
 {
     if ($_serverId == 0) {
         return __('Local', __FILE__);
     } else {
         $jeeNetwork = jeeNetwork::byId($_serverId);
         if (is_object($jeeNetwork)) {
             return $jeeNetwork->getName();
         }
     }
     return $_serverId;
 }