Ejemplo n.º 1
0
function zwave_update()
{
    $cron = cron::byClassAndFunction('zwave', 'pull');
    if (config::byKey('jeeNetwork::mode') != 'slave') {
        if (!is_object($cron)) {
            $cron = new cron();
        }
        $cron->setClass('zwave');
        $cron->setFunction('pull');
        $cron->setEnable(1);
        $cron->setDeamon(1);
        $cron->setTimeout(1440);
        $cron->setSchedule('* * * * *');
        $cron->save();
        $cron->stop();
    } else {
        if (is_object($cron)) {
            $cron->remove();
        }
    }
    foreach (zwave::byType('zwave') as $zwave) {
        if ($zwave->getConfiguration('serverID') == '') {
            $zwave->setConfiguration('serverID', 1);
        }
        $zwave->save();
    }
    config::save('zwaveAddr1', config::byKey('zwaveAddr1', 'zwave', config::byKey('zwaveAddr', 'zwave')), 'zwave');
    config::save('zwavePort1', config::byKey('zwavePort1', 'zwave', config::byKey('zwavePort', 'zwave')), 'zwave');
    config::save('isOpenZwave1', config::byKey('isOpenZwave1', 'zwave', config::byKey('isOpenZwave', 'zwave')), 'zwave');
    if (method_exists('zwave', 'listServerZway')) {
        foreach (zwave::listServerZway() as $serverID => $server) {
            if (config::byKey('lastNotificationCheck' . $serverID, 'zwave', 0) == 0) {
                config::save('lastNotificationCheck' . $serverID, strtotime('now'), 'zwave');
            }
        }
    }
}
Ejemplo n.º 2
0
    echo '<div class="alert alert-info">' . $device['groups']['description'] . '</div>';
}
?>
   <legend>{{Association}}</legend>
   <form class="form-horizontal">
    <fieldset>
        <div class="form-group">
            <label class="col-sm-3 control-label">{{Ajouter association}}</label>
            <div class="col-sm-2">
                <select class="form-control" id="in_configureDeviceAddAssociationGroup"></select>
            </div>
            <div class="col-sm-2">
                <select class="form-control" id="in_configureDeviceAddAssociationNode">
                    <?php 
echo '<option value="' . zwave::getZwaveInfo('controller::data::nodeId::value', $eqLogic->getConfiguration('serverID')) . '">Jeedom</option>';
foreach (zwave::byType('zwave') as $zwave) {
    echo '<option value="' . $zwave->getLogicalId() . '">' . $zwave->getHumanName() . '</option>';
}
?>
               </select>
           </div>
           <div class="col-sm-1">
            <a class="btn btn-success" id="bt_configureDeviceAddAssociation"><i class="fa fa-check-circle"></i> {{Ok}}</a>
        </div>
    </div>
</fieldset>
</form>
<table id="table_configureDeviceAssociation" class="table table-bordered table-condensed">
    <thead>
        <tr>
            <th>{{Numéro de groupe}}</th>
Ejemplo n.º 3
0
 public static function cron()
 {
     //Rafraichissement des valeurs des modules
     foreach (eqLogic::byType('zwave') as $eqLogic) {
         $scheduler = $eqLogic->getConfiguration('refreshDelay', '');
         if ($scheduler != '') {
             try {
                 $c = new Cron\CronExpression($scheduler, new Cron\FieldFactory());
                 if ($c->isDue()) {
                     try {
                         foreach ($eqLogic->getCmd() as $cmd) {
                             $cmd->forceUpdate();
                         }
                     } catch (Exception $exc) {
                         log::add('zwave', 'error', 'Erreur pour ' . $eqLogic->getHumanName() . ' : ' . $exc->getMessage());
                     }
                 }
             } catch (Exception $exc) {
                 log::add('zwave', 'error', 'Expression cron non valide pour ' . $eqLogic->getHumanName() . ' : ' . $scheduler);
             }
         }
     }
     //Verification des piles une fois par jour
     if (date('H:i') == '00:00') {
         foreach (zwave::byType('zwave') as $eqLogic) {
             $http = new com_http(self::makeBaseUrl() . '/ZWaveAPI/Run/devices[' . $eqLogic->getLogicalId() . '].instances[0].commandClasses[0x80].Get()');
             try {
                 $http->exec();
             } catch (Exception $exc) {
             }
             $info = $eqLogic->getInfo();
             if (isset($info['state']) && $info['state'] == 'Réveillé') {
                 continue;
             }
             if (isset($info['battery']) && $info['battery'] !== '') {
                 $eqLogic->batteryStatus($info['battery']['value']);
             }
         }
     }
 }
Ejemplo n.º 4
0
			<th>{{ID}}</th>
			<th>{{Serveur}}</th>
			<th>{{Interview}}</th>
			<th>{{Statut}}</th>
			<th>{{Batterie}}</th>
			<th>{{Wakeup time}}</th>
			<th>{{Paquet total}}</th>
			<th>{{% OK}}</th>
			<th>{{Temporisation (ms)}}</th>
			<th>{{Dernière communication}}</th>
			<th>{{Ping}}</th>
		</tr>
	</thead>
	<tbody>
		<?php 
foreach (zwave::byType('zwave') as $eqLogic) {
    $info = $eqLogic->getInfo($infos[$eqLogic->getConfiguration('serverID')]);
    echo "<tr>";
    echo "<td><a href='index.php?v=d&m=zwave&p=zwave&id=" . $eqLogic->getId() . "'>" . $eqLogic->getHumanName() . "</a></td>";
    echo "<td>" . $eqLogic->getLogicalId() . "</td>";
    echo "<td>" . $serverList[$eqLogic->getConfiguration('serverID')]['name'] . "</td>";
    if (isset($info['interviewComplete']['value']) && $info['interviewComplete']['value'] != '') {
        if ($info['interviewComplete']['value'] == __('Complet', __FILE__)) {
            echo "<td><a class='btn btn-xs btn-success bt_showInterview' data-id='" . $eqLogic->getId() . "'><i class='fa fa-check'></i> " . $info['interviewComplete']['value'] . "</a></td>";
        } else {
            echo "<td><a class='btn btn-xs btn-warning bt_showInterview' data-id='" . $eqLogic->getId() . "'><i class='fa fa-times'></i> " . $info['interviewComplete']['value'] . " (" . $info['interviewComplete']['nbIncompleteClass'] . "/" . $info['interviewComplete']['nbClass'] . ")</a></td>";
        }
    } else {
        echo "<td></td>";
    }
    if ($info['state']['value'] == 'Dead') {
Ejemplo n.º 5
0
 public static function adminRazberry($_command, $_ignoreError = false, $_serverId = 1)
 {
     if ($_command == 'RequestNodeInformation()') {
         foreach (zwave::byType('zwave') as $eqLogic) {
             if ($eqLogic->getLogicalId() != 1 && $eqLogic->getConfiguration('serverID', 1) == $_serverId) {
                 try {
                     self::callRazberry('/ZWaveAPI/Run/devices[' . $eqLogic->getLogicalId() . '].RequestNodeInformation()', $_serverId);
                 } catch (Exception $e) {
                     if (!$_ignoreError) {
                         throw $e;
                     }
                 }
             }
         }
         return true;
     }
     if ($_command == 'SerialAPISoftReset()') {
         try {
             self::callRazberry('/ZWaveAPI/Run/' . $_command, $_serverId);
         } catch (Exception $e) {
             if (!$_ignoreError) {
                 throw $e;
             }
         }
         return true;
     }
     if ($_command == 'InterviewForce') {
         foreach (eqLogic::byType('zwave') as $eqLogic) {
             try {
                 $eqLogic->InterviewForce();
             } catch (Exception $e) {
                 if (!$_ignoreError) {
                     throw $e;
                 }
             }
         }
         return true;
     }
     if ($_command == 'cureZwaveNetwork') {
         $results = self::callRazberry('/ZWaveAPI/Data/0', $_serverId);
         $razberry_id = $results['controller']['data']['nodeId']['value'];
         self::adminRazberry('SendNodeInformation()', $_serverId);
         sleep(2);
         self::adminRazberry('RequestNodeInformation()', $_serverId);
         sleep(20);
         foreach (zwave::byType('zwave') as $eqLogic) {
             if ($eqLogic->getLogicalId() != $razberry_id && $eqLogic->getConfiguration('serverID', 1) == $_serverId) {
                 $results = zwave::callRazberry('/ZWaveAPI/Run/devices[' . $eqLogic->getLogicalId() . ']', $eqLogic->getConfiguration('serverID', 1));
                 foreach ($results['instances'] as $instanceID => $instance) {
                     foreach ($instance['commandClasses'] as $ccId => $commandClasses) {
                         if ($ccId == 96 && $instanceID != 0 || ($ccId == 134 || $ccId == 114 || $ccId == 96) && $instanceID == 0) {
                             continue;
                         }
                         if (isset($commandClasses['data']) && isset($commandClasses['data']['supported']) && (!isset($commandClasses['data']['supported']['value']) || $commandClasses['data']['supported']['value'] != true)) {
                             continue;
                         }
                         if (isset($commandClasses['data']) && isset($commandClasses['data']['interviewDone']) && (!isset($commandClasses['data']['interviewDone']['value']) || $commandClasses['data']['interviewDone']['value'] != true)) {
                             $eqLogic->InterviewForce($instanceID, $ccId);
                         }
                     }
                 }
             }
         }
         return true;
     }
     try {
         self::callRazberry('/ZWaveAPI/Run/controller.' . $_command, $_serverId);
     } catch (Exception $e) {
         if (!$_ignoreError) {
             throw $e;
         }
     }
     return true;
 }