Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

4.8.7 #213

Open
wants to merge 21 commits into
base: develop
Choose a base branch
from
Open

4.8.7 #213

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

core/class/teleinfo.class - copie.php

ressources/teleinfo - Copie.py
resources/teleinfo - Copie.py

.coveralls.yml

Expand All @@ -15,4 +15,9 @@ ressources/teleinfo - Copie.py

.travis.yml

ressources/venv/
resources/venv/




sauvegarde/
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@ Lien vers le forum [ici](https://community.jeedom.com/tag/plugin-teleinfo)

## Documentation

Version stable: [Cliquer ici](https://NextDom.github.io/plugin-teleinfo/)
Version stable: [Cliquer ici](https://github.com/Noyax-37/plugin-teleinfo/blob/master/docs/fr_FR/index.md)

Version bêta: [Cliquer ici](https://noyax.github.io/plugin-teleinfo/fr_FR/)
Version bêta: [Cliquer ici](https://github.com/Noyax-37/plugin-teleinfo/blob/develop/docs/fr_FR/index.md)
85 changes: 84 additions & 1 deletion core/ajax/teleinfo.ajax.php
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@
);
$page = array();

$path = realpath(dirname(__FILE__) . '/../../ressources/teleinfo.log');
$path = realpath(dirname(__FILE__) . '/../../resources/teleinfo.log');
if (!file_exists($path)) {
$return['result'] = array('Deamon non lancé');
ajax::success($return);
Expand Down Expand Up @@ -591,6 +591,89 @@
$return['result'] = '2';
ajax::success($return);
break;
case 'sauveCmd':
$return['erreur']='nOk';
$return = teleinfo::sauveCmd(init('compteur'));
ajax::success($return);
break;
case 'supprCmd':
$return['erreur']='nOk';
$retour =true;
if (init('compteur')!='aucun')
$mask = __DIR__ . "/../../sauvegarde/*equipement-" . init('compteur') . '_*.*';
$retour = array_map( "unlink", glob( $mask ) );
event::add('jeedom::alert', array(
'level' => 'warning',
'page' => 'teleinfo',
'message' => __("suppression des fichiers de sauvegarde du compteur " . init('compteur'), __FILE__),
));
if ($retour == true){
$return['erreur'] = 'ok';
}
ajax::success($return);
break;
case 'restaureCmd':
$return['erreur'] = 'nOk';
event::add('jeedom::alert', array(
'level' => 'warning',
'page' => 'teleinfo',
'message' => __("envoi " . init('idRestaure') . ' vers id compteur ' . init('compteur') . ' du fichier ' . init('fichierRestaure'), __FILE__),
));
$eqLogic = eqLogic::byId(init('compteur'));
if (!is_object($eqLogic)){
}
$cmd = $eqLogic->getCmd('info',init('idRestaure'));
if (!is_object($cmd)){
event::add('jeedom::alert', array(
'level' => 'warning',
'page' => 'teleinfo',
'message' => __("Commande inexistante => création", __FILE__),
));
$cmd = teleinfo::createCmdFromRest($eqLogic,init('idRestaure'));
event::add('jeedom::alert', array(
'level' => 'warning',
'page' => 'teleinfo',
'message' => __("nouvelle commande créée => " . $cmd->getName(), __FILE__),
));
}

event::add('jeedom::alert', array(
'level' => 'warning',
'page' => 'teleinfo',
'message' => __("Récupération des données du fichier ". __DIR__ . '/../../sauvegarde/' . init('fichierRestaure'), __FILE__),
));

if (($fichier = fopen(__DIR__ . '/../../sauvegarde/' . init('fichierRestaure'), 'r')) != FALSE){
event::add('jeedom::alert', array(
'level' => 'warning',
'page' => 'teleinfo',
'message' => __("Restauration de l'historique de l'index ".$cmd->getName(), __FILE__),
));
$i=0;
while (($donnees = fgetcsv($fichier, 1000, ",")) !== FALSE) {
$i+=1;
if ($i<3){
event::add('jeedom::alert', array(
'level' => 'warning',
'page' => 'teleinfo',
'message' => __("getcsv ligne". $i . ' date = ' . $donnees[1] . ', valeur = ' . $donnees[2], __FILE__),
));
}
if ($i!= 1){
$sql = "REPLACE INTO historyArch SET cmd_id=:cmdId,datetime=:newDatetime,value=:newValue";
$values = array(
'cmdId' => $cmd->getId(),
'newDatetime' => date('Y-m-d H:00:00', strtotime($donnees[1])),
'newValue' => floatval($donnees[2]),
);
$replaceValues = DB::Prepare($sql, $values, DB::FETCH_TYPE_ROW);
}
}
$return['erreur'] = 'ok';
}
ajax::success($return);
break;

}
throw new \Exception('Aucune methode correspondante');
} catch (\Exception $e) {
Expand Down
Loading