Esempio n. 1
0
function openzwave_remove()
{
    if (openzwave::deamonRunning()) {
        openzwave::stopDeamon();
    }
    $cron = cron::byClassAndFunction('openzwave', 'pull');
    if (is_object($cron)) {
        $cron->remove();
    }
}
Esempio n. 2
0
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();
}
Esempio n. 3
0
          <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 expertModeVisible">
        <label class="col-sm-4 control-label">{{Node ID}}</label>
        <div class="col-sm-2">
          <input type="text" class="eqLogicAttr form-control" data-l1key="logicalId" />
        </div>
      </div>
      <div class="form-group expertModeVisible">
        <label class="col-sm-4 control-label">{{Serveur}}</label>
        <div class="col-sm-4">
         <select class="form-control eqLogicAttr" data-l1key="configuration" data-l2key="serverID">
          <?php 
foreach (openzwave::listServerZwave() as $id => $server) {
    if (isset($server['name'])) {
        echo '<option value="' . $id . '">' . $server['name'] . '</option>';
    }
}
?>
      </select>
    </div>
  </div>
  <div class="form-group expertModeVisible">
    <label class="col-sm-4 control-label">{{Délai maximum autorisé entre 2 messages (min)}}</label>
    <div class="col-sm-4">
      <input class="eqLogicAttr form-control" data-l1key="timeout" />
    </div>
  </div>
</fieldset>
Esempio n. 4
0
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * Jeedom is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with Jeedom. If not, see <http://www.gnu.org/licenses/>.
 */
if (!isConnect('admin')) {
    throw new Exception('{{401 - Accès non autorisé}}');
}
if (init('id') == '') {
    throw new Exception('{{EqLogic ID ne peut être vide}}');
}
$eqLogic = eqLogic::byId(init('id'));
if (!is_object($eqLogic)) {
    throw new Exception('{{EqLogic non trouvé}}');
}
include_file('3rdparty', 'jsonTree/jsonTree', 'css', 'openzwave');
include_file('3rdparty', 'jsonTree/jsonTree', 'js', 'openzwave');
$json = openzwave::callOpenzwave('/ZWaveAPI/Run/devices[' . $eqLogic->getLogicalId() . ']', $eqLogic->getConfiguration('serverID', 1));
sendVarToJs('zwaveDataTree', $json);
?>
<div id="div_zwaveDataTree"></div>
<script>
    $('#div_zwaveDataTree').html(JSONTree.create(zwaveDataTree));
</script>
 public function sendZwaveResquest($_url, $_options = array())
 {
     $eqLogic = $this->getEqLogic();
     if ($this->getType() == 'action') {
         if (isset($_options['speedAndNoErrorReport']) && $_options['speedAndNoErrorReport'] == true) {
             openzwave::callOpenzwave($_url, $eqLogic->getConfiguration('serverID', 1), 1, true);
         } else {
             openzwave::callOpenzwave($_url, $eqLogic->getConfiguration('serverID', 1));
         }
         return;
     }
     $result = openzwave::callOpenzwave($_url, $eqLogic->getConfiguration('serverID', 1));
     if (is_array($result)) {
         $value = self::handleResult($result);
         if (isset($result['updateTime'])) {
             $this->setCollectDate(date('Y-m-d H:i:s', $result['updateTime']));
         }
     } else {
         $value = $result;
         if ($value === true) {
             return 1;
         }
         if ($value === false) {
             return 0;
         }
         if (is_numeric($value)) {
             return round($value, 2);
         }
     }
     return $value;
 }
Esempio n. 6
0
    echo '<div class="col-sm-1"><span class="label label-success" style="font-size : 1em;">OK</span></div>';
}
echo '<label class="col-sm-1 control-label">{{Retour distant}}</label>';
if (!$urlMasterDistant) {
    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 {
    echo '<div class="col-sm-1"><span class="label label-success" style="font-size : 1em;">OK</span></div>';
}
echo '<label class="col-sm-2 control-label">{{OpenZwave}} (' . openzwave::getVersion('openzwave') . ')</label>';
if (version_compare(config::byKey('openzwave_version', 'openzwave'), openzwave::getVersion('openzwave'), '>')) {
    echo '<div class="col-sm-1"><span class="label label-danger" style="font-size : 1em;">NOK</span></div>';
} else {
    echo '<div class="col-sm-1"><span class="label label-success" style="font-size : 1em;">OK</span></div>';
}
echo '<label class="col-sm-1 control-label">{{Compilation}}</label>';
if (openzwave::compilationOk()) {
    echo '<div class="col-sm-1"><span class="label label-success" style="font-size : 1em;">OK</span></div>';
} else {
    echo '<div class="col-sm-1"><span class="label label-danger" style="font-size : 1em;">NOK</span></div>';
}
echo '</div>';
echo '<div class="form-group">';
echo '<label class="col-sm-4 control-label">{{Démon local}}</label>';
if (!$deamonRunningMaster) {
    echo '<div class="col-sm-1"><span class="label label-danger tooltips" style="font-size : 1em;" title="{{Peut être normale si vous etes en deporté}}">NOK</span></div>';
} else {
    echo '<div class="col-sm-1"><span class="label label-success" style="font-size : 1em;">OK</span></div>';
}
echo '</div>';
foreach ($deamonRunningSlave as $name => $status) {
    echo ' <div class="form-group"><label class="col-sm-4 control-label">{{Sur l\'esclave}} ' . $name . '</label>';
Esempio n. 7
0
        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__)));
        openzwave::syncEqLogicWithOpenZwave($results['serverId'], $results['controller']['included']['value']);
    }
}
if (isset($results['message'])) {
    log::add('openzwave', 'error', $results['message']);
}
if (isset($results['alert'])) {
    switch ($results['alert']['type']) {
        case 'node_dead':
            $eqLogic = openzwave::getEqLogicByLogicalIdAndServerId($results['alert']['id'], $results['alert']['serverId']);
            if (is_object($eqLogic)) {
                $message = __('Le noeud', __FILE__) . ' ' . $eqLogic->getHumanName() . ' (' . $results['alert']['id'] . ') ' . __('est présumé mort', __FILE__);
            } else {
                $message = __('Le noeud', __FILE__) . ' ' . $results['alert']['id'] . ' ' . __('est présumé mort', __FILE__);
            }
            log::add('openzwave', 'error', $message, 'node_dead_' . $results['alert']['id'] . '_' . $results['alert']['serverId']);
            break;
        case 'node_alive':
            message::removeAll('openzwave', 'node_dead_' . $results['alert']['id'] . '_' . $results['alert']['serverId']);
            break;
    }
}
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * Jeedom is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with Jeedom. If not, see <http://www.gnu.org/licenses/>.
 */
if (!isConnect('admin')) {
    throw new Exception('401 Unauthorized');
}
sendVarToJs('node_id', init('id'));
$listServerZwave = openzwave::listServerZwave();
sendVarToJs('path', $listServerZwave[init('serverId')]['path'] . '/');
?>
<style media="screen" type="text/css">
	.noscrolling{
		width:99%;
		overflow: hidden;
	}
	.node-item{
		border: 1px solid;
	}
	.greeniconcolor {color:green;}
	.yellowiconcolor {color:#FFD700;}
	.rediconcolor {color:red;}
	.modal-dialog-center {
		margin: 0;
Esempio n. 9
0
                        $cmd->handleUpdateValue($result);
                    }
                }
            }
        }
    }
}
if (isset($results['controller'])) {
    if (isset($results['controller']['state'])) {
        $jeeNetwork = jeeNetwork::byId($results['serverId']);
        if (is_object($jeeNetwork) || $results['serverId'] == 0) {
            nodejs::pushUpdate('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'])) {
        nodejs::pushUpdate('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++) {
            nodejs::pushUpdate('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);
        }
        nodejs::pushUpdate('jeedom::alert', array('level' => 'warning', 'message' => __('Inclusion en cours...', __FILE__)));
        openzwave::syncEqLogicWithOpenZwave($results['serverId'], $results['controller']['included']['value']);
    }
}
if (isset($results['message'])) {
    log::add('openzwave', 'error', $results['message']);
}
Esempio n. 10
0
         throw new Exception(__('Zwave eqLogic non trouvé : ', __FILE__) . init('id'));
     }
     foreach ($eqLogic->getCmd() as $cmd) {
         $cmd->remove();
     }
     $eqLogic->createCommand(true);
     ajax::success();
 }
 if (init('action') == 'migrateZwave') {
     $cmd = 'sudo php ' . dirname(__FILE__) . '/../../script/migrate.php';
     $cmd .= ' >> ' . log::getPathToLog('openzwave_migrate') . ' 2>&1 &';
     exec($cmd);
     ajax::success();
 }
 if (init('action') == 'getAllPossibleConf') {
     $eqLogic = openzwave::byId(init('id'));
     if (!is_object($eqLogic)) {
         ajax::success();
     }
     ajax::success($eqLogic->getConfFilePath(true));
 }
 if (init('action') == 'getConfiguration') {
     if (init('translation') == 1 && config::byKey('language', 'core', 'fr_FR') != 'fr_FR') {
         ajax::success();
     }
     $id = init('manufacturer_id') . '.' . init('product_type') . '.' . init('product_id');
     $files = ls(dirname(__FILE__) . '/../config/devices', $id . '_*.json', false, array('files', 'quiet'));
     foreach (ls(dirname(__FILE__) . '/../config/devices', '*', false, array('folders', 'quiet')) as $folder) {
         foreach (ls(dirname(__FILE__) . '/../config/devices/' . $folder, $id . '_*.json', false, array('files', 'quiet')) as $file) {
             $files[] = $folder . $file;
         }
			<th>1</th>
			<th>2</th>
			<th>3</th>
			<th>4</th>
			<th>5</th>
			<th>6</th>
			<th>7</th>
			<th>8</th>
			<th>9</th>
			<th>10</th>
		</tr>
	</thead>
	<tbody>
		<tr>
			<?php 
$data = openzwave::callOpenzwave('/ZWaveAPI/Run/devices[' . init('logical_id') . ']', init('serverId'));
$data = $data['instances'][0]['commandClasses'][99]['data'];
for ($i = 1; $i < 11; $i++) {
    echo '<td>';
    echo '<a class="btn btn-success pull-right btn-xs bt_ziptatoKeypadSaveNewCode" data-position="' . $i . '"><i class="fa fa-floppy-o"></i></a>';
    if (isset($data[$i]) && $data[$i]['val'] != '00000000000000000000') {
        echo '<i class="fa fa-check"></i>';
        echo '<a class="btn btn-danger pull-right btn-xs bt_ziptatoKeypadRemoveCode"  data-position="' . $i . '"><i class="fa fa-times"></i></a>';
    } else {
        echo '<i class="fa fa-times"></i>';
    }
    echo '</td>';
}
?>
      </tr>
  </tbody>
Esempio n. 12
0
}
$params = $jsonrpc->getParams();
if ($jsonrpc->getMethod() == 'deamonRunning') {
    $jsonrpc->makeSuccess(openzwave::deamonRunning());
}
if ($jsonrpc->getMethod() == 'runDeamon') {
    config::save('allowStartDeamon', 1, 'openzwave');
    $port = config::byKey('port', 'openzwave', 'none');
    if ($port == 'none') {
        ajax::success();
    }
    openzwave::stopDeamon();
    if (openzwave::deamonRunning()) {
        throw new Exception(__('Impossible d\'arrêter le démon', __FILE__));
    }
    log::clear('openzwave');
    $params['debug'] = !isset($params['debug']) ? 0 : $params['debug'];
    openzwave::runDeamon($params['debug']);
    $jsonrpc->makeSuccess('ok');
}
if ($jsonrpc->getMethod() == 'stopDeamon') {
    config::save('allowStartDeamon', 0, 'openzwave');
    $jsonrpc->makeSuccess(openzwave::stopDeamon());
}
if ($jsonrpc->getMethod() == 'getVersion') {
    $jsonrpc->makeSuccess(openzwave::getVersion($params['module']));
}
if ($jsonrpc->getMethod() == 'compilationOk') {
    $jsonrpc->makeSuccess(openzwave::compilationOk());
}
throw new Exception(__('Aucune methode correspondante pour le plugin openzwave : ' . $jsonrpc->getMethod(), __FILE__));
Esempio n. 13
0
<?php

/* This file is part of Jeedom.
 *
 * Jeedom is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * Jeedom is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with Jeedom. If not, see <http://www.gnu.org/licenses/>.
 */
require_once dirname(__FILE__) . "/../../../../core/php/core.inc.php";
include_file('core', 'authentification', 'php');
if (!isConnect('admin')) {
    throw new Exception('{{401 - Accès non autorisé}}');
}
if (strpos(init('request'), '/ZWaveAPI/Run/network.SaveZWConfig()') !== false) {
    echo json_encode(openzwave::callOpenzwave(str_replace('//', '/', init('request')), init('server_id'), null, false, init('data')));
} else {
    echo json_encode(openzwave::callOpenzwave(str_replace('//', '/', init('request')), init('server_id')));
}
Esempio n. 14
0
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * Jeedom is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with Jeedom. If not, see <http://www.gnu.org/licenses/>.
 */
require_once dirname(__FILE__) . '/../../../../core/php/core.inc.php';
global $jsonrpc;
if (!is_object($jsonrpc)) {
    throw new Exception(__('JSONRPC object not defined', __FILE__), -32699);
}
$params = $jsonrpc->getParams();
if ($jsonrpc->getMethod() == 'deamonRunning') {
    $jsonrpc->makeSuccess(openzwave::deamonRunning());
}
if ($jsonrpc->getMethod() == 'getVersion') {
    $jsonrpc->makeSuccess(openzwave::getVersion($params['module']));
}
if ($jsonrpc->getMethod() == 'compilationOk') {
    $jsonrpc->makeSuccess(openzwave::compilationOk());
}
if ($jsonrpc->getMethod() == 'syncconfOpenzwave') {
    $jsonrpc->makeSuccess(openzwave::syncconfOpenzwave());
}
throw new Exception(__('Aucune methode correspondante pour le plugin openzwave : ' . $jsonrpc->getMethod(), __FILE__));