Skip to content

Commit

Permalink
Téléinfo Version 4.5.1
Browse files Browse the repository at this point in the history
- Optimisation du temps d'exécution du relevé d'index.
- Ajustements divers.
  • Loading branch information
BmdOnline committed Sep 25, 2016
1 parent c4dc1ed commit 5fcdea6
Show file tree
Hide file tree
Showing 4 changed files with 86 additions and 93 deletions.
59 changes: 33 additions & 26 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Graphique Conso Electrique Téléinfo EDF avec Highcharts

[![Animation](https://github.com/BmdOnline/Teleinfo/raw/dev/screenshots/v4.5/animation_small.gif)](https://github.com/BmdOnline/Teleinfo/raw/dev/screenshots/v4.5/animation.gif)
[![Animation](https://github.com/BmdOnline/Teleinfo/raw/master/screenshots/v4.5.1/animation_small.gif)](https://github.com/BmdOnline/Teleinfo/raw/master/screenshots/v4.5.1/animation.gif)

# Sommaire
* [Pré-requis](#pré-requis)
Expand Down Expand Up @@ -84,6 +84,7 @@ git clone -b dev git://github.com/BmdOnline/Teleinfo.git
| dev | https://github.com/BmdOnline/Teleinfo/archive/dev.zip <br> https://github.com/BmdOnline/Teleinfo/archive/dev.tar.gz |
| stable | https://github.com/BmdOnline/Teleinfo/archive/master.zip <br> https://github.com/BmdOnline/Teleinfo/archive/master.tar.gz |
| | |
| v4.5.1 | https://github.com/BmdOnline/Teleinfo/archive/v4.5.zip <br> https://github.com/BmdOnline/Teleinfo/archive/v4.5.1.tar.gz |
| v4.5 | https://github.com/BmdOnline/Teleinfo/archive/v4.5.zip <br> https://github.com/BmdOnline/Teleinfo/archive/v4.5.tar.gz |
| v4.4dev | https://github.com/BmdOnline/Teleinfo/archive/v4.4dev.zip <br> https://github.com/BmdOnline/Teleinfo/archive/v4.4dev.tar.gz |
| v4.3 | https://github.com/BmdOnline/Teleinfo/archive/v4.3.zip <br> https://github.com/BmdOnline/Teleinfo/archive/v4.3.tar.gz |
Expand Down Expand Up @@ -440,52 +441,59 @@ Par défaut, le programme est réglé sur le thème _sombre_.

* Onglet _Puissance Instantanée_

[![Puissance Instantanée](https://github.com/BmdOnline/Teleinfo/raw/dev/screenshots/v4.5/hphc_tab_inst_small.png)](https://github.com/BmdOnline/Teleinfo/raw/dev/screenshots/v4.5/hphc_tab_inst.png)
[![Puissance Instantanée](https://github.com/BmdOnline/Teleinfo/raw/master/screenshots/v4.5.1/hphc_tab_inst_small.png)](https://github.com/BmdOnline/Teleinfo/raw/master/screenshots/v4.5.1/hphc_tab_inst.png)

* Onglet _Consommation Actuelle_

[![Dernières 24h](https://github.com/BmdOnline/Teleinfo/raw/dev/screenshots/v4.5/hphc_tab_day_small.png)](https://github.com/BmdOnline/Teleinfo/raw/dev/screenshots/v4.5/hphc_tab_day.png)
[![Dernières 24h](https://github.com/BmdOnline/Teleinfo/raw/master/screenshots/v4.5.1/hphc_tab_day_small.png)](https://github.com/BmdOnline/Teleinfo/raw/master/screenshots/v4.5.1/hphc_tab_day.png)

* Onglet _Données Historiques_ (2D)

[![Consommation sur 8 jours](https://github.com/BmdOnline/Teleinfo/raw/dev/screenshots/v4.5/hphc_tab_hist_small.png)](https://github.com/BmdOnline/Teleinfo/raw/dev/screenshots/v4.5/hphc_tab_hist.png)
[![Consommation sur 8 jours](https://github.com/BmdOnline/Teleinfo/raw/master/screenshots/v4.5.1/hphc_tab_hist_small.png)](https://github.com/BmdOnline/Teleinfo/raw/master/screenshots/v4.5.1/hphc_tab_hist.png)

* Onglet _Données Historiques_ (3D)

[![Consommation sur 8 jours](https://github.com/BmdOnline/Teleinfo/raw/dev/screenshots/v4.5/hphc_tab_hist_3D_small.png)](https://github.com/BmdOnline/Teleinfo/raw/dev/screenshots/v4.5/hphc_tab_hist_3D.png)
[![Consommation sur 8 jours](https://github.com/BmdOnline/Teleinfo/raw/master/screenshots/v4.5.1/hphc_tab_hist_3D_small.png)](https://github.com/BmdOnline/Teleinfo/raw/master/screenshots/v4.5.1/hphc_tab_hist_3D.png)

* Formule de base
* [Affichage simple] (https://github.com/BmdOnline/Teleinfo/raw/dev/screenshots/v4.5/base_single.png)
* [Onglet _Instantané_] (https://github.com/BmdOnline/Teleinfo/raw/dev/screenshots/v4.5/base_tab_inst.png)
* [Onglet _24h_] (https://github.com/BmdOnline/Teleinfo/raw/dev/screenshots/v4.5/base_tab_day.png)
* [Onglet _Historique_] (https://github.com/BmdOnline/Teleinfo/raw/dev/screenshots/v4.5/base_tab_hist.png)
* [Onglet _Historique_ (3D)] (https://github.com/BmdOnline/Teleinfo/raw/dev/screenshots/v4.5/base_tab_hist_3D.png)
* [Affichage simple] (https://github.com/BmdOnline/Teleinfo/raw/master/screenshots/v4.5.1/base_single.png)
* [Onglet _Instantané_] (https://github.com/BmdOnline/Teleinfo/raw/master/screenshots/v4.5.1/base_tab_inst.png)
* [Onglet _24h_] (https://github.com/BmdOnline/Teleinfo/raw/master/screenshots/v4.5.1/base_tab_day.png)
* [Onglet _Historique_] (https://github.com/BmdOnline/Teleinfo/raw/master/screenshots/v4.5.1/base_tab_hist.png)
* [Onglet _Historique_ (3D)] (https://github.com/BmdOnline/Teleinfo/raw/master/screenshots/v4.5.1/base_tab_hist_3D.png)

* Formule HP/HC
* [Onglet _Instantané_] (https://github.com/BmdOnline/Teleinfo/raw/dev/screenshots/v4.5/hphc_tab_inst.png)
* [Onglet _24h_] (https://github.com/BmdOnline/Teleinfo/raw/dev/screenshots/v4.5/hphc_tab_day.png)
* [Onglet _Historique_] (https://github.com/BmdOnline/Teleinfo/raw/dev/screenshots/v4.5/hphc_tab_hist.png)
* [Onglet _Historique_ (3D)] (https://github.com/BmdOnline/Teleinfo/raw/dev/screenshots/v4.5/hphc_tab_hist_3D.png)
* [Onglet _Instantané_] (https://github.com/BmdOnline/Teleinfo/raw/master/screenshots/v4.5.1/hphc_tab_inst.png)
* [Onglet _24h_] (https://github.com/BmdOnline/Teleinfo/raw/master/screenshots/v4.5.1/hphc_tab_day.png)
* [Onglet _Historique_] (https://github.com/BmdOnline/Teleinfo/raw/master/screenshots/v4.5.1/hphc_tab_hist.png)
* [Onglet _Historique_ (3D)] (https://github.com/BmdOnline/Teleinfo/raw/master/screenshots/v4.5.1/hphc_tab_hist_3D.png)

* Formule Tempo
* [Onglet _Instantané_] (https://github.com/BmdOnline/Teleinfo/raw/dev/screenshots/v4.5/tempo_tab_inst.png)
* [Onglet _24h_] (https://github.com/BmdOnline/Teleinfo/raw/dev/screenshots/v4.5/tempo_tab_day.png)
* [Onglet _Historique_] (https://github.com/BmdOnline/Teleinfo/raw/dev/screenshots/v4.5/tempo_tab_hist.png)
* [Onglet _Historique_ (3D)] (https://github.com/BmdOnline/Teleinfo/raw/dev/screenshots/v4.5/tempo_tab_hist_3D.png)
* [Onglet _Instantané_] (https://github.com/BmdOnline/Teleinfo/raw/master/screenshots/v4.5.1/tempo_tab_inst.png)
* [Onglet _24h_] (https://github.com/BmdOnline/Teleinfo/raw/master/screenshots/v4.5.1/tempo_tab_day.png)
* [Onglet _Historique_] (https://github.com/BmdOnline/Teleinfo/raw/master/screenshots/v4.5.1/tempo_tab_hist.png)
* [Onglet _Historique_ (3D)] (https://github.com/BmdOnline/Teleinfo/raw/master/screenshots/v4.5.1/tempo_tab_hist_3D.png)

* Version Mobile
* [Affichage simple] (https://github.com/BmdOnline/Teleinfo/raw/dev/screenshots/v4.5/mobile_single.png)
* [Onglet _Instantané_] (https://github.com/BmdOnline/Teleinfo/raw/dev/screenshots/v4.5/mobile_tab_inst.png)
* [Onglet _24h_] (https://github.com/BmdOnline/Teleinfo/raw/dev/screenshots/v4.5/mobile_tab_day.png)
* [Onglet _Historique_] (https://github.com/BmdOnline/Teleinfo/raw/dev/screenshots/v4.5/mobile_tab_hist.png)
* [Affichage simple] (https://github.com/BmdOnline/Teleinfo/raw/master/screenshots/v4.5.1/mobile_single.png)
* [Onglet _Instantané_] (https://github.com/BmdOnline/Teleinfo/raw/master/screenshots/v4.5.1/mobile_tab_inst.png)
* [Onglet _24h_] (https://github.com/BmdOnline/Teleinfo/raw/master/screenshots/v4.5.1/mobile_tab_day.png)
* [Onglet _Historique_] (https://github.com/BmdOnline/Teleinfo/raw/master/screenshots/v4.5.1/mobile_tab_hist.png)

* Thèmes
* [Thème _ui-darkhness_] (https://github.com/BmdOnline/Teleinfo/raw/dev/screenshots/v4.5/theme_ui-darkness.png)
* [Thème _ui-lightness_] (https://github.com/BmdOnline/Teleinfo/raw/dev/screenshots/v4.5/theme_ui-lightness.png)
* [Thème _smoothness_] (https://github.com/BmdOnline/Teleinfo/raw/dev/screenshots/v4.5/theme_smoothness.png)
* [Thème _ui-darkhness_] (https://github.com/BmdOnline/Teleinfo/raw/master/screenshots/v4.5.1/theme_ui-darkness.png)
* [Thème _ui-lightness_] (https://github.com/BmdOnline/Teleinfo/raw/master/screenshots/v4.5.1/theme_ui-lightness.png)
* [Thème _smoothness_] (https://github.com/BmdOnline/Teleinfo/raw/master/screenshots/v4.5.1/theme_smoothness.png)

# Changements

##Version 4.5.1
* Interface

* Moteur / PHP
- change : Optimisation du temps d'exécution pour l'affichage de l'index du compteur.
- bugfix : Ajustements divers.

##Version 4.5
* Interface
- change : Affichage de l'index du compteur pour faciliter les relevés EDF.
Expand All @@ -494,7 +502,6 @@ Par défaut, le programme est réglé sur le thème _sombre_.
- change : Compatibilité avec PHP 7.
- change : Quelques adaptations du code javascript.


##Version 4.4 (dev)
* Interface
- bugfix : Ajustements mineurs : libellés singulier/pluriel (1 jour, xx jours)...
Expand Down
4 changes: 2 additions & 2 deletions js/teleinfo.js
Original file line number Diff line number Diff line change
Expand Up @@ -829,7 +829,7 @@ function init_chart2(data) {
};
}

function refresh_chart0(optarif, date) {
function refresh_chart0(date) {
"use strict";

// Remise à zéro du chronomètre
Expand All @@ -839,7 +839,7 @@ function refresh_chart0(optarif, date) {
disable_timer();

// Lancement de la requête instantly
var parameters = (optarif ? "&optarif=" + Object.keys(optarif)[0] : "");
var parameters = "";
$.getJSON('json.php?query=instantly' + parameters, function (data) {
// Création / Remplacement du graphique
chart_elec0 = new Highcharts.Chart(init_chart0(data));
Expand Down
71 changes: 28 additions & 43 deletions json.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,12 +105,7 @@ function instantly () {
$timestampdebut2 = $date - $periodesecondes; // Recule de 24h.
$timestampdebut = $timestampdebut2 - $periodesecondes; // Recule de 24h.

if ($config["afficheIndex"] && !$optarif)
{
$optarif = getOPTARIF(false);
}

$query = queryInstantly($optarif);
$query = queryInstantly();
$result=$mysqli->query($query);
if (!$result) {
printf("<b>Erreur</b> dans la requête <b>" . $query . "</b> : " . $mysqli->error . " !<br>");
Expand All @@ -132,19 +127,7 @@ function instantly () {
$series["W"] = "Watts";
$series["I"] = "Ampères";

// Différents index
if ($config["afficheIndex"])
{
foreach($teleinfo["PERIODES"][$optarif] as $field){
$index[$field] = array (
"title" => $teleinfo["LIBELLES"]["PTEC"][$field],
"value" => $row[$field],
);
}
}

$query = queryMaxPeriod ($timestampdebut2, $timestampfin);

$query = queryMaxPeriod ($timestampdebut2, $timestampfin, $optarif);
$result=$mysqli->query($query);
if (!$result) {
printf("<b>Erreur</b> dans la requête <b>" . $query . "</b> : " . $mysqli->error . " !<br>");
Expand All @@ -155,6 +138,16 @@ function instantly () {
$row = $result->fetch_array();
$max["W"] = max($val["W"], $row["PAPP"]);
$max["I"] = max($val["I"], $row["IINST1"]);

// Différents index
if ($config["afficheIndex"]) {
foreach($teleinfo["PERIODES"][$optarif] as $field) {
$index[$field] = array (
"title" => $teleinfo["LIBELLES"]["PTEC"][$field],
"value" => $row[$field],
);
}
}
};
$result->free();

Expand Down Expand Up @@ -193,9 +186,8 @@ function instantly () {
}

// Différents index
if ($config["afficheIndex"])
{
foreach($teleinfo["PERIODES"][$optarif] as $field){
if ($config["afficheIndex"]) {
foreach($teleinfo["PERIODES"][$optarif] as $field) {
//$subtitle .= "Index " . $index[$field]["title"] . " : " . $index[$field]["value"] . "<br />";
$subtitle .= "Index " . $field . " : <b>" . $index[$field]["value"]/1000 . " KWh</b><br />"; // Le compteur affiche la valeur / 1000
}
Expand Down Expand Up @@ -247,8 +239,7 @@ function daily () {
$timestampdebut2 = $date - $periodesecondes; // Recule d'une période
$timestampdebut = $timestampdebut2 - $periodesecondes; // Recule d'une période

if ($config["recalculPuissance"])
{
if ($config["recalculPuissance"]) {
$tab_optarif = getOPTARIF(true);
$optarif = $tab_optarif["OPTARIF"];
} else {
Expand All @@ -274,7 +265,7 @@ function daily () {
$ptecStr = $teleinfo["LIBELLES"]["PTEC"][$ptec];

// Initialisation des courbes qui seront affichées
foreach($teleinfo["PERIODES"][$optarif] as $ptec){
foreach($teleinfo["PERIODES"][$optarif] as $ptec) {
$courbe_titre[$ptec]=$teleinfo["LIBELLES"]["PTEC"][$ptec];
$courbe_min[$ptec]=5000;
$courbe_max[$ptec]=0;
Expand Down Expand Up @@ -303,8 +294,7 @@ function daily () {
$prevptec = null;
$prevts = null;
$previdx = array();
while ($row = $result->fetch_array())
{
while ($row = $result->fetch_array()) {
$ts = intval($row["TIMESTAMP"]);
$curptec = $teleinfo["PTEC"][$row["PTEC"]];

Expand All @@ -316,8 +306,7 @@ function daily () {
// On utilise la puissance apparente
$val = floatval(str_replace(",", ".", $row["PAPP"]));

if ($config["recalculPuissance"])
{
if ($config["recalculPuissance"]) {
// On recalcule la puissance active, basée sur les relevés d'index
$curidx = floatval(str_replace(",", ".", $row[$curptec]));
$deltaidx = $curidx-$previdx[$curptec];
Expand Down Expand Up @@ -345,8 +334,7 @@ function daily () {
// On utilise la puissance apparente
$val = floatval(str_replace(",", ".", $row["PAPP"]));

if ($config["recalculPuissance"])
{
if ($config["recalculPuissance"]) {
// On recalcule la puissance active, basée sur les relevés d'index
$curidx = floatval(str_replace(",", ".", $row[$curptec]));
$deltaidx = $curidx-$previdx[$curptec];
Expand All @@ -357,7 +345,7 @@ function daily () {
}

// Affecte la consommation selon la période tarifaire
foreach($teleinfo["PERIODES"][$optarif] as $ptec){
foreach($teleinfo["PERIODES"][$optarif] as $ptec) {

if ($curptec == $ptec) {
// Période tarifaire courante
Expand Down Expand Up @@ -476,8 +464,7 @@ function history() {
$date = ($date)?min($date, $timestampheure):$timestampheure;

// Avance d'un jour tant que celui-ci n'est pas un lundi
while ( date("w", $date) != 1 )
{
while ( date("w", $date) != 1 ) {
$date += 24*3600;
}

Expand All @@ -498,8 +485,7 @@ function history() {
$date = ($date)?min($date, $timestampheure):$timestampheure;

// Avance d'un jour tant qu'on n'est pas le premier du mois
while ( date("d", $date) != 1 )
{
while ( date("d", $date) != 1 ) {
$date += 24*3600;
}

Expand Down Expand Up @@ -565,7 +551,7 @@ function history() {

// On initialise à vide
// Cas si les périodes sont "nulles", on n'aura pas d'initialisation des tableaux
foreach($teleinfo["PERIODES"][$optarif] as $ptec){
foreach($teleinfo["PERIODES"][$optarif] as $ptec) {
$kwh[$ptec] = array();
$kwhp[$ptec] = array();
}
Expand All @@ -575,14 +561,13 @@ function history() {

// Calcul des consommations
$result->data_seek(0); // Revient au début (car on a déjà lu un enreg)
while ($row = $result->fetch_array())
{
while ($row = $result->fetch_array()) {
$ts = intval($row["TIMESTAMP"]);
if ($ts < $timestampdebut2) {
// Période précédente
$cumul = null; // reset (sinon on cumule à chaque étape de la boucle)
$timestpp[] = $row["TIMESTAMP"];
foreach($teleinfo["PERIODES"][$optarif] as $ptec){
foreach($teleinfo["PERIODES"][$optarif] as $ptec) {
// On conserve le détail (qui sera affiché en infobulle)
$kwhp[$ptec][] = floatval(isset($row[$ptec]) ? $row[$ptec] : 0);
// On calcule le total consommé (qui sera affiché en courbe)
Expand All @@ -599,7 +584,7 @@ function history() {
// Ajout les éléments actuels à chaque tableau
$categories[] = $row["PERIODE"];
$timestp[] = $row["TIMESTAMP"];
foreach($teleinfo["PERIODES"][$optarif] as $ptec){
foreach($teleinfo["PERIODES"][$optarif] as $ptec) {
$kwh[$ptec][] = floatval(isset($row[$ptec]) ? $row[$ptec] : 0);
}
}
Expand All @@ -610,7 +595,7 @@ function history() {
// pad avec une valeur négative, pour ajouter en début de tableau
$timestp = array_pad ($timestp, -$duree, null);
$categories = array_pad ($categories, -$duree, null);
foreach($kwh as &$current){
foreach($kwh as &$current) {
$current = array_pad ($current, -$duree, null);
}
}
Expand All @@ -620,7 +605,7 @@ function history() {
// pad avec une valeur négative, pour ajouter en début de tableau
$timestpp = array_pad ($timestpp, -count(reset($kwh)), null);
$kwhprec = array_pad ($kwhprec, -count(reset($kwh)), null);
foreach($kwhp as &$current){
foreach($kwhp as &$current) {
$current = array_pad ($current, -count(reset($kwh)), null);
}
}
Expand Down
Loading

0 comments on commit 5fcdea6

Please sign in to comment.