Octopus Agile as a feed/input

Hi James, how are you installing it?

Just restarted my Home Assistant add-on and it loads the package no problem. Has anything else changed?

I did update the version and added an output for use with InfluxDB a week ago.

[edit]

[08:16:06] INFO: Starting installation of custom NPM/Node-RED packages...
+ [email protected]
+ [email protected]
added 2 packages from 17 contributors and audited 3759 packages in 23.547s

Add-on config (partial)

npm_packages:
  - 'git+https://github.com/borpin/node-red-contrib-octopus.git'
  - canvas-gauges
init_commands: []
1 Like

Hi Brian,

Thankyou, I swapped

ā€˜npm install GitHub - borpin/node-red-contrib-octopus: Octopus Node-Red node --saveā€™

for

 - 'git+https://github.com/borpin/node-red-contrib-octopus.git'

and this fixed it!

Great work on this, its very usefull, thank you for sharing!

Best Regards

James

1 Like

Hi @borpin just wanted to let you know that I just installed your node red node from GitHub and it works perfectly.

Just what I needed, many thanks
Cheers
Mark

1 Like

I have created a feed that takes the Agile costs and loads them into Emoncms (input). I run a python script every 30 minutes (+1) which loads the value.

This is great for seeing the costs now but I wanted to feed in the costs for the future ( aka the Octopus Agile app).

The idea is to combine these projected costs along with other areas as per the initial request for help.

Is there a way of directly loading the feed with future values rather then relying on the input? I assume a feed takes the current input value and provides a timestamp. SO is there a method I could insert directly into the feed which would then complete what I need - maybe there is an API call I could send data to feed rather than input?

thanking you in advance - Andy B

Apologies everyone. I have found the details for feed API so will follow that.

Having tried in vain to create something myself in NR, just discovered this very nice contribution, thank you @borpin

Iā€™m trying to get the live price for Octopusā€™ Cosy product which i gather is just a change to the Product & Tarriff code in request URL. Is there any way to modify this either in the Nodered GUI or a config file somewhere? As you can probably tell my engineering skills are somewhat limited!

I have the raw Cosy data coming from Octopus OK thanks to @Timbones, just need to isolate the current price for which this custom node appears to handle all the complexity.

BASE_URL="https://api.octopus.energy"
PRODUCT_CODE="COSY-22-12-08"
TARIFF_CODE="E-1R-$PRODUCT_CODE-J"
TARIFF_URL="$BASE_URL/v1/products/$PRODUCT_CODE/electricity-tariffs/$TARIFF_CODE/standard-unit-rates/"'

Many thanks

Currently no. When I did that, there was just one Tariff!

Thank you! I am obviosuly v. late to the party and just discovered this. Assuming easy enough to mqtt back to emoncms, itā€™s just what i needed. Iā€™ll have a tinker

If you want a Node-RED solution try this (you will need to modify the URL used)

[{"id":"3f62582d090894ec","type":"debug","z":"24bde98641010730","name":"debug 11","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":760,"y":320,"wires":[]},{"id":"d049f0c637498499","type":"http request","z":"24bde98641010730","name":"Agile API Request","method":"GET","ret":"txt","paytoqs":"ignore","url":"https://api.octopus.energy/v1/products/AGILE-FLEX-22-11-25/electricity-tariffs/E-1R-AGILE-FLEX-22-11-25-J/standard-unit-rates/","tls":"","persist":false,"proxy":"","authType":"","senderr":false,"x":330,"y":260,"wires":[["96ddd52228ca5970"]]},{"id":"96ddd52228ca5970","type":"json","z":"24bde98641010730","name":"Convert to Objects","property":"payload","action":"","pretty":false,"x":530,"y":260,"wires":[["1bec2a814c3bb42b"]]},{"id":"2eb46e6b364e2529","type":"inject","z":"24bde98641010730","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"60","crontab":"","once":true,"onceDelay":"1","topic":"","payload":"","payloadType":"date","x":150,"y":260,"wires":[["d049f0c637498499"]]},{"id":"1bec2a814c3bb42b","type":"function","z":"24bde98641010730","name":"Get Current Price from Object","func":"const currentTime = new Date();\n\n// Find the most recent rate that's still valid\nlet currentRate = null;\nmsg.payload.results.forEach(rate => {\n  const validTo = new Date(rate.valid_to);\n  const validFrom = new Date(rate.valid_from);\n\n  if (validFrom <= currentTime && validTo > currentTime) {\n    currentRate = rate;\n    return;\n  }\n});\n\nlet output = \"\";\nif (currentRate) {\n  output = currentRate.value_inc_vat.toString();\n} else {\n  output = \"No current rate available.\";\n}\n// Set the modified payload\nmsg.payload = output;\n\n// Set Global Variable - use  global.get(\"agile_current_price\") \nglobal.set(\"agile_current_price\", msg.payload);\n\n// Return the modified message\nreturn msg;\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":770,"y":260,"wires":[["3f62582d090894ec"]]}]

Copy and import to Node-RED.

1 Like

Thanks so muchā€¦