Closed rthorntn closed 2 months ago
There is an attribute for one of the sensors that indicates what interval it is referring to. You are correct that Localvolts usually updates the number within about 20 seconds at the start of the interval.
This code in a template will show the end time of the current interval delivered as UTC time. {{ state_attr('sensor.earningsflexup', 'last_interval') }}
In relation to your screenshot above... If HASS is using the last_changed attribute underneath the earningsFlexUp (9 minutes it says), then that will not reset if the next 5 minute interval has exactly the same value for earningsFlexUp i.e. it did not "change" value.
Also, the Flex sensors shown here are calculated FOR YOU by Localvolts to be the marginal variable price/earnings for the nerxt 5 minutes i.e. less the actual overheads you cannot avoid even if you IMPORT (or EXPORT) nothing in that 5 min interval).
Also note that I round the $ to the nearest cent/kWh
Thanks, with my hand on heart, it was definitely way off, the LV API was telling me 46c and the HASS dashboard was showing 26c (and hadn't updated in 9 minutes), I think something weird is going on, the preceding interval was not the same price as it was jumping about in the morning shoulder.
It's easy to replicate:
OK, I see. I'll take a look.
Thank you!
I've made some minor tweaks with version 0.2.1. See if that helps.
FYI I did note that there were sometimes intervals where the LV API did not update for around 3 minutes into the interval.
Usually it is within the first minute though.
Thanks, that has made a monumental difference.
In a nutshell how does the fetch interval code work, I'm trying to read the python but not understanding it, are you trying to fetch at 15 seconds past the start of a settlement window and if that fails trying again 15 seconds later, rinse repeat...I think I'm seeing most updates at just over 30 seconds past, or just over one minute occasionally, am I seeing a multiple of 15 seconds?
Sorry to be a nuisance.
Can I buy you a Ko-fi?
The default for a custom integration is an update every 30 seconds. When that happens, this integration looks to see if we are in a new 5min interval and, if so, will check for latest data.
In theory, all working according to normal timing, even if we just miss the update at 20 seconds into the interval, we should pick it up at 50 seconds into the interval.
I could reduce the polling interval for more timely results but increases the load on the API server.
You can add this to your configuration.yaml (and then restart HASS) to see the debugging in the logs with some timings.
logger:
default: warning
logs:
custom_components.localvolts: debug
Legend, is it trivial to add the polling interval as a configuration in the yaml?
Personally I would risk the wrath of LV and put my interval to 5 seconds.
localvolts: api_key: "abc123abc123abc123abc123abc123ab" partner_id: "12345" nmi_id: "1234567890" interval "5"
Thanks again!
It's visible in the sensor code now as defaulted to looking for an update every 15 seconds. A compromise over hitting the server too much. Localvolts are early stage startup and may kick you out for misbehaving :)
Better API calling just released. v0.2.4 Ok to close this issue?
Will do, thanks!
Hi,
Thanks for all your help, you're an absolute legend!
I'm just trying to figure out how dependable the price in HASS is, apologies in advance if this is a daft question, I'm not a programmer.
How does your code grab my buy and sell as quickly as possible for the current settlement window, its RESTAPI right, so it pulls but how do I know how quickly it gets the price and is there a sanity check that I can use to confirm, like a timestamp (short of going to AEMO NEM dashboard and eyeballing it)?
I've heard the price update is usually within 20 seconds in the current settlement window. Fyi, I'm asking so I can be sure that the price comes through quickly so I can instruct my inverter to sell for the maximum amount of that 5 minute period, worst case in an $18/kwh spike 1 minute of missed export would be a couple of dollars.
Update: actually something isn't right I can see this in my HASS dashboard:
earningsFlexUp - 11 minutes ago - 0.25 (the current price on AEMO was ~0.46, the LV API seems to be working fine (using Postman)). HASS updated after about 13 minutes.
Attached an image of the issue happening again (I should add the costs graph has the same issue.
Thanks!