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

Flux Import Rate is wrong for the peak time #188

Closed ppmt closed 1 year ago

ppmt commented 1 year ago

With the new Octopus Flux tariff there is a cheap tariff from 2am to 5am, a standard after that and a high tariff from 4pm to 7pm.

While the cheap and standard tariff seems correct the peak is not correct (seems to be the same as the standard)

Steps to reproduce the behavior: Check the attributes of the current rate sensor. Between 4pm and 7p it should be 47.9p for me not 3


  - from: '2023-03-26T23:30:00+00:00'
    to: '2023-03-27T00:00:00+00:00'
    rate: 33.726735
  - from: '2023-03-27T00:00:00+00:00'
    to: '2023-03-27T00:30:00+00:00'
    rate: 33.726735
  - from: '2023-03-27T00:30:00+00:00'
    to: '2023-03-27T01:00:00+00:00'
    rate: 33.726735
  - from: '2023-03-27T01:00:00+00:00'
    to: '2023-03-27T01:30:00+00:00'
    rate: 20.23602
  - from: '2023-03-27T01:30:00+00:00'
    to: '2023-03-27T02:00:00+00:00'
    rate: 20.23602
  - from: '2023-03-27T02:00:00+00:00'
    to: '2023-03-27T02:30:00+00:00'
    rate: 20.23602
  - from: '2023-03-27T02:30:00+00:00'
    to: '2023-03-27T03:00:00+00:00'
    rate: 20.23602
  - from: '2023-03-27T03:00:00+00:00'
    to: '2023-03-27T03:30:00+00:00'
    rate: 20.23602
  - from: '2023-03-27T03:30:00+00:00'
    to: '2023-03-27T04:00:00+00:00'
    rate: 20.23602
  - from: '2023-03-27T04:00:00+00:00'
    to: '2023-03-27T04:30:00+00:00'
    rate: 33.726735
  - from: '2023-03-27T04:30:00+00:00'
    to: '2023-03-27T05:00:00+00:00'
    rate: 33.726735
  - from: '2023-03-27T05:00:00+00:00'
    to: '2023-03-27T05:30:00+00:00'
 - from: '2023-03-27T14:30:00+00:00'
    to: '2023-03-27T15:00:00+00:00'
    rate: 33.726735
  - from: '2023-03-27T15:00:00+00:00'
    to: '2023-03-27T15:30:00+00:00'
    rate: 33.73
  - from: '2023-03-27T15:30:00+00:00'
    to: '2023-03-27T16:00:00+00:00'
    rate: 33.73

  - from: '2023-03-27T16:00:00+00:00'
    to: '2023-03-27T16:30:00+00:00'
    rate: 33.73
  - from: '2023-03-27T16:30:00+00:00'
    to: '2023-03-27T17:00:00+00:00'
    rate: 33.73
  - from: '2023-03-27T17:00:00+00:00'
    to: '2023-03-27T17:30:00+00:00'
    rate: 33.73
  - from: '2023-03-27T17:30:00+00:00'
    to: '2023-03-27T18:00:00+00:00'
    rate: 33.73
  - from: '2023-03-27T18:00:00+00:00'
    to: '2023-03-27T18:30:00+00:00'
    rate: 33.726735
  - from: '2023-03-27T18:30:00+00:00'
    to: '2023-03-27T19:00:00+00:00'
    rate: 33.726735
  - from: '2023-03-27T19:00:00+00:00'
    to: '2023-03-27T19:30:00+00:00'
    rate: 33.726735

  - from: '2023-03-27T19:30:00+00:00'
    to: '2023-03-27T20:00:00+00:00'
    rate: 33.726735
  - from: '2023-03-27T20:00:00+00:00'
    to: '2023-03-27T20:30:00+00:00'
    rate: 33.726735

Expected behavior During 4pm and 7pm the tariff should be 47.22p/kWh not 33.726735

Home Assistant Version 2023-3-6

Integration Version 6.3.0

Fresh Install? I am not sure if it was updated since I installed it

Home Assistant Logs

could not find related logs

BottlecapDave commented 1 year ago

Hello, sorry that you're receiving this error. Unfortunately, I only report back what the Octopus API reports back. I assume you haven't configured any price caps?

Could you also post your tariff code (present as an attribute in the current rate sensor) to see if anything is jumping out at me.

ppmt commented 1 year ago

Nothing to be sorry about :D

I indeed have to price cap set.

Here is my tariff code : E-1R-FLUX-IMPORT-23-02-14-E

BottlecapDave commented 1 year ago

I indeed have to price cap set.

Is the price cap you have configured in the integration higher than 33.73? Could this be what's stopping your rates? I've created some integration tests around your tariff and the rates seem to be coming back correctly.

BottlecapDave commented 1 year ago

Also to note, that all times are in UTC. Now that we're in BST, the rates representing your peek times are

- from: '2023-03-27T15:00:00+00:00'
    to: '2023-03-27T15:30:00+00:00'
    rate: 33.73
  - from: '2023-03-27T15:30:00+00:00'
    to: '2023-03-27T16:00:00+00:00'
    rate: 33.73
  - from: '2023-03-27T16:00:00+00:00'
    to: '2023-03-27T16:30:00+00:00'
    rate: 33.73
  - from: '2023-03-27T16:30:00+00:00'
    to: '2023-03-27T17:00:00+00:00'
    rate: 33.73
  - from: '2023-03-27T17:00:00+00:00'
    to: '2023-03-27T17:30:00+00:00'
    rate: 33.73
  - from: '2023-03-27T17:30:00+00:00'
    to: '2023-03-27T18:00:00+00:00'
    rate: 33.73
ppmt commented 1 year ago

Ok It was a typo. I meant to say no price cap but then by reconfiguring it showed I had set one....nor sure why but now I also don't know how to clear. I tried to empty the value and then click the clear price cap but it always come back to show 33.73p

ppmt commented 1 year ago

Well now I have a bigger problem. The integration has lost all its entities bare one (the binary_sensor.octopus_energy_saving_session ).

I had an update of your integration and after installing and restarting stopped showing the other entities. in the log I can see that errors.

This error originated from a custom integration.

Logger: custom_components.octopus_energy
Source: custom_components/octopus_energy/__init__.py:91
Integration: Octopus Energy (documentation, issues)
First occurred: 21:29:34 (2 occurrences)
Last logged: 21:38:52

Unexpected error fetching rates data: name 'ir' is not defined
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 239, in _async_refresh
    self.data = await self._async_update_data()
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 195, in _async_update_data
    return await self.update_method()
  File "/config/custom_components/octopus_energy/__init__.py", line 150, in async_update_electricity_rates_data
    tariff_codes = await async_get_current_electricity_agreement_tariff_codes(hass, client, account_id)
  File "/config/custom_components/octopus_energy/__init__.py", line 91, in async_get_current_electricity_agreement_tariff_codes
    ir.async_delete_issue(hass, DOMAIN, f"account_not_found_{account_id}")
NameError: name 'ir' is not defined

Edit: I think your last update removed an important line in the import section

from homeassistant.helpers import issue_registry as ir

After adding it back and restarting all is good..

And my issue is now fixed as well. I reinstalled without the price cap and now I can see the correct price

Thanks a lot for your help and sorry for the false alarm

BottlecapDave commented 1 year ago

Sorry, this was caused by a silly mistake by myself that wasn't caused by my CI. I'm planning on adding some additional checks to ensure this doesn't happen again. A new release (https://github.com/BottlecapDave/HomeAssistant-OctopusEnergy/releases/tag/v6.3.2) should rectify this.

I tried to empty the value and then click the clear price cap but it always come back to show 33.73p

Checking the checkboxes Clear electricity price cap or Clear gas price cap and then submitting should remove the price checks (I just checked on my machine). Unfortunately due to a limitation in the HA integration UI this was the best I could do to support removing price caps. Alternatively you could update the price cap to something huge (e.g. 500) so that it never gets hit.

BottlecapDave commented 1 year ago

And my issue is now fixed as well. I reinstalled without the price cap and now I can see the correct price Thanks a lot for your help and sorry for the false alarm

Sorry just saw this, and glad that this was the issue. In the latest update, the rates now have an additional attribute is_capped that should indicate if a price has been capped.