Closed Daverover66 closed 7 months ago
Sorry you're seeing this.
Do you have any errors in your logs? Have you tried restarting your HA instance or reloading the integration since?
The fact the last evaluated timestamp is quite old (this should be updated roughly every minute) means that HA hasn't fired the event that the entity is listening for, so is probably out of my control I'm afraid.
Not seeing any errors in the logs. I've changed the setting of that target rate sensor to this
name: intermittent_best_rates_3_hours_overnight
hours: "3.0"
type: Intermittent
mpan: "**************"
rolling_target: true
last_rates: true
target_invert_target_rates: false
start_time: "10:30"
end_time: "16:00"
kind: target_rate
account_id: ***************
is_target_export: false
rates_incomplete: false
target_times:
- value_inc_vat: 0.12348
start: "2024-02-17T12:00:00+00:00"
end: "2024-02-17T12:30:00+00:00"
tariff_code: E-1R-AGILE-23-12-06-N
is_capped: false
- value_inc_vat: 0.12285
start: "2024-02-17T12:30:00+00:00"
end: "2024-02-17T13:00:00+00:00"
tariff_code: E-1R-AGILE-23-12-06-N
is_capped: false
- value_inc_vat: 0.12285
start: "2024-02-17T13:00:00+00:00"
end: "2024-02-17T13:30:00+00:00"
tariff_code: E-1R-AGILE-23-12-06-N
is_capped: false
- value_inc_vat: 0.11991
start: "2024-02-17T13:30:00+00:00"
end: "2024-02-17T14:00:00+00:00"
tariff_code: E-1R-AGILE-23-12-06-N
is_capped: false
- value_inc_vat: 0.12285
start: "2024-02-17T14:30:00+00:00"
end: "2024-02-17T15:00:00+00:00"
tariff_code: E-1R-AGILE-23-12-06-N
is_capped: false
- value_inc_vat: 0.12348
start: "2024-02-17T15:30:00+00:00"
end: "2024-02-17T16:00:00+00:00"
tariff_code: E-1R-AGILE-23-12-06-N
is_capped: false
target_times_last_evaluated: "2024-02-17T10:03:02.521043+00:00"
overall_average_cost: 0.12257
overall_min_cost: 0.11991
overall_max_cost: 0.12348
current_duration_in_hours: 0
current_average_cost: null
current_min_cost: null
current_max_cost: null
next_time: "2024-02-17T12:00:00+00:00"
next_duration_in_hours: 2
next_average_cost: 0.1222725
next_min_cost: 0.11991
next_max_cost: 0.12348
last_evaluated: "2024-02-17T10:20:02.520049+00:00"
icon: mdi:camera-timer
friendly_name: Octopus Energy Target intermittent_best_rates_3_hours_overnight
It re-evaluated after I submitted the new times and gave me some target rates, which show up on my rate card
I'll let you know what happens at midday.
If it doesn't turn on I'll restart HA and try again.
Okay. So after reconfiguring the 3 hour intermittent target rate sensor, it worked.
However, I've now updated to HA2024.2.2 and set the configuration back to what I need overnight. We'll see what happens tonight .
Sorry, can I just clarify something you said earlier please?
You said "The fact the last evaluated timestamp is quite old (this should be updated roughly every minute)". Does this mean it should update roughly every minute between "start_time" and "end_time", or should it be updating roughly every minute regardless?
** Okay, so I've answered that myself by watching the last_evaluated
attribute updating outside the time
window ***
Due to the architecture, the last evaluated timestamp should update roughly every minute, as this is when the sensor checks the calculated rates against the current time and checks to see if the sensor should turn on or off. This is basically the same value as if you look at states.sensor.xxx.last_updated using templates which is HAs underlying tracking of when entities last updated. I added the attribute when I didn't realise the HA method was available.
I've just experienced the same thing, albeit I didn't see any correlation with a standing charge change. Reloading the target rate sensor resolved it. This did also happen once last week.
Today, I did add an override tariff just before i noticed the sensor had stopped working.
Unfortunately I don't see any errors in the logs. But there does appear to be a situation where the target rate sensor can occassionally miss turning on.
As mentioned above, without any errors in the logs there's very little I can think it can be. If the last evaluated timestamp or HA last updated state doesn't change roughly every minute, it implies there's an in issue in HA which is not telling the entity to update. There might be a silent (or debug) error that is occuring on certain entities, but without the logs there is very little I can do.
When it happens, the last evaluated ceases to change
Another sensor has the same issue just now, the time is currently 16:34
Target times last evaluated 17 February 2024 at 13:17:04 Last evaluated 17 February 2024 at 14:34:04
I am trying to get any debug i can, but whereever it's happen it does appear to be a silent error so far
This integration was bulletproof in all HA versions up to 2024.1.6. If it's glitching in 2024.2, is it worth raising an issue with the HA team? I don't know what would stop an entity from updating when it should.
My target rates for tonight are set, so we'll see if they work.
I have found an error that was logged at the exact same time of the last updated time of all the sensors which then ceased to update afterwards. All target rate sensors ceased to update at this point, i'm not seeing issues with any other sensors,
2024-02-17 14:34:52.309 ERROR (MainThread) [homeassistant] Error doing job: Unclosed client session 2024-02-17 14:34:52.310 ERROR (MainThread) [homeassistant] Error doing job: Unclosed connector
My target rate sensor is currently updating roughly every minute so fingers crossed.
I only have to stay up until 11:30pm tonight to make sure it turns on for that first target rate.
@irata-coder Those issues should be resolved in v10.1.2. However, I'm not sure they're the cause of this issue.
@BottlecapDave Success with last night's target rates. I'll continue to monitor, but I reckon you can safely close this issue as resolved. Thanks.
@BottlecapDave Ok, that's interesting, thank you.
This looks and feels like a deadlock/race condition, hence why there's no ongoing errors logged. Restarting the rate sensor solves this, but the issue can randomly occur again at somepoint.
For example, could we have a situation whereby the rates are updated at the exact same time the rate sensor handler is iterating the rates. I don't see any mutex around these, or are we confident they can't both execute simulatneously?
The rate information is updated in a background task (using HA reccommended techniques), which then triggers an event which calls all listening entities to update their data, for which the target rate sensor is one of them and will calculate the next set of target rates (if needed) and then update the state of the sensor based on said target rates. Nothing in the docs suggest any guarding is needed.
I assume you guys are seeing this after manually reloading the integration instead of restarting you HA instance? If so, the only thing I can think of is to see if I can automatically reload the target rate entities after the main account has been reloaded.
Since it wasn't something I was expecting, sadly I can't recall exactly what happened but I will take note in future. This has happned more than once now, however, and on different days.
There is a chance I manually reloaded the integration.
I certainly did a home assistant core update. I did notice in the logs that the update hung after downloading for about 15 minutes, waiting for something, then resumed and restarted ok.
What's odd is, when things stop updating, no other itegration was having issues. I'll have a play around over the next few days and see if I can trigger it, I've updated to 10.1.2. At the moment, the last evaluated is ticking along nicely.
Thank you for keeping an eye on this.
Funnily I had issues early this morning and the expected target_rate sensor didn't trigger - It found a 2 hour period for me and when I looked prior to going to bed it was all looking as usual but when I awoke, I could see the associated automation that is usually triggered by this binary sensor hadn't run.
The history for the sensor shows that whilst it ran on the 20th Feb, it never switched on again on the 21st.
@Stephens-ely when was the last evaluated timestamp on the sensor? Did you reload the main integration between the dates or update the main config?
I didn’t at the time because I had to sort some other things out and thought it was just me.
If it happens again, I'll take more note
Brian
From: David Kendall @.> Sent: Wednesday, February 21, 2024 5:38:18 PM To: BottlecapDave/HomeAssistant-OctopusEnergy @.> Cc: Brian @.>; Mention @.> Subject: Re: [BottlecapDave/HomeAssistant-OctopusEnergy] Target Rate Binary Sensors Not Turning on at selected time (Issue #764)
@Stephens-elyhttps://github.com/Stephens-ely when was the last evaluated timestamp on the sensor? Did you reload the main integration between the dates or update the main config?
— Reply to this email directly, view it on GitHubhttps://github.com/BottlecapDave/HomeAssistant-OctopusEnergy/issues/764#issuecomment-1957446444, or unsubscribehttps://github.com/notifications/unsubscribe-auth/A3JPHS5AAWNRCUP4Z73HTU3YUYWIVAVCNFSM6AAAAABDNFACS2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSNJXGQ2DMNBUGQ. You are receiving this because you were mentioned.Message ID: @.***>
I can recreate this by restarting the integration for the account only, after doing this any target times stop being evaluated.
Sorry for the late response.
I believe I've rectified this issue in the latest release (v10.2.0) by reloading the target rate and cost tracker sensors upon account updates.
Describe the bug
This integration has been working flawlessly for months now. However, something happened when Octopus changed their standing charge rates a couple of days ago and when I updated HA to 2024.2.1 and this integration to 10.1.0
I have 6 target rate sensors, 2 of which are not turning on when they reach the selected time. Here is one such target rate sensor where you can clearly see that 6 rates were selected covering a 3 hour period between 3am and 6am.
This is the history of all target rate sensors over the last 24 hours. The sensor shown above is third one down.
This has happened for 2 nights in a row now.
I don't often raise issues so I hope I've given you enough to go on.
In the meantime, I'm going to create another target rate sensor that covers the next few hours and watch what it does.
Reproduction steps
Create a target rate sensor as above and monitor the binary sensor's behaviour over the target times.
Expected behaviour
I expect the target rate binary sensors to turn on at the start of a target rate period and off at the end.
Tariff Code
E-1R-AGILE-23-12-06-N
Integration Version
10.1.0
Home Assistant Version
Core: 2024.2.1
Fresh Install?
After upgrading
Home Assistant Logs
Diagnostics json as follows:
There's nothing relevant in the HA logs.
Confirmation