本文整理汇总了PHP中eqLogic类的典型用法代码示例。如果您正苦于以下问题:PHP eqLogic类的具体用法?PHP eqLogic怎么用?PHP eqLogic使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了eqLogic类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: cron30
public function cron30($_eqlogic_id = null)
{
if ($_eqlogic_id !== null) {
$eqLogics = array(eqLogic::byId($_eqlogic_id));
} else {
$eqLogics = eqLogic::byType('karotz');
}
foreach ($eqLogics as $karotz) {
if ($karotz->getIsEnable() == 1) {
$request = 'http://' . $karotz->getConfiguration('addr') . '/cgi-bin/status';
$request = new com_http($request);
$jsonstatus = json_decode($request->exec(5, 1), true);
$change = false;
foreach ($karotz->getCmd() as $cmd) {
if (!isset($jsonstatus[$cmd->getLogicalId()])) {
continue;
}
$value = $jsonstatus[$cmd->getLogicalId()];
if ($cmd->getLogicalId() == 'led_color') {
$value = '#' . $value;
}
if ($cmd->execCmd() !== $cmd->formatValue($value)) {
$cmd->event($value);
$change = true;
}
}
if ($change) {
$karotz->refreshWidget();
}
}
}
}
示例2: pull
public static function pull($_options)
{
$date = time();
log::add('mySensors', 'info', 'Cron de vérification des nodes');
foreach (eqLogic::byType('mySensors') as $elogic) {
log::add('mySensors', 'info', 'Vérification du node' . $elogic->getName());
if ($elogic->getConfiguration('followActivity') == '1') {
log::add('mySensors', 'info', $elogic->getName() . ' en surveillance');
$actDate = $elogic->getConfiguration('LastActivity');
log::add('mySensors', 'info', 'Derniere Activite ' . $actDate);
$activity = strtotime($actDate);
$duration = $elogic->getConfiguration('AlertLimit');
log::add('mySensors', 'info', 'Interval paramétré ' . $duration);
$interval = round(abs($date - $activity) / 60, 2);
log::add('mySensors', 'info', 'Durée d inactivité ' . $interval);
if ($interval > $duration) {
log::add('mySensors', 'info', 'Délai dépassé pour ' . $elogic->getName());
$gate = self::byLogicalId('gateway', 'mySensors');
$value = $elogic->getName();
$cmdlogic = mySensorsCmd::byEqLogicIdAndLogicalId($gate->getId(), 'Inactif');
$cmdlogic->setConfiguration('value', $value);
$cmdlogic->save();
$cmdlogic->event($value);
}
}
}
}
示例3: openzwave_update
function openzwave_update()
{
if (openzwave::deamonRunning()) {
echo 'Stop zwave network...';
openzwave::stopDeamon();
echo "OK\n";
}
echo 'Stop cron...';
$cron = cron::byClassAndFunction('openzwave', 'pull');
if (config::byKey('jeeNetwork::mode') != 'slave') {
if (!is_object($cron)) {
$cron = new cron();
}
$cron->setClass('openzwave');
$cron->setFunction('pull');
$cron->setEnable(1);
$cron->setDeamon(1);
$cron->setDeamonSleepTime(0.5);
$cron->setTimeout(1440);
$cron->setSchedule('* * * * *');
$cron->save();
$cron->stop();
} else {
if (is_object($cron)) {
$cron->remove();
}
}
echo "OK\n";
echo 'Check zwave system...';
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');
}
if (config::byKey('port', 'openzwave', 'none') != 'none') {
if (method_exists('openzwave', 'getVersion')) {
if (version_compare(config::byKey('openzwave_version', 'openzwave'), openzwave::getVersion('openzwave'), '>')) {
if (jeedom::getHardwareName() == 'Jeedomboard') {
config::save('allowStartDeamon', 0, 'openzwave');
openzwave::updateOpenzwave(false);
config::save('allowStartDeamon', 1, 'openzwave');
} else {
log::add('openzwave', 'error', __('Attention votre version d\'openzwave est dépassée sur le démon local, il faut ABSOLUMENT la mettre à jour', __FILE__));
}
}
}
}
if (config::byKey('jeeNetwork::mode') == 'master') {
foreach (jeeNetwork::byPlugin('openzwave') as $jeeNetwork) {
try {
if ($jeeNetwork->configByKey('port', 'openzwave', 'none') != 'none') {
if (version_compare($jeeNetwork->sendRawRequest('getVersion', array('plugin' => 'openzwave', 'module' => 'openzwave')), openzwave::getVersion('openzwave'), '>')) {
log::add('openzwave', 'error', __('Attention votre version d\'openzwave est dépassée sur', __FILE__) . ' ' . $jeeNetwork->getName() . ' ' . __('il faut ABSOLUMENT la mettre à jour', __FILE__));
}
}
} catch (Exception $e) {
}
}
}
echo "OK\n";
}
示例4: cronHourly
public static function cronHourly($_eqlogic_id = null)
{
if ($_eqlogic_id !== null) {
$eqLogics = array(eqLogic::byId($_eqlogic_id));
} else {
$eqLogics = eqLogic::byType('porkfolio');
}
foreach ($eqLogics as $porkfolio) {
if ($porkfolio->getIsEnable() == 1) {
log::add('porkfolio', 'debug', 'Pull Cron pour Porkfolio');
$porkfolioInfo = $porkfolio->getporkfolioInfo();
$somme = isset($porkfolioInfo['Somme']) ? $porkfolioInfo['Somme'] : "old";
$derniervers = isset($porkfolioInfo['Dernier']) ? $porkfolioInfo['Dernier'] : "old";
$datemvt = isset($porkfolioInfo['Date Mouvement']) ? $porkfolioInfo['Date Mouvement'] : "old";
$dateretournement = isset($porkfolioInfo['Date Retournement']) ? $porkfolioInfo['Date Retournement'] : "old";
$datevers = isset($porkfolioInfo['Date depot']) ? $porkfolioInfo['Date depot'] : "old";
$objectif = isset($porkfolioInfo['Objectif']) ? $porkfolioInfo['Objectif'] : "old";
$nez = isset($porkfolioInfo['Nez']) ? $porkfolioInfo['Nez'] : "old";
foreach ($porkfolio->getCmd('info') as $cmd) {
switch ($cmd->getName()) {
case 'Somme':
$value = $somme;
break;
case 'Dernière Opération':
$value = $derniervers;
break;
case 'Date mouvement':
$value = $datemvt;
break;
case 'Date dépot':
$value = $datevers;
break;
case 'Nez':
$value = $nez;
break;
case 'Date retournement':
$value = $dateretournement;
break;
case 'Objectif':
$value = $objectif;
break;
}
if ($value == 0 || $value != 'old') {
$cmd->event($value);
log::add('porkfolio', 'debug', 'set:' . $cmd->getName() . ' to ' . $value);
}
}
$mc = cache::byKey('porkfolioWidgetmobile' . $porkfolio->getId());
$mc->remove();
$mc = cache::byKey('porkfolioWidgetdashboard' . $porkfolio->getId());
$mc->remove();
$porkfolio->toHtml('mobile');
$porkfolio->toHtml('dashboard');
$porkfolio->refreshWidget();
}
}
}
示例5: openzwave_update
function openzwave_update()
{
log::add('openzwave', 'error', __('Après toute installation/mise à jour pensez bien à mettre à jour les dépendances Openzwave (voir documentation)', __FILE__));
if (!file_exists(dirname(__FILE__) . '/../data')) {
mkdir(dirname(__FILE__) . '/../data');
}
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');
config::save('allowStartDeamon', 0, 'openzwave');
echo 'Stop zwave network...';
openzwave::stop();
openzwave::stopDeamon();
echo "OK\n";
echo 'Stop cron...';
$cron = cron::byClassAndFunction('openzwave', 'pull');
if (is_object($cron)) {
$cron->remove();
}
echo "OK\n";
echo 'Check zwave system...';
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');
}
if (config::byKey('port', 'openzwave', 'none') != 'none') {
if (method_exists('openzwave', 'getVersion')) {
if (version_compare(config::byKey('openzwave_version', 'openzwave'), openzwave::getVersion('openzwave'), '>')) {
if (jeedom::getHardwareName() == 'Jeedomboard') {
openzwave::updateOpenzwave(false);
} else {
log::add('openzwave', 'error', __('Attention votre version d\'openzwave est dépassée sur le démon local, il faut ABSOLUMENT la mettre à jour', __FILE__));
}
}
}
}
if (config::byKey('jeeNetwork::mode') == 'master') {
foreach (jeeNetwork::byPlugin('openzwave') as $jeeNetwork) {
try {
if ($jeeNetwork->configByKey('port', 'openzwave', 'none') != 'none') {
if (version_compare($jeeNetwork->sendRawRequest('getVersion', array('plugin' => 'openzwave', 'module' => 'openzwave')), openzwave::getVersion('openzwave'), '>')) {
log::add('openzwave', 'error', __('Attention votre version d\'openzwave est dépassée sur', __FILE__) . ' ' . $jeeNetwork->getName() . ' ' . __('il faut ABSOLUMENT la mettre à jour', __FILE__));
}
}
} catch (Exception $e) {
}
}
}
echo "OK\n";
echo 'Redemarrage zwave network...';
try {
config::save('allowStartDeamon', 1, 'openzwave');
openzwave::runDeamon();
} catch (Exception $e) {
}
echo "OK\n";
}
示例6: karotz_update
function karotz_update()
{
foreach (eqLogic::byType('karotz') as $karotz) {
foreach ($karotz->getCmd() as $cmd) {
if ($cmd->getLogicalId() == '') {
$cmd->remove();
}
}
$karotz->save();
}
}
示例7: nabaztag_update
function nabaztag_update()
{
foreach (eqLogic::byType('nabaztag') as $nabaztag) {
foreach ($nabaztag->getCmd() as $cmd) {
if ($cmd->getLogicalId() == '') {
$cmd->remove();
}
}
$nabaztag->save();
}
}
示例8: getDisplayIds
public static function getDisplayIds($pebbleId)
{
$displayIds = '';
foreach (eqLogic::byType('jebble') as $jebble) {
if ($jebble->getIsEnable() && $jebble->getId() == $pebbleId) {
$displayIds = $jebble->getConfiguration('display_ids');
log::add('jebble', 'debug', 'ids:' . $displayIds);
break;
}
}
return $displayIds;
}
示例9: cron30
public static function cron30($_eqlogic_id = null)
{
if ($_eqlogic_id !== null) {
$eqLogics = array(eqLogic::byId($_eqlogic_id));
} else {
$eqLogics = eqLogic::byType('wazeintime');
sleep(rand(0, 120));
}
foreach ($eqLogics as $wazeintime) {
if ($wazeintime->getIsEnable() == 1) {
try {
$start = $wazeintime->getPosition('start');
$end = $wazeintime->getPosition('end');
$row = $wazeintime->getConfiguration('NOA') ? '' : 'row-';
$wazeRouteurl = 'https://www.waze.com/' . $row . 'RoutingManager/routingRequest?from=x%3A' . $start['lon'] . '+y%3A' . $start['lat'] . '&to=x%3A' . $end['lon'] . '+y%3A' . $end['lat'] . '&at=0&returnJSON=true&returnGeometries=true&returnInstructions=true&timeout=60000&nPaths=3&options=AVOID_TRAILS%3At';
$request_http = new com_http($wazeRouteurl);
$request_http->setUserAgent('User-Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:43.0) Gecko/20100101 Firefox/43.0');
$json = json_decode($request_http->exec(6, 2), true);
if (isset($json['error'])) {
throw new Exception($json['error']);
}
$data = self::extractInfo($json);
$wazeRoutereturl = 'https://www.waze.com/' . $row . 'RoutingManager/routingRequest?from=x%3A' . $end['lon'] . '+y%3A' . $end['lat'] . '&to=x%3A' . $start['lon'] . '+y%3A' . $start['lat'] . '&at=0&returnJSON=true&returnGeometries=true&returnInstructions=true&timeout=60000&nPaths=3&options=AVOID_TRAILS%3At';
$request_http = new com_http($wazeRoutereturl);
$request_http->setUserAgent('User-Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:43.0) Gecko/20100101 Firefox/43.0');
$json = json_decode($request_http->exec(6, 2), true);
if (isset($json['error'])) {
throw new Exception($json['error']);
}
$data = array_merge($data, self::extractInfo($json, 'ret'));
log::add('wazeintime', 'debug', 'Data : ' . print_r($data, true));
foreach ($wazeintime->getCmd('info') as $cmd) {
if ($cmd->getLogicalId() == 'lastrefresh') {
$cmd->event(date('H:i'));
continue;
}
if (!isset($data[$cmd->getLogicalId()])) {
continue;
}
if ($cmd->formatValue($data[$cmd->getLogicalId()]) != $cmd->execCmd()) {
$cmd->setCollectDate('');
$cmd->event($data[$cmd->getLogicalId()]);
}
}
$wazeintime->refreshWidget();
} catch (Exception $e) {
log::add('wazeintime', 'error', $e->getMessage());
}
}
}
}
示例10: cron
public static function cron($_eqlogic_id = null, $force = false)
{
if ($_eqlogic_id !== null) {
$eqLogics = array(eqLogic::byId($_eqlogic_id));
} else {
$eqLogics = eqLogic::byType('trains');
}
foreach ($eqLogics as $trains) {
if ($trains->getIsEnable() == 1) {
if ($force || date('Hi', time()) >= $trains->getConfiguration('trains_maj_deb') && date('Hi', time()) <= $trains->getConfiguration('trains_maj_fin')) {
log::add('trains', 'debug', 'Pull ' . ($force ? 'Forcé' : 'Cron') . ' pour trains ');
$baseUrl = 'http://www.gares-sncf.com/fr/train-times/departure/' . $trains->getConfiguration('trains_depart') . '/gl';
$arrivee = $trains->getConfiguration('trains_arrivee');
$response = file_get_contents($baseUrl);
$json = json_decode($response, true);
$departs = [];
foreach ($json['trains'] as $depart) {
$trainCourant = (object) [];
if ($arrivee == '' || $trains->string_contains($depart['origdest'], $arrivee)) {
$trainCourant->dest = $depart['origdest'];
$trainCourant->type = $depart['type'];
$trainCourant->voie = $depart['voie'];
$trainCourant->heure = $depart['heure'];
$trainCourant->etat = $depart['etat'];
$trainCourant->retard = $depart['retard'];
$trainCourant->infos = $depart['infos'];
$departs[] = $trainCourant;
}
}
log::add('trains', 'debug', 'Date de mise à jour des infos récupérées : ' . $json['updated']);
log::add('trains', 'debug', 'infos récupérées : ' . json_encode($departs));
$result = (object) [];
$result->updated = $json['updated'];
$result->departs = $departs;
$trainsCmd = $trains->getCmd(null, 'Departs');
if (is_object($trainsCmd)) {
$trainsCmd->event(json_encode($result));
}
$trains->refreshWidget();
}
}
}
}
示例11: openzwave_update
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();
}
示例12: ecodevice_remove
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();
}
}
示例13: copyFromEqLogic
public function copyFromEqLogic($_eqLogic_id)
{
$eqLogic = eqLogic::byId($_eqLogic_id);
if (!is_object($eqLogic)) {
throw new Exception(__('Impossible de trouver l\'équipement : ', __FILE__) . $_eqLogic_id);
}
if ($eqLogic->getEqType_name() == 'virtual') {
throw new Exception(__('Vous ne pouvez importer la configuration d\'un équipement virtuel', __FILE__));
}
foreach ($eqLogic->getCategory() as $key => $value) {
$this->setCategory($key, $value);
}
foreach ($eqLogic->getCmd() as $cmd_def) {
$cmd = new virtualCmd();
$cmd->setName($cmd_def->getName());
$cmd->setEqLogic_id($this->getId());
$cmd->setIsVisible($cmd_def->getIsVisible());
$cmd->setType($cmd_def->getType());
$cmd->setUnite($cmd_def->getUnite());
$cmd->setOrder($cmd_def->getOrder());
$cmd->setDisplay('icon', $cmd_def->getDisplay('icon'));
$cmd->setDisplay('invertBinary', $cmd_def->getDisplay('invertBinary'));
foreach ($cmd_def->getTemplate() as $key => $value) {
$cmd->setTemplate($key, $value);
}
$cmd->setSubType($cmd_def->getSubType());
if ($cmd->getType() == 'info') {
$cmd->setConfiguration('calcul', '#' . $cmd_def->getId() . '#');
$cmd->setValue($cmd_def->getId());
$cmd->setEventOnly(1);
} else {
$cmd->setValue($cmd_def->getValue());
$cmd->setConfiguration('infoName', '#' . $cmd_def->getId() . '#');
}
$cmd->save();
}
$this->save();
}
示例14: setIsEnable
public function setIsEnable($_state)
{
if (version_compare(jeedom::version(), $this->getRequire()) == -1 && $_state == 1) {
throw new Exception('Votre version de jeedom n\'est pas assez récente pour activer ce plugin');
}
$alreadyActive = config::byKey('active', $this->getId(), 0);
if ($_state == 1) {
if (config::byKey('jeeNetwork::mode') != 'master' && $this->getAllowRemote() != 1) {
throw new Exception('Vous ne pouvez pas activer ce plugin sur un Jeedom configuré en esclave');
}
//market::checkPayment($this->getId());
config::save('active', $_state, $this->getId());
}
if ($_state == 0) {
$eqLogics = eqLogic::byType($this->getId());
if (is_array($eqLogics)) {
foreach ($eqLogics as $eqLogic) {
try {
$eqLogic->setConfiguration('previousIsEnable', $eqLogic->getIsEnable());
$eqLogic->setConfiguration('previousIsVisible', $eqLogic->getIsVisible());
$eqLogic->setIsEnable(0);
$eqLogic->setIsVisible(0);
$eqLogic->save();
} catch (Exception $e) {
}
}
}
$listeners = listener::byClass($this->getId());
if (is_array($listeners)) {
foreach ($listeners as $listener) {
$listener->remove();
}
}
}
if ($alreadyActive == 0 && $_state == 1) {
foreach (eqLogic::byType($this->getId()) as $eqLogic) {
try {
$eqLogic->setIsEnable($eqLogic->getConfiguration('previousIsEnable', 1));
$eqLogic->setIsVisible($eqLogic->getConfiguration('previousIsVisible', 1));
$eqLogic->save();
} catch (Exception $e) {
}
}
}
try {
if ($_state == 1) {
if ($alreadyActive == 1) {
$out = $this->callInstallFunction('update');
} else {
$out = $this->callInstallFunction('install');
}
} else {
if ($alreadyActive == 1) {
$out = $this->callInstallFunction('remove');
}
}
if (isset($out) && trim($out) != '') {
log::add($this->getId(), 'info', "Installation/remove/update result : " . $out);
}
} catch (Exception $e) {
config::save('active', $alreadyActive, $this->getId());
log::add('plugin', 'error', $e->getMessage());
throw $e;
}
if ($_state == 0) {
config::save('active', $_state, $this->getId());
}
return true;
}
示例15: Exception
<?php
if (!isConnect('admin')) {
throw new Exception('{{401 - Accès non autorisé}}');
}
sendVarToJS('eqType', '#plugin_id#');
$eqLogics = eqLogic::byType('#plugin_id#');
?>
<div class="row row-overflow">
<div class="col-lg-2 col-md-3 col-sm-4">
<div class="bs-sidebar">
<ul id="ul_eqLogic" class="nav nav-list bs-sidenav">
<a class="btn btn-default eqLogicAction" style="width : 100%;margin-top : 5px;margin-bottom: 5px;" data-action="add">
<i class="fa fa-plus-circle"></i> {{Ajouter un #plugin_name#}}
</a>
<li class="filter" style="margin-bottom: 5px;"><input class="filter form-control input-sm" placeholder="{{Rechercher}}" style="width: 100%"/></li>
</ul>
<ul id="ul_eqLogicView" class="nav nav-pills nav-stacked"></ul> <!-- la sidebar -->
</div>
</div>
<div class="col-lg-10 col-md-9 col-sm-8 eqLogicThumbnailDisplay" style="border-left: solid 1px #EEE; padding-left: 25px;">
<legend>{{Mes #plugin_name#}}</legend> <!-- changer pour votre type d'équipement -->
<div class="eqLogicThumbnailContainer"></div> <!-- le container -->
</div>
<!-- Affichage de l'eqLogic sélectionné -->
<div class="col-lg-10 col-md-9 col-sm-8 eqLogic" style="border-left: solid 1px #EEE; padding-left: 25px;display: none;">
<form class="form-horizontal">