@Loic ou @Alexandre
Le plugin affiche une page vide sous Debian 10
Vu que ce plugin n’est pas sur GitHub je ne peux vous pousser la modification
Bonne journée
@Loic ou @Alexandre
Le plugin affiche une page vide sous Debian 10
Vu que ce plugin n’est pas sur GitHub je ne peux vous pousser la modification
Bonne journée
Bonjour,
Merci pour le retour je viens de pousser la correction en beta
Salut @Loic
J’ai finalisé la migration de l’affichage vers le core v4
je te joins le fichier le code ci-dessous
Je ne suis pas un expert mais voici ma proposition
<?php
if (!isConnect('admin')) {
throw new Exception('{{401 - Accès non autorisé}}');
}
include_file('3rdparty', 'datetimepicker/jquery.datetimepicker', 'css', 'energy');
$plugin = plugin::byId('energy');
sendVarToJS('eqType', $plugin->getId());
$eqLogics = eqLogic::byType($plugin->getId());
?>
<div class="row row-overflow">
<div class="col-xs-12 eqLogicThumbnailDisplay">
<legend><i class="icon loisir-two28"></i> {{Gestion}}</legend>
<div class="eqLogicThumbnailContainer">
<div class="cursor eqLogicAction logoPrimary" data-action="add" >
<i class="fas fa-plus-circle"></i>
<br/>
<span>{{Ajouter}}</span>
</div>
<div class="cursor eqLogicAction logoSecondary" data-action="gotoPluginConf">
<i class="fas fa-wrench"></i>
<br/>
<span>{{Configuration}}</span>
</div>
</div>
<legend><i class="fas fa-tachometer-alt"></i> {{Mes Energies}}</legend>
<input class="form-control" placeholder="{{Rechercher}}" id="in_searchEqlogic" />
<div class="eqLogicThumbnailContainer">
<?php
foreach ($eqLogics as $eqLogic) {
$opacity = ($eqLogic->getIsEnable()) ? '' : 'disableCard';
echo '<div class="eqLogicDisplayCard cursor '.$opacity.'" data-eqLogic_id="' . $eqLogic->getId() . '" >';
echo '<img src="' . $plugin->getPathImgIcon() . '" />';
echo '<br>';
echo '<span class="name">' . $eqLogic->getHumanName(true, true) . '</span>';
echo '</div>';
}
?>
</div>
</div>
<div class="col-xs-12 eqLogic" style="display: none;">
<div class="input-group pull-right" style="display:inline-flex">
<span class="input-group-btn">
<a class="btn btn-default btn-sm eqLogicAction" data-action="configure"><i class="fas fa-cogs"></i> {{Configuration avancée}}</a><a class="btn btn-default btn-sm eqLogicAction" data-action="copy"><i class="fas fa-copy"></i> {{Dupliquer}}</a><a class="btn btn-sm btn-success eqLogicAction" data-action="save"><i class="fas fa-check-circle"></i> {{Sauvegarder}}</a><a class="btn btn-danger btn-sm eqLogicAction roundedRight" data-action="remove"><i class="fas fa-minus-circle"></i> {{Supprimer}}</a>
</span>
</div>
<ul class="nav nav-tabs" role="tablist">
<li role="presentation"><a href="#" class="eqLogicAction" aria-controls="home" role="tab" data-toggle="tab" data-action="returnToThumbnailDisplay"><i class="fas fa-arrow-circle-left"></i></a></li>
<li role="presentation" class="active"><a href="#eqlogictab" aria-controls="home" role="tab" data-toggle="tab"><i class="fas fa-tachometer-alt"></i> {{Equipement}}</a></li>
<li role="presentation"><a href="#commandtab" aria-controls="profile" role="tab" data-toggle="tab"><i class="fas fa-list-alt"></i> {{Commandes}}</a></li>
</ul>
<div class="tab-content" style="height:calc(100% - 50px);overflow:auto;overflow-x: hidden;">
<div role="tabpanel" class="tab-pane active" id="eqlogictab">
<br/>
<form class="form-horizontal">
<fieldset>
<div class="form-group">
<label class="col-sm-2 control-label">{{Nom de l'équipement virtuel}}</label>
<div class="col-sm-3">
<input type="text" class="eqLogicAttr form-control" data-l1key="id" style="display : none;" />
<input type="text" class="eqLogicAttr form-control" data-l1key="name" placeholder="{{Nom de l'équipement virtuel}}"/>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label" >{{Objet parent}}</label>
<div class="col-sm-3">
<select class="form-control eqLogicAttr" data-l1key="object_id">
<option value="">{{Aucun}}</option>
<?php
foreach (jeeObject::all() as $object) {
echo '<option value="' . $object->getId() . '">' . $object->getName() . '</option>';
}
?>
</select>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label">{{Catégorie}}</label>
<div class="col-sm-8">
<?php
foreach (jeedom::getConfiguration('eqLogic:category') as $key => $value) {
echo '<label class="checkbox-inline">';
echo '<input type="checkbox" class="eqLogicAttr" data-l1key="category" data-l2key="' . $key . '" />' . $value['name'];
echo '</label>';
}
?>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label"></label>
<div class="col-sm-9">
<label class="checkbox-inline"><input type="checkbox" class="eqLogicAttr" data-l1key="isEnable" checked/>{{Activer}}</label>
<label class="checkbox-inline"><input type="checkbox" class="eqLogicAttr" data-l1key="isVisible" checked/>{{Visible}}</label>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label">{{Type)}}</label>
<div class="col-sm-3">
<select class="form-control eqLogicAttr" data-l1key="configuration" data-l2key="type">
<?php if (config::byKey('enableElectricity', 'energy') == 1) {?>
<option value="electricity">Electricité</option>
<?php }
?>
<?php if (config::byKey('enableWater', 'energy') == 1) {?>
<option value="water">Eau</option>
<?php }
?>
<?php if (config::byKey('enableGas', 'energy') == 1) {?>
<option value="gas">Gaz</option>
<?php }
?>
</select>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label">{{Ce compteur donne un total}}</label>
<div class="col-sm-8">
<label class="checkbox-inline"><input type="checkbox" class="eqLogicAttr" data-l1key="configuration" data-l2key="totalCounter" checked/></label>
</div>
</div>
<br />
<div class="form-group">
<label class="col-sm-2 control-label">{{Historique}}</label>
<div class="col-sm-2">
<a class="btn btn-warning btn-sm" id="bt_emptyHistory"><i class="fas fa-times"></i> Supprimer l'historique</a>
</div>
</div>
<br/>
<div class="form-group">
<legend class="col-sm-2 control-label"><i class="fas fa-eye"></i> {{Visibilité des commandes}}</legend>
</div>
<br/>
<form class="form-horizontal">
<fieldset>
<div class="form-group">
<label class="col-sm-2 control-label">{{Coût}}</label>
<div class="col-sm-1">
<label class="checkbox-inline"><input type="checkbox" class="eqLogicAttr" data-l1key="configuration" data-l2key="visibleCost" checked/></label>
</div>
<label class="col-sm-2 control-label">{{Consommation}}</label>
<div class="col-sm-1">
<label class="checkbox-inline"><input type="checkbox" class="eqLogicAttr" data-l1key="configuration" data-l2key="visibleConsumptionTotal" checked/></label>
</div>
</div>
<div class="form-group electricityOnly">
<label class="col-sm-2 control-label">{{Puissance}}</label>
<div class="col-sm-1">
<label class="checkbox-inline"><input type="checkbox" class="eqLogicAttr" data-l1key="configuration" data-l2key="visiblePower" checked/></label>
</div>
</div>
<div class="form-group electricityOnly">
<label class="col-sm-2 control-label">{{Lumière}}</label>
<div class="col-sm-1">
<label class="checkbox-inline"><input type="checkbox" class="eqLogicAttr" data-l1key="configuration" data-l2key="visibleConsumptionLight" checked/></label>
</div>
<label class="col-sm-2 control-label">{{Automatisme}}</label>
<div class="col-sm-1">
<label class="checkbox-inline"><input type="checkbox" class="eqLogicAttr" data-l1key="configuration" data-l2key="visibleConsumptionAutomatism" checked/></label>
</div>
</div>
<div class="form-group electricityOnly">
<label class="col-sm-2 control-label">{{Electromenager}}</label>
<div class="col-sm-1">
<label class="checkbox-inline"><input type="checkbox" class="eqLogicAttr" data-l1key="configuration" data-l2key="visibleConsumptionElectrical" checked/></label>
</div>
<label class="col-sm-2 control-label">{{Chauffage}}</label>
<div class="col-sm-1">
<label class="checkbox-inline"><input type="checkbox" class="eqLogicAttr" data-l1key="configuration" data-l2key="visibleConsumptionHeating" checked/></label>
</div>
</div>
<div class="form-group electricityOnly">
<label class="col-sm-2 control-label">{{Multimedia}}</label>
<div class="col-sm-1">
<label class="checkbox-inline"><input type="checkbox" class="eqLogicAttr" data-l1key="configuration" data-l2key="visibleConsumptionMultimedia" checked/></label>
</div>
<label class="col-sm-2 control-label">{{Autre}}</label>
<div class="col-sm-1">
<label class="checkbox-inline"><input type="checkbox" class="eqLogicAttr" data-l1key="configuration" data-l2key="visibleConsumptionOther" checked/></label>
</div>
</div>
</fieldset>
</form>
</fieldset>
</form>
</div>
<div role="tabpanel" class="tab-pane" id="commandtab">
<a class="btn btn-default btn-sm pull-right" id="bt_addEnergyEqLogic" style="margin-top:5px;"><i class="fas fa-plus-circle"></i> {{Ajouter un compteur}}</a>
<br/><br/>
<form class="form-horizontal">
<div id="div_confEnergy"></div>
</form>
</div>
</div>
</div>
</div>
<?php include_file('3rdparty', 'datetimepicker/jquery.datetimepicker', 'js', 'energy');?>
<?php include_file('desktop', 'energy', 'js', 'energy');?>
<?php include_file('core', 'plugin.template', 'js');?>
Bonne journée
Bonjour,
Merci pour la modification j’ai poussé en beta
c’est possible de poussé en stable
@Loic, je ne sais pas si tu as corrigé partout mais le panel le fonctionne pas non plus j’ai corrigé chez moi
panel.php
<?php
if (!isConnect()) {
throw new Exception('{{401 - Accès non autorisé}}');
}
if (init('object_id') == '') {
$_GET['object_id'] = $_SESSION['user']->getOptions('defaultDashboardObject');
}
$object = jeeObject::byId(init('object_id'));
if (!is_object($object)) {
$object = jeeObject::rootObject();
}
if (!is_object($object)) {
throw new Exception('{{Aucun objet racine trouvé}}');
}
sendVarToJs('object_id', $object->getId());
sendVarToJs('energyType', init('energyType', 'electricity'));
sendVarToJs('groupBy', init('groupBy', 'day'));
if (init('groupBy', 'day') == 'day') {
$date = array(
'start' => init('startDate', date('Y-m-d', strtotime('-31 days ' . date('Y-m-d')))),
'end' => init('endDate', date('Y-m-d')),
);
}
if (init('groupBy', 'day') == 'month') {
$date = array(
'start' => init('startDate', date('Y-m-d', strtotime('-1 year ' . date('Y-m-d')))),
'end' => init('endDate', date('Y-m-d', strtotime('+1 days' . date('Y-m-d')))),
);
}
?>
<div style="position : fixed;height:100%;width:15px;top:50px;left:0px;z-index:998;background-color:#f6f6f6;" id="bt_displayObjectList"><i class="fa fa-arrow-circle-o-right" style="color : #b6b6b6;"></i></div>
<div class="row row-overflow" id="div_energy">
<div class="col-xs-2" id="sd_objectList" style="z-index:999">
<div class="bs-sidebar">
<ul id="ul_object" class="nav nav-list bs-sidenav">
<li class="nav-header">{{Liste objets}}</li>
<li class="filter" style="margin-bottom: 5px;"><input class="filter form-control input-sm" placeholder="{{Rechercher}}" style="width: 100%"/></li>
<?php
$allObject = jeeObject::buildTree();
foreach ($allObject as $object_li) {
if ($object_li->getIsVisible() == 1) {
$margin = 15 * $object_li->parentNumber();
if ($object_li->getId() == $object->getId()) {
echo '<li class="cursor li_object active" ><a href="index.php?v=d&m=energy&p=panel&object_id=' . $object_li->getId() . '&energyType=' . init('energyType', 'electricity') . '" style="position:relative;left:' . $margin . 'px;">' . $object_li->getHumanName(true) . '</a></li>';
} else {
echo '<li class="cursor li_object" ><a href="index.php?v=d&m=energy&p=panel&object_id=' . $object_li->getId() . '&energyType=' . init('energyType', 'electricity') . '" style="position:relative;left:' . $margin . 'px;">' . $object_li->getHumanName(true) . '</a></li>';
}
}
}
?>
</ul>
</div>
</div>
<div class="col-xs-10" id="div_graphiqueDisplay">
<legend style="height: 40px;">
<i class="fa fa-picture-o"></i> <span class="objectName"></span> {{du}}
<input class="form-control input-sm in_datepicker" id='in_startDate' style="display : inline-block; width: 150px;" value='<?php echo $date['start']?>'/> {{au}}
<input class="form-control input-sm in_datepicker" id='in_endDate' style="display : inline-block; width: 150px;" value='<?php echo $date['end']?>'/>
<a class="btn btn-success btn-sm tooltips" id='bt_validChangeDate' title="{{Attention une trop grande plage de dates peut mettre très longtemps à être calculée ou même ne pas s'afficher}}">{{Ok}}</a>
<center style="display:inline-block;">
<?php if (init('energyType', 'electricity') == 'electricity') {?>
<span class='label label-success' style="font-size: 0.9em;"><span class="energyAttr" data-l1key="total" data-l2key="power"></span> W</span>
<span class='label label-primary' style="font-size: 0.9em;"><span class="energyAttr" data-l1key="total" data-l2key="consumption"></span> <span class="energyAttr" data-l1key="consumptionUnite"></span></span>
<span class='label label-default' style="font-size: 0.9em;"><span class="energyAttr" data-l1key="total" data-l2key="cost"> </span> <span class="energyAttr" data-l1key="currency"></span>
<?php } else {
?>
<span class='label label-primary' style="font-size: 0.9em;"><span class="energyAttr" data-l1key="total" data-l2key="consumption"></span> <span class="energyAttr" data-l1key="consumptionUnite"></span></span>
<span class='label label-default' style="font-size: 0.9em;"><span class="energyAttr" data-l1key="total" data-l2key="cost"> </span> <span class="energyAttr" data-l1key="currency"></span>
<?php }
?>
</center>
<span class="pull-right">
<?php
if (init('groupBy', 'day') == 'day') {
echo '<a class="btn btn-primary btn-sm" href="index.php?v=d&m=energy&p=panel&groupBy=day&energyType=' . init('energyType', 'electricity') . '&object_id=' . $object->getId() . '">{{Jour}}</a> ';
} else {
echo '<a class="btn btn-default btn-sm" href="index.php?v=d&m=energy&p=panel&groupBy=day&energyType=' . init('energyType', 'electricity') . '&object_id=' . $object->getId() . '">{{Jour}}</a> ';
}
if (init('groupBy', 'day') == 'month') {
echo '<a class="btn btn-primary btn-sm" href="index.php?v=d&m=energy&p=panel&groupBy=month&energyType=' . init('energyType', 'electricity') . '&object_id=' . $object->getId() . '">{{Mois}}</a> ';
} else {
echo '<a class="btn btn-default btn-sm" href="index.php?v=d&m=energy&p=panel&groupBy=month&energyType=' . init('energyType', 'electricity') . '&object_id=' . $object->getId() . '">{{Mois}}</a> ';
}
?>
<span class="pull-right">
<?php
if (config::byKey('enableElectricity', 'energy') == 1) {
if (init('energyType', 'electricity') == 'electricity') {
echo '<a class="btn btn-success btn-sm" href="index.php?v=d&m=energy&p=panel&groupBy=' . init('groupBy', 'day') . 'energyType=electricity&object_id=' . $object->getId() . '"><i class="fa fa-bolt"></i> Electricité</a> ';
} else {
echo '<a class="btn btn-default btn-sm" href="index.php?v=d&m=energy&p=panel&groupBy=' . init('groupBy', 'day') . '&energyType=electricity&object_id=' . $object->getId() . '"><i class="fa fa-bolt"></i> Electricité</a> ';
}
}
if (config::byKey('enableWater', 'energy') == 1) {
if (init('energyType', 'electricity') == 'water') {
echo '<a class="btn btn-success btn-sm" href="index.php?v=d&m=energy&groupBy=' . init('groupBy', 'day') . '&p=panel&energyType=water&object_id=' . $object->getId() . '"><i class="fa fa-tint"></i> Eau</a> ';
} else {
echo '<a class="btn btn-default btn-sm" href="index.php?v=d&m=energy&groupBy=' . init('groupBy', 'day') . '&p=panel&energyType=water&object_id=' . $object->getId() . '"><i class="fa fa-tint"></i> Eau</a> ';
}
}
if (config::byKey('enableGas', 'energy') == 1) {
if (init('energyType', 'electricity') == 'gas') {
echo '<a class="btn btn-success btn-sm" href="index.php?v=d&m=energy&groupBy=' . init('groupBy', 'day') . '&p=panel&energyType=gas&object_id=' . $object->getId() . '"><i class="fa fa-fire"></i> Gaz</a> ';
} else {
echo '<a class="btn btn-default btn-sm" href="index.php?v=d&m=energy&groupBy=' . init('groupBy', 'day') . '&p=panel&energyType=gas&object_id=' . $object->getId() . '"><i class="fa fa-fire"></i> Gaz</a> ';
}
}
?>
</span>
</legend>
<?php if (init('energyType', 'electricity') == 'electricity') {
?>
<div class="row">
<div class="col-lg-6">
<legend><i class="icon techno-courbes3"></i> {{Puissance (15min/1h)}} <input id="cb_powerLissage" data-href="<?php echo 'index.php?v=d&m=energy&groupBy=' . init('groupBy', 'day') . '&p=panel&energyType=' . init('energyType', 'electricity') . '&object_id=' . init('object_id', 'day')?>" type="checkbox" data-off-color="warning" <?php if (init('powerDisplay', '1h') == '1h') {echo 'checked';}
?> class="pull-right"/></legend>
<div id='div_graphPower'></div>
</div>
<div class="col-lg-6">
<legend><i class="fa fa-eur"></i> {{Coût}}</legend>
<div id='div_graphCost'></div>
</div>
</div>
<div class="row">
<div class="col-lg-6">
<legend><i class="icon techno-courbes4"></i> {{Consommation par objet}}</legend>
<div id='div_graphDetailConsumptionByObject'></div>
</div>
<div class="col-lg-6">
<legend><i class="icon techno-courbes2"></i> {{Consommation par catégorie}}</legend>
<div id='div_graphDetailConsumptionByCategorie'></div>
</div>
</div>
<?php } else {?>
<legend><i class="fa fa-eur"></i> {{Coût}}</legend>
<div id='div_graphCost'></div>
<legend><i class="icon techno-courbes2"></i> {{Consommation}}</legend>
<div id='div_graphDetailConsumption'></div>
<?php }
?>
</div>
</div>
<?php include_file('desktop', 'panel', 'js', 'energy');?>
energie.class.php
<?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/>.
*/
/* * ***************************Includes********************************* */
require_once dirname(__FILE__) . '/../../../../core/php/core.inc.php';
class energy extends eqLogic {
/* * *************************Attributs****************************** */
/* * ***********************Méthodes statiques*************************** */
public static function getConfEnergyKey($_confEnergy, $_position = 0) {
$key = '';
if (isset($_confEnergy['power']) && $_confEnergy['power'] != '') {
preg_match_all("/#([0-9]*)#/", $_confEnergy['power'], $matches);
foreach ($matches[1] as $cmd_id) {
$key .= '#' . $cmd_id . '#';
}
}
if (isset($_confEnergy['consumption']) && $_confEnergy['consumption'] != '') {
preg_match_all("/#([0-9]*)#/", $_confEnergy['consumption'], $matches);
foreach ($matches[1] as $cmd_id) {
$key .= '#' . $cmd_id . '#';
}
}
if ($key === '') {
$key = $_position;
}
return $key;
}
public static function cron15() {
$datetime = date('Y-m-d H:i:00');
$powerTotal = 0;
foreach (self::byType('energy') as $energy) {
if ($energy->getConfiguration('type') == 'electricity') {
$totalConsumption = 0;
$power = 0;
$consumptions = array('other' => 0, 'light' => 0, 'multimedia' => 0, 'heating' => 0, 'electrical' => 0, 'automatism' => 0, 'hc' => 0, 'hp' => 0);
$position = 0;
foreach ($energy->getConfiguration('confEnergy') as $confEnergy) {
$key = self::getConfEnergyKey($confEnergy, $position);
if ($confEnergy['power'] != '') {
$value = floatval(jeedom::evaluateExpression($confEnergy['power']));
$power += $value;
if ($confEnergy['consumption'] == '') {
$nowtime = strtotime('now');
$lastChange = $energy->getConfiguration('lastChangeTime' . $key);
$lastValue = $energy->getConfiguration('lastValue' . $key);
$consumptions[$confEnergy['category']] += (($lastValue * ($nowtime - $lastChange)) / 3600) / 1000;
$energy->setConfiguration('lastChangeTime' . $key, $nowtime);
$energy->setConfiguration('lastValue' . $key, $value);
}
}
if ($confEnergy['consumption'] != '') {
$previous = $energy->getConfiguration('previous' . $key, 0);
$value = floatval(jeedom::evaluateExpression($confEnergy['consumption']));
if (($value - $previous) >= 0) {
$consumptions[$confEnergy['category']] += ($value - $previous);
$energy->setConfiguration('previous' . $key, $value);
}
}
$position++;
}
$energy->save();
foreach ($consumptions as $name => $consumption) {
if ($energy->getConfiguration('totalCounter') == 0 && $consumption > 0) {
$cmd = $energy->getCmd(null, 'consumption' . ucfirst($name));
if (is_object($cmd)) {
$previous = $cmd->execCmd();
$cmd->setCollectDate($datetime);
$cmd->event($consumption + $previous);
}
}
$totalConsumption += $consumption;
}
if ($consumptions['hc'] > 0) {
$cmd = $energy->getCmd(null, 'consumptionHc');
if (is_object($cmd)) {
$previous = $cmd->execCmd();
$cmd->setCollectDate($datetime);
log::add('energy', 'debug', 'HC : ' . $consumptions['hc'] . '+' . $previous);
$cmd->event($consumptions['hc'] + $previous);
}
}
if ($consumptions['hp'] > 0) {
$cmd = $energy->getCmd(null, 'consumptionHp');
if (is_object($cmd)) {
$previous = $cmd->execCmd();
$cmd->setCollectDate($datetime);
log::add('energy', 'debug', 'HP : ' . $consumptions['hp'] . '+' . $previous);
$cmd->event($consumptions['hp'] + $previous);
}
}
if ($totalConsumption > 0) {
$cmd = $energy->getCmd(null, 'consumptionTotal');
if (is_object($cmd)) {
$previous = $cmd->execCmd();
$cmd->setCollectDate($datetime);
log::add('energy', 'debug', 'Total : ' . $totalConsumption . '+' . $previous);
$cmd->event($totalConsumption + $previous);
}
$calculCost = 0;
if (config::byKey('rateMode', 'energy') == 'variable') {
if ($consumptions['hp'] != 0 || $consumptions['hp'] != 0) {
$calculCost = $consumptions['hp'] * str_replace(',', '.', config::byKey('rateHp', 'energy')) + $consumptions['hc'] * str_replace(',', '.', config::byKey('rateHc', 'energy'));
} else {
$rateHour = array(
'startHp' => intval(ltrim(str_replace(':', '', config::byKey('startHc', 'energy', -1)), '0')),
'endHp' => intval(ltrim(str_replace(':', '', config::byKey('endHc', 'energy', -1)), '0')),
'startHp2' => intval(ltrim(str_replace(':', '', config::byKey('startHc2', 'energy'-1)), '0')),
'endHp2' => intval(ltrim(str_replace(':', '', config::byKey('endHc2', 'energy', -1)), '0')),
'startHp3' => intval(ltrim(str_replace(':', '', config::byKey('startHc3', 'energy', -1)), '0')),
'endHp3' => intval(ltrim(str_replace(':', '', config::byKey('endHc3', 'energy', -1)), '0')),
'rateHp' => str_replace(',', '.', config::byKey('rateHp', 'energy', 0)),
'rateHc' => str_replace(',', '.', config::byKey('rateHc', 'energy', 0)),
);
$hourtime = date('Gi', strtotime($datetime));
if ($hourtime >= $rateHour['startHp'] && $hourtime <= $rateHour['endHp'] && $rateHour['startHp'] !== '' && $rateHour['endHp'] !== '') {
$calculCost = $totalConsumption * $rateHour['rateHc'];
}
if ($hourtime >= $rateHour['startHp2'] && $hourtime <= $rateHour['endHp2'] && $rateHour['startHp2'] !== '' && $rateHour['endHp2'] !== '') {
$calculCost = $totalConsumption * $rateHour['rateHc'];
}
if ($hourtime >= $rateHour['startHp3'] && $hourtime <= $rateHour['endHp3'] && $rateHour['startHp3'] !== '' && $rateHour['endHp3'] !== '') {
$calculCost = $totalConsumption * $rateHour['rateHc'];
}
if ($calculCost == 0) {
$calculCost = $totalConsumption * $rateHour['rateHp'];
}
}
} else {
$cost = jeedom::evaluateExpression(str_replace(',', '.', config::byKey('rate', 'energy', 0)));
$calculCost = $totalConsumption * $cost;
}
$cmd = $energy->getCmd(null, 'cost');
if (is_object($cmd)) {
$previous = $cmd->execCmd();
$cmd->setCollectDate($datetime);
$cmd->event($calculCost + $previous);
}
}
$cmd = $energy->getCmd(null, 'power');
if (is_object($cmd)) {
$cmd->setCollectDate($datetime);
$cmd->event($power);
}
} else {
$totalConsumption = 0;
$position = 0;
foreach ($energy->getConfiguration('confEnergy') as $confEnergy) {
$key = self::getConfEnergyKey($confEnergy, $position);
$previous = $energy->getConfiguration('previous' . $key, 0);
$value = floatval(evaluate(cmd::cmdToValue($confEnergy['consumption'])));
if (($value - $previous) >= 0) {
$totalConsumption += ($value - $previous);
$energy->setConfiguration('previous' . $key, $value);
}
$position++;
}
$energy->save();
if ($totalConsumption > 0) {
$cmd = $energy->getCmd(null, 'consumptionTotal');
if (is_object($cmd)) {
$previous = $cmd->execCmd();
$cmd->setCollectDate($datetime);
$cmd->event($totalConsumption + $previous);
}
$cost = $cost = jeedom::evaluateExpression(str_replace(',', '.', config::byKey('rate' . ucfirst($energy->getConfiguration('type')), 'energy', 0)));
$calculCost = $totalConsumption * $cost;
$cmd = $energy->getCmd(null, 'cost');
if (is_object($cmd)) {
$previous = $cmd->execCmd();
$cmd->setCollectDate($datetime);
$cmd->event($calculCost + $previous);
}
}
}
}
}
public static function cronDaily() {
sleep(60);
$datetime = date('Y-m-d 00:00:00');
foreach (self::byType('energy') as $energy) {
$cmd = $energy->getCmd(null, 'cost');
if (is_object($cmd)) {
$cmd->setCollectDate($datetime);
$cmd->event(0);
}
$cmd = $energy->getCmd(null, 'consumptionOther');
if (is_object($cmd)) {
$cmd->setCollectDate($datetime);
$cmd->event(0);
}
$cmd = $energy->getCmd(null, 'consumptionLight');
if (is_object($cmd)) {
$cmd->setCollectDate($datetime);
$cmd->event(0);
}
$cmd = $energy->getCmd(null, 'consumptionMultimedia');
if (is_object($cmd)) {
$cmd->setCollectDate($datetime);
$cmd->event(0);
}
$cmd = $energy->getCmd(null, 'consumptionAutomatism');
if (is_object($cmd)) {
$cmd->setCollectDate($datetime);
$cmd->event(0);
}
$cmd = $energy->getCmd(null, 'consumptionElectrical');
if (is_object($cmd)) {
$cmd->setCollectDate($datetime);
$cmd->event(0);
}
$cmd = $energy->getCmd(null, 'consumptionHeating');
if (is_object($cmd)) {
$cmd->setCollectDate($datetime);
$cmd->event(0);
}
$cmd = $energy->getCmd(null, 'consumptionTotal');
if (is_object($cmd)) {
$cmd->setCollectDate($datetime);
$cmd->event(0);
}
$cmd = $energy->getCmd(null, 'consumptionHp');
if (is_object($cmd)) {
$cmd->setCollectDate($datetime);
$cmd->event(0);
}
$cmd = $energy->getCmd(null, 'consumptionHc');
if (is_object($cmd)) {
$cmd->setCollectDate($datetime);
$cmd->event(0);
}
}
}
public static function getGraph($_startTime = null, $_endTime = null, $_object_id, $_energyType = 'electricity') {
$return = array(
'category' => array('other' => array(), 'light' => array(), 'multimedia' => array(), 'heating' => array(), 'electrical' => array(), 'automatism' => array()),
'cost' => array(),
'translation' => array('other' => __('Autre', __FILE__), 'light' => __('Lumière', __FILE__), 'multimedia' => __('Multimedia', __FILE__), 'heating' => __('Chauffage', __FILE__), 'electrical' => __('Electroménager', __FILE__), 'automatism' => __('Automatisme', __FILE__)),
'object' => array(),
'total' => array('power' => 0, 'consumption' => 0, 'cost' => 0),
'consumptionUnite' => 'kWh',
'power' => array(),
);
if ($_energyType == 'water') {
$return['consumptionUnite'] = 'L';
}
$object = jeeObject::byId($_object_id);
if (!is_object($object)) {
throw new Exception(__('Objet non trouvé. Vérifiez l\'id : ', __FILE__) . $_object_id);
}
$objects = $object->getChilds();
$objects[] = $object;
foreach ($objects as $object) {
$return['object'][$object->getName()] = array();
$return['power'][$object->getName()] = array();
foreach ($object->getEqLogic(true, false, 'energy') as $energy) {
if ($energy->getConfiguration('type') != $_energyType) {
continue;
}
$cmd = $energy->getCmd(null, 'power');
if (is_object($cmd)) {
$return['total']['power'] += $cmd->execCmd();
foreach ($cmd->getHistory($_startTime, date('Y-m-d 23:59:59', strtotime($_endTime))) as $value) {
$datetime = floatval(strtotime($value->getDatetime() . " UTC")) * 1000;
if (isset($return['power'][$object->getName()][$datetime])) {
$return['power'][$object->getName()][$datetime][1] += floatval($value->getValue());
} else {
$return['power'][$object->getName()][$datetime] = array($datetime, floatval($value->getValue()));
}
}
}
if ($energy->getConfiguration('totalCounter') == 1) {
continue;
}
foreach ($energy->getData($_startTime, $_endTime) as $key => $values) {
foreach ($values as $value) {
if (!is_numeric($value[1]) || $value[1] == 0) {
continue;
}
$value[0] = floatval(strtotime($value[0] . " UTC")) * 1000;
if ($key == 'cost') {
$return['total']['cost'] += floatval($value[1]);
if (isset($return['cost'][$value[0]])) {
$return['cost'][$value[0]][1] += floatval($value[1]);
} else {
$return['cost'][$value[0]] = array($value[0], floatval($value[1]));
}
continue;
}
$return['total']['consumption'] += floatval($value[1]);
if (isset($return['category'][$key][$value[0]])) {
$return['category'][$key][$value[0]][1] += floatval($value[1]);
} else {
$return['category'][$key][$value[0]] = array($value[0], floatval($value[1]));
}
if (isset($return['object'][$object->getName()][$value[0]])) {
$return['object'][$object->getName()][$value[0]][1] += floatval($value[1]);
} else {
$return['object'][$object->getName()][$value[0]] = array($value[0], floatval($value[1]));
}
}
}
}
}
foreach ($object->getEqLogic(true, false, 'energy') as $energy) {
if ($energy->getConfiguration('type') == $_energyType && $energy->getConfiguration('totalCounter') == 1) {
$return['totalConsumption'] = array();
$return['cost'] = array();
$cmd = $energy->getCmd(null, 'consumptionTotal');
if (is_object($cmd)) {
$return['total']['consumption'] = 0;
foreach ($cmd->getHistoryEnergy($_startTime, $_endTime) as $value) {
if (!is_numeric($value[1]) || $value[1] == 0) {
continue;
}
$value[0] = floatval(strtotime($value[0] . " UTC")) * 1000;
if (isset($return['totalConsumption'][$value[0]])) {
$return['totalConsumption'][$value[0]][1] += floatval($value[1]);
} else {
$return['totalConsumption'][$value[0]] = array($value[0], floatval($value[1]));
}
$return['total']['consumption'] += floatval($value[1]);
}
}
$cmd = $energy->getCmd(null, 'cost');
if (is_object($cmd)) {
$return['total']['cost'] = 0;
foreach ($cmd->getHistoryEnergy($_startTime, $_endTime) as $value) {
if (!is_numeric($value[1]) || $value[1] == 0) {
continue;
}
$value[0] = floatval(strtotime($value[0] . " UTC")) * 1000;
if (isset($return['cost'][$value[0]])) {
$return['cost'][$value[0]][1] += floatval($value[1]);
} else {
$return['cost'][$value[0]] = array($value[0], floatval($value[1]));
}
$return['total']['cost'] += floatval($value[1]);
}
}
break;
}
}
if (isset($return['totalConsumption'])) {
$return['totalConsumption'] = array_values($return['totalConsumption']);
}
if (isset($return['cost'])) {
sort($return['cost']);
$return['cost'] = array_values($return['cost']);
}
foreach ($return['power'] as &$value) {
sort($value);
$value = array_values($value);
}
foreach ($return['category'] as &$value) {
sort($value);
$value = array_values($value);
}
foreach ($return['object'] as &$value) {
sort($value);
$value = array_values($value);
}
$return['total']['consumption'] = round($return['total']['consumption'], 2);
$return['total']['cost'] = round($return['total']['cost'], 2);
return $return;
}
/* * *********************Méthodes d'instance************************* */
public function getData($_startTime = null, $_endTime = null) {
$return = array('other' => array(), 'light' => array(), 'multimedia' => array(), 'heating' => array(), 'electrical' => array(), 'automatism' => array(), 'cost' => array());
$cmd = $this->getCmd(null, 'consumptionOther');
if (is_object($cmd)) {
$return['other'] = $cmd->getHistoryEnergy($_startTime, $_endTime);
}
$cmd = $this->getCmd(null, 'consumptionLight');
if (is_object($cmd)) {
$return['light'] = $cmd->getHistoryEnergy($_startTime, $_endTime);
}
$cmd = $this->getCmd(null, 'consumptionMultimedia');
if (is_object($cmd)) {
$return['multimedia'] = $cmd->getHistoryEnergy($_startTime, $_endTime);
}
$cmd = $this->getCmd(null, 'consumptionAutomatism');
if (is_object($cmd)) {
$return['automatism'] = $cmd->getHistoryEnergy($_startTime, $_endTime);
}
$cmd = $this->getCmd(null, 'consumptionElectrical');
if (is_object($cmd)) {
$return['electrical'] = $cmd->getHistoryEnergy($_startTime, $_endTime);
}
$cmd = $this->getCmd(null, 'consumptionHeating');
if (is_object($cmd)) {
$return['heating'] = $cmd->getHistoryEnergy($_startTime, $_endTime);
}
$cmd = $this->getCmd(null, 'cost');
if (is_object($cmd)) {
$return['cost'] = $cmd->getHistoryEnergy($_startTime, $_endTime);
}
return $return;
}
public function emptyHistory() {
foreach ($this->getCmd('info') as $cmd) {
history::emptyHistory($cmd->getId());
$cmd->save();
$cmd->event(0);
}
foreach ($this->getConfiguration('confEnergy') as $confEnergy) {
$key = self::getConfEnergyKey($confEnergy);
if ($this->getConfiguration('type') == 'electricity') {
$this->setConfiguration('lastChangeTime' . $key, strtotime('now'));
$this->setConfiguration('lastValue' . $key, 0);
if ($confEnergy['consumption'] != '') {
$this->setConfiguration('previous' . $key, floatval(evaluate(cmd::cmdToValue($confEnergy['consumption']))));
}
} else {
if ($confEnergy['consumption'] != '') {
$this->setConfiguration('previous' . $key, floatval(evaluate(cmd::cmdToValue($confEnergy['consumption']))));
}
}
}
$this->save();
}
public function preInsert() {
$this->setConfiguration('visiblePower', 1);
$this->setConfiguration('visibleCost', 1);
$this->setConfiguration('visibleConsumptionTotal', 1);
}
public function preUpdate() {
if ($this->getConfiguration('type') == '') {
throw new Exception('Le type ne peut pas être vide');
}
$this->setCategory('energy', 1);
}
public function postSave() {
$cmd = $this->getCmd(null, 'cost');
if (!is_object($cmd)) {
$cmd = new energyCmd();
$cmd->setLogicalId('cost');
$cmd->setName(__('Coût', __FILE__));
$cmd->setTemplate('dashboard', 'tile');
}
$cmd->setEqLogic_id($this->getId());
$cmd->setType('info');
$cmd->setSubType('numeric');
$cmd->setUnite(config::byKey('currency', 'energy', '€'));
$cmd->setIsVisible($this->getConfiguration('visibleCost', 0));
$cmd->setIsHistorized(1);
$cmd->save();
$unite = '';
if ($this->getConfiguration('type') == 'electricity') {
$unite = 'kWh';
} elseif ($this->getConfiguration('type') == 'water') {
$unite = 'L';
} elseif ($this->getConfiguration('type') == 'gas') {
$unite = 'kWh';
}
$cmd = $this->getCmd(null, 'consumptionTotal');
if (!is_object($cmd)) {
$cmd = new energyCmd();
$cmd->setLogicalId('consumptionTotal');
$cmd->setTemplate('dashboard', 'tile');
$cmd->setConfiguration('historizeMode', 'max');
$cmd->setIsHistorized(1);
}
$cmd->setName(__('Consommation', __FILE__));
$cmd->setEqLogic_id($this->getId());
$cmd->setType('info');
$cmd->setSubType('numeric');
$cmd->setUnite($unite);
$cmd->setIsVisible($this->getConfiguration('visibleConsumptionTotal', 0));
$cmd->save();
if ($this->getConfiguration('type') == 'electricity') {
$cmd = $this->getCmd(null, 'power');
if (!is_object($cmd)) {
$cmd = new energyCmd();
$cmd->setLogicalId('power');
$cmd->setName(__('Puissance', __FILE__));
$cmd->setTemplate('dashboard', 'tile');
}
$cmd->setEqLogic_id($this->getId());
$cmd->setType('info');
$cmd->setSubType('numeric');
$cmd->setUnite('W');
$cmd->setIsHistorized(1);
$cmd->setIsVisible($this->getConfiguration('visiblePower', 0));
$cmd->save();
$cmd = $this->getCmd(null, 'consumptionLight');
if (!is_object($cmd)) {
$cmd = new energyCmd();
$cmd->setLogicalId('consumptionLight');
$cmd->setTemplate('dashboard', 'tile');
$cmd->setConfiguration('historizeMode', 'max');
$cmd->setIsHistorized(1);
}
$cmd->setName(__('Consommation Lumière', __FILE__));
$cmd->setEqLogic_id($this->getId());
$cmd->setType('info');
$cmd->setSubType('numeric');
$cmd->setUnite($unite);
$cmd->setIsVisible($this->getConfiguration('visibleConsumptionLight', 0));
$cmd->save();
$cmd = $this->getCmd(null, 'consumptionOther');
if (!is_object($cmd)) {
$cmd = new energyCmd();
$cmd->setLogicalId('consumptionOther');
$cmd->setTemplate('dashboard', 'tile');
$cmd->setConfiguration('historizeMode', 'max');
$cmd->setIsHistorized(1);
}
$cmd->setName(__('Consommation Autre', __FILE__));
$cmd->setEqLogic_id($this->getId());
$cmd->setType('info');
$cmd->setSubType('numeric');
$cmd->setUnite($unite);
$cmd->setIsVisible($this->getConfiguration('visibleConsumptionOther', 0));
$cmd->save();
$cmd = $this->getCmd(null, 'consumptionMultimedia');
if (!is_object($cmd)) {
$cmd = new energyCmd();
$cmd->setLogicalId('consumptionMultimedia');
$cmd->setTemplate('dashboard', 'tile');
$cmd->setConfiguration('historizeMode', 'max');
$cmd->setIsHistorized(1);
}
$cmd->setName(__('Consommation Multimedia', __FILE__));
$cmd->setEqLogic_id($this->getId());
$cmd->setType('info');
$cmd->setSubType('numeric');
$cmd->setUnite($unite);
$cmd->setIsVisible($this->getConfiguration('visibleConsumptionMultimedia', 0));
$cmd->save();
$cmd = $this->getCmd(null, 'consumptionAutomatism');
if (!is_object($cmd)) {
$cmd = new energyCmd();
$cmd->setLogicalId('consumptionAutomatism');
$cmd->setTemplate('dashboard', 'tile');
$cmd->setConfiguration('historizeMode', 'max');
$cmd->setIsHistorized(1);
}
$cmd->setName(__('Consommation Automatisme', __FILE__));
$cmd->setEqLogic_id($this->getId());
$cmd->setType('info');
$cmd->setSubType('numeric');
$cmd->setUnite($unite);
$cmd->setIsVisible($this->getConfiguration('visibleConsumptionAutomatism', 0));
$cmd->save();
$cmd = $this->getCmd(null, 'consumptionElectrical');
if (!is_object($cmd)) {
$cmd = new energyCmd();
$cmd->setLogicalId('consumptionElectrical');
$cmd->setTemplate('dashboard', 'tile');
$cmd->setConfiguration('historizeMode', 'max');
$cmd->setIsHistorized(1);
}
$cmd->setName(__('Consommation Electromenager', __FILE__));
$cmd->setEqLogic_id($this->getId());
$cmd->setType('info');
$cmd->setSubType('numeric');
$cmd->setUnite($unite);
$cmd->setIsVisible($this->getConfiguration('visibleConsumptionElectrical', 0));
$cmd->save();
$cmd = $this->getCmd(null, 'consumptionHeating');
if (!is_object($cmd)) {
$cmd = new energyCmd();
$cmd->setLogicalId('consumptionHeating');
$cmd->setTemplate('dashboard', 'tile');
$cmd->setConfiguration('historizeMode', 'max');
$cmd->setIsHistorized(1);
}
$cmd->setName(__('Consommation Chauffage', __FILE__));
$cmd->setEqLogic_id($this->getId());
$cmd->setType('info');
$cmd->setSubType('numeric');
$cmd->setUnite($unite);
$cmd->setIsVisible($this->getConfiguration('visibleConsumptionHeating', 0));
$cmd->save();
$cmd = $this->getCmd(null, 'consumptionHp');
if (!is_object($cmd)) {
$cmd = new energyCmd();
$cmd->setLogicalId('consumptionHP');
$cmd->setTemplate('dashboard', 'tile');
$cmd->setConfiguration('historizeMode', 'max');
$cmd->setIsHistorized(1);
}
$cmd->setName(__('Consommation HP', __FILE__));
$cmd->setEqLogic_id($this->getId());
$cmd->setType('info');
$cmd->setSubType('numeric');
$cmd->setUnite($unite);
$cmd->setIsVisible($this->getConfiguration('visibleConsumptionHP', 0));
$cmd->save();
$cmd = $this->getCmd(null, 'consumptionHc');
if (!is_object($cmd)) {
$cmd = new energyCmd();
$cmd->setLogicalId('consumptionHC');
$cmd->setTemplate('dashboard', 'tile');
$cmd->setConfiguration('historizeMode', 'max');
$cmd->setIsHistorized(1);
}
$cmd->setName(__('Consommation HC', __FILE__));
$cmd->setEqLogic_id($this->getId());
$cmd->setType('info');
$cmd->setSubType('numeric');
$cmd->setUnite($unite);
$cmd->setIsVisible($this->getConfiguration('visibleConsumptionHC', 0));
$cmd->save();
} else {
$this->setConfiguration('totalCounter', 1);
}
}
/* * **********************Getteur Setteur*************************** */
}
class energyCmd extends cmd {
/* * *************************Attributs****************************** */
/* * ***********************Méthodes statiques*************************** */
/* * *********************Méthodes d'instance************************* */
public function formatValueWidget($_value) {
if ($this->getType() == 'info' && $this->getSubType() == 'numeric') {
return round($_value, 2);
}
return $_value;
}
public function getHistoryEnergy($_startTime = null, $_endTime = null) {
$values = array(
'cmd_id' => $this->getId(),
);
if ($_startTime != null) {
$values['startTime'] = date('Y-m-d H:i:s', strtotime('+1 hours ' . $_startTime));
}
if ($_endTime != null) {
$values['endTime'] = date('Y-m-d H:i:s', strtotime('+1 day ' . $_endTime));
}
$sql = '
SELECT date(`datetime`) as "0", MAX(CAST(value as DOUBLE)) as "1"
FROM (
SELECT (`datetime` - INTERVAL 240 SECOND) as `datetime`,value
FROM history
WHERE cmd_id=:cmd_id ';
if ($_startTime != null) {
$sql .= ' AND `datetime`>=:startTime';
}
if ($_endTime != null) {
$sql .= ' AND `datetime`<=:endTime';
}
$sql .= ' UNION ALL
SELECT (`datetime` - INTERVAL 240 SECOND) as `datetime`,value
FROM historyArch
WHERE cmd_id=:cmd_id';
if ($_startTime != null) {
$sql .= ' AND `datetime`>=:startTime';
}
if ($_endTime != null) {
$sql .= ' AND `datetime`<=:endTime';
}
$sql .= ' ) as dt
GROUP BY date(`datetime`)
ORDER BY `datetime` ASC;';
try{
return DB::Prepare($sql, $values, DB::FETCH_TYPE_ALL);
}catch(Exception $e) {
$sql = 'SET sql_mode=(SELECT REPLACE(@@sql_mode, "ONLY_FULL_GROUP_BY", ""));' . $sql . 'SET sql_mode=(SELECT CONCAT(@@sql_mode,",ONLY_FULL_GROUP_BY"))';
return DB::Prepare($sql, $values, DB::FETCH_TYPE_ALL);
}
}
public function dontRemoveCmd() {
return true;
}
public function execute($_options = array()) {
return;
}
/* * **********************Getteur Setteur*************************** */
}
?>
energie.ajax.php
<?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/>.
*/
try {
require_once dirname(__FILE__) . '/../../../../core/php/core.inc.php';
include_file('core', 'authentification', 'php');
if (!isConnect()) {
throw new Exception(__('401 - Accès non autorisé', __FILE__));
}
if (init('action') == 'applyCostTo') {
if (init('cost') == '') {
throw new Exception(__('Vous devez d\'abord enregistrer le coût avant de pouvoir l\'appliquer : ', __FILE__) . init('cost'));
}
$cost = config::byKey(init('cost'), 'energy');
if (!is_array($cost)) {
throw new Exception(__('Aucun coût trouvé : ', __FILE__) . init('cost'));
}
$ids = json_decode(init('ids'), true);
foreach ($ids as $id) {
$eqLogic = eqLogic::byId($id);
if (!is_object($eqLogic) || $eqLogic->getEqType_name() != 'energy') {
continue;
}
$eqLogic->setConfiguration('rateMode', $cost['rateMode']);
$eqLogic->setConfiguration('rate', $cost['rate']);
$eqLogic->setConfiguration('rateHp', $cost['rateHp']);
$eqLogic->setConfiguration('rateHc', $cost['rateHc']);
$eqLogic->setConfiguration('startHc', $cost['startHc']);
$eqLogic->setConfiguration('endHc', $cost['endHc']);
$eqLogic->setConfiguration('startHc2', $cost['startHc2']);
$eqLogic->setConfiguration('endHc2', $cost['endHc2']);
$eqLogic->setConfiguration('startHc3', $cost['startHc3']);
$eqLogic->setConfiguration('endHc3', $cost['endHc3']);
$eqLogic->save();
}
ajax::success();
}
if (init('action') == 'getData') {
if (init('object_id') == '') {
$_GET['object_id'] = $_SESSION['user']->getOptions('defaultDashboardObject');
}
$object = jeeObject::byId(init('object_id'));
if (!is_object($object)) {
$object = jeeObject::rootObject();
}
if (!is_object($object)) {
throw new Exception('{{Aucun objet racine trouvé}}');
}
$date = array(
'start' => init('dateStart'),
'end' => init('dateEnd'),
);
if ($date['start'] == '') {
$date['start'] = date('Y-m-d', strtotime('-1 month'));
if (init('groupBy', 'day') == 'month') {
$date['start'] = date('Y-m-d', strtotime('-1 year'));
}
}
if ($date['end'] == '') {
$date['end'] = date('Y-m-d');
}
$energy = energy::getGraph($date['start'] . ' 00:00:00', $date['end'], $object->getId(), init('energyType'));
ajax::success(array(
'datas' => $energy,
'date' => $date,
'object' => utils::o2a($object),
'currency' => config::byKey('currency', 'energy', '€'),
'enableElectricity' => config::byKey('enableElectricity', 'energy'),
'enableWater' => config::byKey('enableWater', 'energy'),
'enableGas' => config::byKey('enableGas', 'energy'),
));
}
if (init('action') == 'emptyHistory') {
$eqLogic = eqLogic::byId(init('id'));
if (!is_object($eqLogic)) {
throw new Exception(__('Equipement introuvable : ', __FILE__) . init('id'));
}
$eqLogic->emptyHistory();
ajax::success();
}
throw new Exception(__('Aucune méthode correspondante à : ', __FILE__) . init('action'));
/* * *********Catch exeption*************** */
} catch (Exception $e) {
ajax::error(displayExeption($e), $e->getCode());
}
?>
Faudrait peut-être pas mettre le code d’un plugin payant sur un forum… meme si c’est espace réservé aux partenaires.
Merci pour le retour, pouvez vous demain me confirmer que dans la beta tout est bon ? Si c’est le cas je pousserais en stable
Je vais l’installer sur ma dev car la je l’ai mis a jours sur ma prod
Désolé je n’ai pas eu le temps de regarder avant
Je pense que tu as mélange le panel et la configuration car je me retrouve avec la page du panel sur la conf et un erreur sur le panel
A oui effectivement, ca sera bon demain en beta
C’est ok pour moi
Top je me note qu’il faut faire une stable du plugin pour la semaine prochaine