Skip to content

Commit

Permalink
Merge pull request #58 from netmindz/rowLimit
Browse files Browse the repository at this point in the history
Add rateListLimit option
  • Loading branch information
lozzd authored Jan 26, 2024
2 parents 7651151 + ffd0880 commit cc4eabf
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ Here's a breakdown of all the available configuration items:
| cheapest | Y | false | If true show the cheapest rate in light green / light blue |
| combinerate | Y | false | If true combine rows where the rate is the same price, useful if you have a daily tracker tarrif for instance |
| multiplier | Y | 100 | multiple rate values for pence (100) or pounds (1) |

| rateListLimit | Y | N/A | Limit number of rates to display, useful if you only want to only show next 4 rates


#### A note on colouring
Expand Down
7 changes: 5 additions & 2 deletions octopus-energy-rates-card.js
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ class OctopusEnergyRatesCard extends HTMLElement {
const cheapest = config.cheapest;
const combinerate = config.combinerate;
const multiplier = config.multiplier
const rateListLimit = config.rateListLimit
var colours = (config.exportrates ? colours_export : colours_import);
var rates_totalnumber = 0;
var combinedRates = [];
Expand Down Expand Up @@ -236,7 +237,7 @@ class OctopusEnergyRatesCard extends HTMLElement {
rates_processingRow ++;
var ratesToEvaluate = key.value_inc_vat * multiplier;

if(showpast || (date - Date.parse(new Date())>-1800000))
if((showpast || (date - Date.parse(new Date())>-1800000)) && (rateListLimit == 0 || rates_list_length < rateListLimit))
{
rates_currentNumber++;

Expand Down Expand Up @@ -404,7 +405,9 @@ class OctopusEnergyRatesCard extends HTMLElement {
// Combine equal rates
combinerate: false,
// multiple rate values for pence (100) or pounds (1)
multiplier: 100
multiplier: 100,
// Limit display to next X rows
rateListLimit: 0
};

const cardConfig = {
Expand Down

0 comments on commit cc4eabf

Please sign in to comment.