utilities/telegraf-plugins#18: Octopus Pricing Fetching Broken

Issue Information

Issue Type: issue
Status: closed
Reported By: btasker
Assigned To: btasker

Created: 21-Dec-23 14:15


Earlier in the month, Octopus changed their tariff codes but haven't updated the tariff code recorded against my meter.

This has resulted in pricing lookups failing

Toggle State Changes


assigned to @btasker

Something like this happened back in July (#17) - there seems to be a delay between changes being made and the API reflecting that change.

To get a short-term fix in place, I'm mildly inclined to add support for some new environment variables - the idea being that they can be used to provide the beginning of the desired product code.

Running the plugin manually, though, it doesn't look like that's the issue - we get a value back for today:

octopus_pricing,payment_method=None,tariff_code=E-1R-OUTGOING-FIX-12M-19-05-13-A,charge_type=usage-charge,tariff_direction=EXPORT cost_exc_vat=15.0,cost_inc_vat=15.0,valid_from="2022-09-19T23:00:00Z",valid_to="None" 1703169000000000000

Querying the database shows a definite gap though


Manually inserting a point from today

curl -v -d 'octopus_pricing,payment_method=None,tariff_code=E-1R-OUTGOING-FIX-12M-19-05-13-A,charge_type=usage-charge,tariff_direction=EXPORT cost_exc_vat=15.0,cost_inc_vat=15.0,valid_from="2022-09-19T23:00:00Z",valid_to="None" 1703169000000000000' ""

and querying it:

SELECT max("cost_inc_vat") AS "mean_cost_inc_vat" FROM "Systemstats"."autogen"."octopus_pricing" WHERE time > now() - 12h and time < now() + 12h  AND "tariff_direction"='EXPORT' GROUP BY time(:interval:) FILL(null)

The point comes back

I'm thinking, then, that the issue might be with telegraf - perhaps its buffers are getting full so it's discarding points.

ben@optimus:~$ ~/Documents/src.old/telegraf-plugins/octopus-energy/octopus-energy.py  | wc -l

That'll do it.

The underlying problem is that we have the pricing section go back to whenever the pricing plan started. It's probably worth adjusting so it goes back to when the plan started OR a few days (whichever is later)

Commits will show up once the Github mirror syncs.

Changes are:

  • Adjusted so that pricing windows are only generated for the last 3 days
  • To fix the import pricing issue, added support for 2 env vars IMPORT_PRODUCT_PREFIX and EXPORT_PRODUCT_PREFIX
  • Updated README