BottlecapDave / HomeAssistant-OctopusEnergy

Unofficial Home Assistant integration for interacting with Octopus Energy
https://bottlecapdave.github.io/HomeAssistant-OctopusEnergy/
MIT License
564 stars 55 forks source link

Tracker tariffs not reporting correctly #129

Closed no1knows closed 1 year ago

no1knows commented 1 year ago

I recently switched to the Gas Tracker tariff (https://octopus.energy/smart/tracker/) and since then my gas price is not shown in HA:

image

I've tried reloading/deleting and re-setting up the integration. Any ideas? Thank you.

BottlecapDave commented 1 year ago

If you could give me the tariff that appears in the attributes of your gas sensors, I'll see if I can find some time to see why this is.

no1knows commented 1 year ago

Thanks. I don't see a tariff in the attributes of any of the gas sensors. My electricity sensors have "tariff_code: E-1R-GO-22-07-05-C"

The only attributes on the gas current rate sensor are:

unit_of_measurement: GBP/kWh
device_class: monetary
icon: mdi:currency-gbp
friendly_name: Octopus Energy Gas [serial] [MPRN] Current Rate

(not sure if the serial or mprn are sensitive, but happy to share if useful).

BottlecapDave commented 1 year ago

Hmm ok. If you go to "Gas Meter" in your devices, you should be able to "download diagnostics" which includes the gas tariff.

michaelmorris commented 1 year ago

Hi, I have the same tariff and issue - here is the relevant section from the diagnostics:

"gas_meter_points": [ { "mprn": "**REDACTED**", "meters": [ { "serial_number": "**REDACTED**", "consumption_units": "" } ], "agreements": [ { "valid_from": "2023-01-20T00:00:00+00:00", "valid_to": null, "tariff_code": "G-1R-SILVER-FLEX-22-11-25-D" } ] } ]

no1knows commented 1 year ago

and mine:

    "gas_meter_points": [
      {
        "mprn": "**REDACTED**",
        "meters": [
          {
            "serial_number": "**REDACTED**",
            "consumption_units": "m\u00b3"
          }
        ],
        "agreements": [
          {
            "valid_from": "2023-01-12T00:00:00+00:00",
            "valid_to": null,
            "tariff_code": "G-1R-SILVER-FLEX-22-11-25-C"
          }
        ]
      }
    ]
BottlecapDave commented 1 year ago

Thanks for that both of you. It looks like these tariffs aren't documented in their APIs. After snooping at the demo, I may have found the endpoint, but it'll take me a little while to integrate it.

sembeeuk commented 1 year ago

Does this thread help? https://community.home-assistant.io/t/octopus-energy-gas-tracker-tariff-dynamic-pricing-sensors-solved/456964

Someone is doing it with Rest, so that should provide you with the path.

jamesa22 commented 1 year ago

I'm also looking for this integration. The rate changes every day after midnight. You can use your traiff code to read the cost in your area.

Thanks

BottlecapDave commented 1 year ago

Hello. This should now be fixed in https://github.com/BottlecapDave/HomeAssistant-OctopusEnergy/releases/tag/v5.3.1 (assuming I'm extracting the correct value ;))

sembeeuk commented 1 year ago

I am also a user of the tracker tariff for Gas, and installed this update yesterday. Had to wait until this morning to see whether there was any update, as I presume the integration only downloads the price once a day. The tracker price is showing correctly, however the standing charge still says Unknown as per the screen shots at the top of this thread.

BottlecapDave commented 1 year ago

I'm sorry, I misunderstood the full extent of the issue as it originally only mentioned the price. I'll take a look at the standing charge when I can (I believe it's present in the same service).

Dazula commented 1 year ago

Not sure if this helps: There is an issue whereby the Gas Tracker below will not return data. It would appear that this is an issue that Octopus are aware about (Forum).

https://api.octopus.energy/v1/products/SILVER-FLEX-22-11-25/gas-tariffs/G-1R-SILVER-FLEX-22-11-25-B/standard-unit-rates/

Others do work... for example https://api.octopus.energy/v1/products/SILVER-22-07-22/gas-tariffs/G-1R-SILVER-22-07-22-B/standard-unit-rates/

RobinXe commented 1 year ago

@Dazula I have noticed the same thing. Do you have a link to the forum post where this is being discussed?

Dazula commented 1 year ago

@RobinXe Here you go... https://forum.octopus.energy/t/how-to-access-gas-tracker-tariff-historic-prices/6937

RobinXe commented 1 year ago

@Dazula Thanks very much!

adamwylde commented 1 year ago

I'm having a similar issue for electric ("tariff_code": "E-1R-SILVER-FLEX-22-11-25-J") having just switched yesterday to Tracker for both fuels.

I'm seeing the standard unit rate, and unknown standing charge.

image

Maybe electric tracker just isnt supported?

Thanks either way, and loving your work @BottlecapDave

Burgess101 commented 1 year ago

Similarly, after switching to the tracker, I don't have access to any of the rate-related sensors for electricity. Gas seems to be fine.

BottlecapDave commented 1 year ago

I'm sorry, I misunderstood the full extent of the issue as it originally only mentioned the price. I'll take a look at the standing charge and electricity when I can (I believe it's present in the same service).

adamwylde commented 1 year ago

I presume its related to these log entries... I understand that the Octopus API gives our the wrong uri for the new tariff.

This error originated from a custom integration.

Logger: custom_components.octopus_energy.api_client
Source: custom_components/octopus_energy/api_client.py:264
Integration: Octopus Energy (documentation, issues)
First occurred: 1 February 2023 at 21:35:25 (2716 occurrences)
Last logged: 20:15:32

Request failed (https://api.octopus.energy/v1/products/SILVER-FLEX-22-11-25/electricity-tariffs/E-1R-SILVER-FLEX-22-11-25-J/standard-unit-rates?period_from=2023-02-01T00:00:00Z&period_to=2023-02-03T00:00:00Z): 404; {"detail":"Not found."}
Request failed (https://api.octopus.energy/v1/products/SILVER-FLEX-22-11-25/electricity-tariffs/E-1R-SILVER-FLEX-22-11-25-J/standard-unit-rates?period_from=2023-01-31T00:00:00Z&period_to=2023-02-01T00:00:00Z): 404; {"detail":"Not found."}
Request failed (https://api.octopus.energy/v1/products/SILVER-FLEX-22-11-25/electricity-tariffs/E-1R-SILVER-FLEX-22-11-25-J/standard-unit-rates?period_from=2023-02-01T00:00:00Z&period_to=2023-02-02T00:00:00Z): 404; {"detail":"Not found."}
Request failed (https://api.octopus.energy/v1/products/SILVER-FLEX-22-11-25/electricity-tariffs/E-1R-SILVER-FLEX-22-11-25-J/standard-unit-rates?period_from=2023-02-02T00:00:00Z&period_to=2023-02-04T00:00:00Z): 404; {"detail":"Not found."}

This error originated from a custom integration.

Logger: custom_components.octopus_energy.api_client
Source: custom_components/octopus_energy/api_client.py:436
Integration: Octopus Energy (documentation, issues)
First occurred: 1 February 2023 at 21:35:26 (2721 occurrences)
Last logged: 20:15:31

Request failed (https://api.octopus.energy/v1/products/SILVER-FLEX-22-11-25/gas-tariffs/G-1R-SILVER-FLEX-22-11-25-J/standing-charges?period_from=2023-02-01T00:00:00Z&period_to=2023-02-02T00:00:00Z): 500; Internal Server Error
Request failed (https://api.octopus.energy/v1/products/SILVER-FLEX-22-11-25/gas-tariffs/G-1R-SILVER-FLEX-22-11-25-J/standing-charges?period_from=2023-02-01T00:00:00Z&period_to=2023-02-02T00:00:00Z): 404; {"detail":"Not found."}
Request failed (https://api.octopus.energy/v1/products/SILVER-FLEX-22-11-25/gas-tariffs/G-1R-SILVER-FLEX-22-11-25-J/standing-charges?period_from=2023-02-01T00:00:00Z&period_to=2023-02-02T00:00:00Z): 502; <html> <head><title>502 Bad Gateway</title></head> <body> <center><h1>502 Bad Gateway</h1></center> <hr><center>nginx</center> </body> </html>
Request failed (https://api.octopus.energy/v1/products/SILVER-FLEX-22-11-25/gas-tariffs/G-1R-SILVER-FLEX-22-11-25-J/standing-charges?period_from=2023-02-02T00:00:00Z&period_to=2023-02-03T00:00:00Z): 404; {"detail":"Not found."}
Request failed (https://api.octopus.energy/v1/products/SILVER-FLEX-22-11-25/gas-tariffs/G-1R-SILVER-FLEX-22-11-25-J/standing-charges?period_from=2023-02-02T00:00:00Z&period_to=2023-02-03T00:00:00Z): 502; <html> <head><title>502 Bad Gateway</title></head> <body> <center><h1>502 Bad Gateway</h1></center> <hr><center>nginx</center> </body> </html>
Dazula commented 1 year ago

I am temporarily getting todays prices from https://api.octopus.energy/v1/products/SILVER-FLEX-22-11-25/ which does work. whilst Octopus sort out the historical and future end points above.

RobinXe commented 1 year ago

Yeah, so it appears that Octopus do not have a product/tariff endpoint for their most recent tracker under the /products/ path.

I'm using https://octopus.energy/api/v1/tracker/E-1R-SILVER-FLEX-22-11-25-H/daily/past/21/0/ with the appropriate fuel type/region code, where the first trailing parameter is days in the past, rounded to the inclusive calendar month, and the second is annual consumption (not required for rate tracking). I'm cautioned that this does not take account of the EPG/tariff cap, so may not always be relied upon in its raw form. This also does not seem to conform to the 'period_from/period_to' pattern, as I believe it predates the current incarnation of the API.

BottlecapDave commented 1 year ago

Yeah this is a known issue by them (acknowledged in https://forum.octopus.energy/t/how-to-access-gas-tracker-tariff-historic-prices/6937/2), but with no estimated fix time.

Currently I'm falling back onto that specified url if the tariff is a tracker tariff for gas prices (less than ideal). I need to add this logic for standing charges and electricity. I also need to account for previous accumulation prices.

My worry about these work arounds is a) they will hide when the APIs start working properly, b) there are reports they're not including price caps and c) they'll be fixed by the time I've implemented the work arounds.

RobinXe commented 1 year ago

My impression has been that they are not prioritising the incorporation of the tracker tariff into the latest version of the API, if it's receiving any attention at all! This may well change, however, with their recent increased popularity.🤷‍♂️

Another concern is that the EPG per-unit discounts are due to change in March. I'm not sure whether there is any way to retrieve these automatically from the Octopus API. My experience of GOV.UK is that their formatting is not consistent enough to ensure accurate scraping of these values, and additionally the current discounts quoted there differ from those quoted by Octopus (e.g. 6.4p/kWh for gas, vs. 6.7p/kWh quoted by Octopus).

I believe the API is not reporting capped/discounted rates at all, so the logic for those would need to be implemented client-side, by any solution.

BottlecapDave commented 1 year ago

They previously took a while for the price caps to reflect through the API for non tracker tariffs, so I expect the same this time. The only way they might prioritize the the API updates is if enough people complain about it (either via their forum which you can request access to, via email or via twitter).

As said I will try and get the workaround for the tracker API as soon as I get a bit of free time. I'm trying to do it in the most efficient way but I might have to go another route.

I don't want to be maintaining price caps and my philosophy around the plugin is to be intelligent and adapt automatically (e.g. if your tariff changes then you shouldn't have to do anything). However I might have to break that rule for price caps if Octopus Energy are not going to provide them and provide a way for you to add them yourselves. But again this will complicate other parts of the plugin.

BottlecapDave commented 1 year ago

I've released a new version at https://github.com/BottlecapDave/HomeAssistant-OctopusEnergy/releases/tag/v5.4.0 which should use the tracker endpoint where appropriate. I'm leaving this ticket open as I still need to account for price caps.

BottlecapDave commented 1 year ago

The above had a bug in it that while fixed tracker tariffs, broke some other tariffs. Please find an update at https://github.com/BottlecapDave/HomeAssistant-OctopusEnergy/releases/tag/v5.4.1. As mentioned, the handling of price caps will be introduced in a future version.

adamwylde commented 1 year ago

I think there is still a minor issue with the gas tracker previous accumulative cost...

The previous consumption sesnsor appears correct:

Total m3 9.561

Rate on 9/2/2023 was 69.23p/m3

9.561m3 *69.23p/m3 = £6.62

Or in kWh: 1 m3 = 10.55 kWh... rate was 6.562p/kWh usage was 100.86855 kW 6.562p/kWh*100.86855 kW=£6.62

However, the cost sensor is showing as:

Tariff code G-1R-SILVER-FLEX-22-11-25-J
Standing charge 26.838p
Total without standing charge £7.13
Total £7.4
....
- from: '2023-02-09T06:30:00+00:00'
to: '2023-02-09T07:00:00+00:00'
rate: 6.5625p
BottlecapDave commented 1 year ago

@adamwylde This is due to the price cap that is not being taken into consideration?

If not, it might be due to the conversion from m3 to kwh. As per the comments, I use the calculation as outlined in https://www.theenergyshop.com/guides/how-to-convert-gas-units-to-kwh. The part that can vary is the calorific value, which state if you don't know a baseline of 40 is fine. As per https://octopus.energy/blog/statement-questions/, they use the same calculation but don't highlight what they use for the calorific value. I couldn't find anything in their API that stated what they use and I worry it might vary from region to region.

adamwylde commented 1 year ago

I don’t think conversion is the problem. The kWh reported in HA for the day looks correct and matches the data I can download from octopus directly which is also in KWh.

All sources inc HA come up with 100.8 kWh, and that multiplied by the p/kWh of 6.562 (shown against each half hour rate in the sensor) - that’s about 25% below where any cap would start applying - doesn’t work out as the sensor value of £7.13 - it’s £6.62. I can’t work out where the other 51p comes from!

BottlecapDave commented 1 year ago

Do you know if your meter natively reports in m3 or kwh? This can be found in the attributes of the standard consumption sensor. If it states it's estimated then your meter reports in kwh otherwise it reports it in m3.

It might be that the calculation conversion error is compounding, as the calculation converts each charge (if m3) and then captures the cost of that. The sum of these charges are then what are presented, rather than the cost of the value reported in the consumption sensor. I assume the cost of the individual charges added up equal the 7.13?

adamwylde commented 1 year ago

You are of course quite right - the meter is not estimated, so values are m3. It looks like the calorific value varies and is shown on your bill each month (and varies month to month). So yeah rather hard to get a reliable conversion from m3 to kWh when the calorific value varies (unless its hiding in the API somewhere as you mention)!

FYI my last 3 bills have has calorific values of 38.8, 38.6, and 39.0, so all under the 'default' 40 which explains why the estimate is high.

Thanks

adamwylde commented 1 year ago

It appears you can get the calorific value but from National Gas not the Octopus api. And it looks like hard work tbh as it’s geographic.

Details found on the octopus forum: https://forum.octopus.energy/t/daily-calorific-value/6466

Maybe a viable workaround is to let the user configure the CV value so they can set it to a value similar to their bill.

Anyway clearly this is unrelated to trackers, it’s just a potential improvement so feel free to file this away somewhere!

BottlecapDave commented 1 year ago

Yeah I've been thinking about making it configurable, so will add to the backlog :)

BottlecapDave commented 1 year ago

I'll close this ticket as the original issue is now fixed. If there are other issues, please raise a new ticket :)

BottlecapDave commented 1 year ago

Calorific value configuration is now available in the latest release (https://github.com/BottlecapDave/HomeAssistant-OctopusEnergy/releases/tag/v6.0.0)

adamwylde commented 1 year ago

That looks better with some adjusted rates. Thank you