BottlecapDave / HomeAssistant-OctopusEnergy

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

Calculate costs based on direct debit unit costs, not non direct debit (an option is prob best) #956

Closed DavidBeavan closed 1 month ago

DavidBeavan commented 2 months ago

Describe the bug

Thanks for all your hard work on this integration, it's bloomin excellent.

I was happily using a tariff comparison, comparing to E-2R-VAR-22-11-01-A flexible octopus e7. After a Home Assistant restart today I noticed yesterday's rates for comparison were revised up. Odd, I thought. I had just upgraded from 11.2.1 to v11.2.2. I think the upgrade and reboot may be red herrings, and its the API that's got wrong info. All prior comparisons agreed with other tools, and my own maths. This just appeared today.

Reproduction steps

Tarff reported by API: https://api.octopus.energy/v1/products/VAR-22-11-01/

     "varying": {
        "code": "E-2R-VAR-22-11-01-A",
        "standing_charge_exc_vat": 46.09,
        "standing_charge_inc_vat": 48.3945,
        "online_discount_exc_vat": 0,
        "online_discount_inc_vat": 0,
        "dual_fuel_discount_exc_vat": 0,
        "dual_fuel_discount_inc_vat": 0,
        "exit_fees_exc_vat": 0,
        "exit_fees_inc_vat": 0,
        "exit_fees_type": "NONE",
        "links": [
          {
            "href": "https://api.octopus.energy/v1/products/VAR-22-11-01/electricity-tariffs/E-2R-VAR-22-11-01-A/standing-charges/",
            "method": "GET",
            "rel": "standing_charges"
          },
          {
            "href": "https://api.octopus.energy/v1/products/VAR-22-11-01/electricity-tariffs/E-2R-VAR-22-11-01-A/day-unit-rates/",
            "method": "GET",
            "rel": "day_unit_rates"
          },
          {
            "href": "https://api.octopus.energy/v1/products/VAR-22-11-01/electricity-tariffs/E-2R-VAR-22-11-01-A/night-unit-rates/",
            "method": "GET",
            "rel": "night_unit_rates"
          }
        ],
        "day_unit_rate_exc_vat": 27.8035,
        "day_unit_rate_inc_vat": 29.193675,
        "night_unit_rate_exc_vat": 11.6632,
        "night_unit_rate_inc_vat": 12.24636
      }

Those day and night rates reported are the NON_DIRECT_DEBIT ones, see if you follow the links above to day and night

e.g. day

  "results": [
    {
      "value_exc_vat": 27.8035,
      "value_inc_vat": 29.193675,
      "valid_from": "2024-06-30T23:00:00Z",
      "valid_to": null,
      "payment_method": "NON_DIRECT_DEBIT"
    },
    {
      "value_exc_vat": 27.1576,
      "value_inc_vat": 28.51548,
      "valid_from": "2024-06-30T23:00:00Z",
      "valid_to": null,
      "payment_method": "DIRECT_DEBIT"
    },

It looks like the NON_DIRECT_DEBIT rates come first in the file, followed by DIRECT_DEBIT but previous entries it's the other way around.

Comparison daily total is subsequently based upon the NON_DIRECT_DEBIT rates and compared to previous behaviour its not doing the same comparison.

Expected behaviour

I'm given the choice to select direct debit or non direct debit and the correct rates are used. Or it defaults to previous behaviour and chooses direct debit (or whatever the majority of users are on)

Tariff Code

E-2R-VAR-22-11-01-A

Integration Version

11.2.2

Home Assistant Version

2024.7.3

Fresh Install?

After upgrading

Home Assistant Logs

N/A

Confirmation

BottlecapDave commented 2 months ago

Thanks for raising this and sorry you've encountered the issue. The API looks like it's changed the order and it was just working with direct debit numbers before by coincidence. I'll see if I can get a fix in for the next release, which should be within the next week.

BottlecapDave commented 1 month ago

This should now be fixed in v12.0.0