BottlecapDave / HomeAssistant-OctopusEnergy

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

Current electricity rate is not updating during an Intelligent Dispatch period #687

Closed simeon-simsoft closed 10 months ago

simeon-simsoft commented 10 months ago

Describe the bug

During an intelligent dispatch period outside the normal off peak hours the current rate sensor remains at the peak rate when it should reflect the off peak rate at that time.

Reproduction steps

trigger an intelligent period outside normal off peak hours

Expected behaviour

during any Intelligent dispatch period the current rate should be off peak regardless of time of day. I would expect the itelligent_adjusted attribute to also be true

Tariff Code

E-1R-INTELLI-VAR-22-10-14-L

Integration Version

10.0.1

Home Assistant Version

2024.1.2

Fresh Install?

After upgrading

Home Assistant Logs

is_export: false is_smart_meter: true tariff: E-1R-INTELLI-VAR-22-10-14-L start: 2024-01-07T05:30:00+00:00 end: 2024-01-07T23:30:00+00:00 is_capped: false is_intelligent_adjusted: false current_day_min_rate: 0.074999 current_day_max_rate: 0.302471 current_day_average_rate: 0.245603 data_last_retrieved: 2024-01-07T21:52:37.695506+00:00 last_evaluated: 2024-01-07T21:56:37.696812+00:00 unit_of_measurement: GBP/kWh device_class: monetary icon: mdi:currency-gbp friendly_name: Electricity Import Current Rate

binary_sensor.octopus_energy_intelligent_dispatchingOctopus Energy Intelligent Dispatching | on | planned_dispatches: - start: '2024-01-07T21:30:00+00:00' end: '2024-01-07T22:00:00+00:00' charge_in_kwh: -3.53 source: smart-charge location: null - start: '2024-01-07T22:00:00+00:00' end: '2024-01-07T22:30:00+00:00' charge_in_kwh: -0.92 source: smart-charge location: null - start: '2024-01-07T22:30:00+00:00' end: '2024-01-08T04:00:00+00:00' charge_in_kwh: -38.88 source: smart-charge location: null -- | -- | -- [binary_sensor.octopus_energy_intelligent_dispatching](https://home.simeon.uk/developer-tools/state#) Octopus Energy Intelligent Dispatching on planned_dispatches: - start: '2024-01-07T21:30:00+00:00' end: '2024-01-07T22:00:00+00:00' charge_in_kwh: -3.53 source: smart-charge location: null - start: '2024-01-07T22:00:00+00:00' end: '2024-01-07T22:30:00+00:00' charge_in_kwh: -0.92 source: smart-charge location: null - start: '2024-01-07T22:30:00+00:00' end: '2024-01-08T04:00:00+00:00' charge_in_kwh: -38.88 source: smart-charge location: null ### Confirmation - [X] I confirm that I cannot find my solution within the [documentation](https://bottlecapdave.github.io/HomeAssistant-OctopusEnergy) - [X] I confirm that I cannot find my solution within the [FAQ](https://bottlecapdave.github.io/HomeAssistant-OctopusEnergy/faq)
daesimps commented 10 months ago

I've noticed this bug too. What I have noticed, however, is that the rate will change on the next slot start time.

For example, today my slots were 08:35-09:00, then 09:00-11:00. Between 08:35 and 09:00 the dispatching sensor was on, but current_rate was still showing peak even though my Zappi charger had been turned on by Octopus. At 09:00 the current_rate changed to the off peak value and next_rate changed to commence at 11:00 (end of cheap slot).

This behaviour seems repeatable, and seems to happen when I plug in and get an immediate slot. Overnight, e.g. 23:30-05:30 the rate seems to update as expected

simeon-simsoft commented 10 months ago

yes, after i raised this i noticed it had gone to the correct value.. i then restarted HA and it reverted back to the peak rate again until the next time slot.

BottlecapDave commented 10 months ago

Hello and sorry you're seeing this issue. This is probably a combination of the rates and intelligent settings refreshing at different interval, short time between being told about the dispatch and the dispatch becoming available and possibly rates failing to update which force the rates to be adjusted to off peak. When I get a chance I'll see if I can take a look.

gareth78 commented 10 months ago

Just to add to this as this is an issue that’s appeared in the version 10 or 10.0.1 releases.

when plugging in outside of scheduled hours but being allocated charging hours by octopus then the intelligent dispatch is showing active but off peak is inactive, current rate is peak rate and accumulative costs for the day are based on peak rates.

this was working perfectly prior to version 10. There was usually a small lag between intelligent dispatch being enabled and the off peak and current rate being adjusted but in most cases this was seconds to a minute.

BottlecapDave commented 10 months ago

Nothing changed in the integration between 9.2.1 and 10 around how the intelligent data is refreshed. Before 9.2.0 all data was refreshed on the hour/half hour, but this was changed to reduce load on the OE APIs. The data is now refreshed at the rate as per the faq, where the start point is determined by when integration is first loaded. It's possible that the dispatch schedules are updating more frequently on the API.

The underlying data also powers all of the sensors you mentioned, so if one is effected they'll all be effected.

As mentioned, I have an idea on how to improve this which I'll take a look at when I have some time.

apbarratt commented 10 months ago

I too am having regular problems with this. I can plug in the car and instantly be told the new charging plan by notification on the Octopus app, but it can be a very long time before the charging plan / rate is reflected on the integration. This can be particularly frustrating when unplugging the car and using fairly significant amounts of electricity because the integration hasn't noticed the rate has gone down for a good 20 minutes or longer.

If there were a way to poll for this information more frequently, that would be very useful. For instance, I'd set up an automation that triggers a check every minute for 10 minutes after the status of my car charger changes. Or another one that does the same when the Ready By time on intelligent has been updated.

simeon-simsoft commented 10 months ago

Andy - You might be better off using the binary_sensor.octopus_energy_intelligent_dispatching sensor to trigger your other automations rather than looking at the rate value.. this one seems to update very quickly.

Cheers

From: Andy Barratt @.> Sent: Thursday, January 18, 2024 11:05 AM To: BottlecapDave/HomeAssistant-OctopusEnergy @.> Cc: Simeon Johnson @.>; Author @.> Subject: Re: [BottlecapDave/HomeAssistant-OctopusEnergy] Current electricity rate is not updating during an Intelligent Dispatch period (Issue #687)

I too am having regular problems with this. I can plug in the car and instantly be told the new charging plan by notification on the Octopus app, but it can be a very long time before the charging plan / rate is reflected on the integration. This can be particularly frustrating when unplugging the car and using fairly significant amounts of electricity because the integration hasn't noticed the rate has gone down for a good 20 minutes or longer.

If there were a way to poll for this information more frequently, that would be very useful. For instance, I'd set up an automation that triggers a check every minute for 10 minutes after the status of my car charger changes. Or another one that does the same when the Ready By time on intelligent has been updated.

— Reply to this email directly, view it on GitHub https://github.com/BottlecapDave/HomeAssistant-OctopusEnergy/issues/687#issuecomment-1898265110 , or unsubscribe https://github.com/notifications/unsubscribe-auth/AOVQVCWWRAD5VAZXBY45K2TYPD6ULAVCNFSM6AAAAABBQTQCFWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQOJYGI3DKMJRGA . You are receiving this because you authored the thread. https://github.com/notifications/beacon/AOVQVCQPZJ7CSCIQ3FEWIUDYPD6ULA5CNFSM6AAAAABBQTQCFWWGG33NNVSW45C7OR4XAZNMJFZXG5LFINXW23LFNZ2KUY3PNVWWK3TUL5UWJTTREU5BM.gif Message ID: @. @.> >

apbarratt commented 10 months ago

Oh interesting, thank you, I shall give that a go :)

apbarratt commented 10 months ago

Righto, for the time being I've created a template helper called sensor.electric_rate that goes like this:

{% set intelligent_rate = 0.074999 %}
{% set current_rate = states("sensor.octopus_energy_electricity_[REDACTED]_current_rate") | float %}
{% set dispatching = states("binary_sensor.octopus_energy_[REDACTED]_intelligent_dispatching") %}
{{
  intelligent_rate
  if dispatching == "on"
  and intelligent_rate < current_rate
  else current_rate
}}

I've included the intelligent_rate < current_rate because supposedly I might get free electric time from time to time according to Octoplus, so would like the rate to be reflected properly if that's ever the case. I can use this to accurately reflect import costs in the energy dashboard too :)

apbarratt commented 10 months ago

Whoops, that last bit should have shown dispatching == "on". Got to be careful with that because the string "off" resolves as truthy, have edited to reflect this :)

BottlecapDave commented 10 months ago

Morning. Sorry for the radio silence, I've been battling a winter illness. The latest version of the integration (v10.0.3) should hopefully fix this issue as the rate information will be re-evaluated if dispatch information is updated between rate updates. There might be up to a minute delay between dispatch information updating and rate information updating.

apbarratt commented 10 months ago

SERIOUSLY‽ You couldn't have left it broken for just, like, a day or two? Now all that work I did on those template sensors on all my family's instances doesn't look quite so clever to them 😅 I mean... Thank you muchly!

BottlecapDave commented 10 months ago

Sorry. Just don't update their instances for a couple of days :)