1. Go to this page and download the library: Download tbibard/teleinfo-recorder library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
tbibard / teleinfo-recorder example snippets
TeleinfoRecorder\Recorder;
use TeleinfoRecorder\Handler\StreamHandler;
use TeleinfoRecorder\Handler\PdoHandler;
use TeleinfoRecorder\Processor\CopyProcessor;
use TeleinfoRecorder\Processor\VariationLastProcessor;
use TeleinfoRecorder\Processor\SumFieldsProcessor;
try {
$recorder = new Recorder();
// StreamHandler
$recorder->pushHandler(new StreamHandler('/path/teleinfo.csv'));
// PdoHandler
$dbh = new PDO('mysql:dbname=teleinfo;host=localhost', 'teleinfo', 'teleinfo-password');
$recorder->pushHandler(new PdoHandler($dbh, 'Teleinfo'));
// Ajout de processors
// Copy processor: copie simplement un index de l'enregistrement vers un autre index
$copy = new CopyProcessor('HCHP');
$recorder->pushProcessor($copy, 'IndexHP');
// Variation processor: calcul la différence entre le relevé courant et le précédent
$variationHCHC = new VariationLastProcessor('HCHC', __DIR__, 60);
$variationHCHP = new VariationLastProcessor('HCHP', __DIR__, 60);
$recorder->pushProcessor($variationHCHC, 'HCvariation');
$recorder->pushProcessor($variationHCHP, 'HPvariation');
// Sum processor: calcul la somme de deux index du relevé
$sumconso = new SumFieldsProcessor(array('HCvariation', 'HPvariation'));
$recorder->pushProcessor($sumconso, 'CONSO');
// Write record
$recorder->write();
} catch (Exception $e) {
echo $e->getMessage() . "\n";
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.