PHP code example of supla / energy-cost-calculator
1. Go to this page and download the library: Download supla/energy-cost-calculator 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/ */
supla / energy-cost-calculator example snippets
use Supla\EnergyCostCalculator\Engine\CostCalculator;
use Supla\EnergyCostCalculator\Engine\CalculationOptions;
use Supla\EnergyCostCalculator\Model\TimeRange;
$calculator = new CostCalculator(
$energyDeltaSource,
$referenceDataSource,
);
$result = $calculator->calculate(
meterId: (string)$channelId,
range: new TimeRange($from, $to),
definition: $jsonDefinition,
options: new CalculationOptions(
use Supla\EnergyCostCalculator\Preset\TariffPresetCatalog;
$catalog = new TariffPresetCatalog();
$summaries = $catalog->presets();
$preset = $catalog->get('PL.TAURON_DYSTRYBUCJA.G12.2026');
$preset->document; // Complete preset document.
$preset->revision; // SHA-256 of the deterministically encoded JSON document.