Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions octopus.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,14 @@
<label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
<input type="text" id="node-input-name" placeholder="octopus">
</div>
<div class="form-row">
<label for="node-input-product"><i class="fa fa-tag"></i> Product</label>
<input type="text" id="node-input-product" placeholder="AGILE-18-02-21">
</div>
<div class="form-row">
<label for="node-input-tariff"><i class="fa fa-tag"></i> Tariff</label>
<input type="text" id="node-input-tariff" placeholder="E-1R-AGILE-18-02-21-A">
</div>
<div class="form-row">
<label for="node-input-region"><i class="fa fa-tag"></i> Energy Region</label>
<select id="node-input-region" style="width:180px;">
Expand Down Expand Up @@ -110,6 +118,8 @@ <h3>References</h3>
color:"rgb(91, 192, 222)",
defaults: {
name: {value:"Octopus"},
product: {value:"AGILE-18-02-21"},
tariff: {value:"E-1R-AGILE-18-02-21-A"},
region: {value:"A"},
numblocks: {value:"4"}
},
Expand Down
8 changes: 5 additions & 3 deletions octopus.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,11 @@ module.exports = function(RED) {
});
}

this.region = n.region
this.region = n.region;
this.product = n.product || "AGILE-18-02-21";
this.tariff = n.tariff || "E-1R-" + n.product + "-" + this.region;

var baseurl = "https://api.octopus.energy/v1/products/AGILE-18-02-21/electricity-tariffs/E-1R-AGILE-18-02-21-";
var baseurl = "https://api.octopus.energy/v1/products/";
var https = require("https");
var next_run = new Date(0);

Expand All @@ -53,7 +55,7 @@ module.exports = function(RED) {
msg.end_time = end_time.replace(/\.[0-9]{3}/, '');
msg.region = this.region;

var APIurl = baseurl + this.region + '/standard-unit-rates/?' + 'period_from=' + start_time + '&' + 'period_to=' + end_time;
var APIurl = baseurl + this.product + '/electricity-tariffs/' + this.tariff + '/standard-unit-rates/?' + 'period_from=' + start_time + '&' + 'period_to=' + end_time;

https.get(APIurl, function(res) {
msg.rc = res.statusCode;
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name" : "node-red-contrib-octopus",
"version" : "0.3.0",
"version" : "0.4.0",
"description" : "A Node-RED node to fetch data from Octopus",
"dependencies" : {
},
Expand Down