A Node.js project that processes energy contract pricing data from CSV files and generates structured JSON output for use in Gladys Assistant.
This project processes energy contract pricing data from any energy providers and converts it into a standardized JSON format. It supports multiple contract types with different pricing structures.
- contract: Contract type identifier
- price_type: Always "consumption" for energy consumption pricing
- currency: "euro", "usd"
- start_date: Start date of the pricing period (ISO format YYYY-MM-DD)
- end_date: End date of the pricing period (ISO format YYYY-MM-DD, null for open-ended)
- price: Price in currency (multiplied by 10000 for integer precision)
- hour_slots: Time slots when the price applies (contract-specific format)
- day_type: Day classification for Tempo contracts ("blue", "white", "red")
# Clone the repository
git clone <repository-url>
cd gladys-energy-contracts
# Install dependencies
npm install# Generate contracts.json file
npm run build# Run validation tests
npm testThe project uses a modular structure where each contract type has its own convert.js file that processes the corresponding CSV data. The main process.js script automatically discovers and executes all converter functions.
To add a new contract type:
- Create new directory under
contracts/, this directory should have your provider name (i.e.electricite-de-strasbourg) - Create new subfolder with contract's name (i.e.
tarif-bleu) followed by the period name (i.e.base,peak-off-peak,tempo), results should be like:tarif-bleu-baseortarif-bleu-peak-off-peakortarif-bleu-tempo. It is important to have the right ending for good translation in Gladys - Add your CSV data file or json data file (based on the other contracts)
- Create a
convert.jsfile that exports a function returning the processed data - The main process will automatically include it
Folders' hierarchy to follow:
contracts/
└── new-provider/
├── new-tariff-base/
├── new-tariff-peak-off-peak/
└── new-tariff-tempo/
- Fork the repository
- Create a feature branch
- Make your changes
- Run build:
npm run build - Ensure tests pass:
npm test - Submit a pull request
The CI/CD pipeline will automatically validate your changes before they can be merged.