Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[persistence] Forecast Items only update whilst future states exist #4462

Open
jamesmelville opened this issue Nov 28, 2024 · 1 comment
Open
Labels
bug An unexpected problem or unintended behavior of the Core

Comments

@jamesmelville
Copy link
Contributor

Expected Behavior

I expect that when I persist a state or timeseries with timestamps in the future, then the item will transition to these states at the future time.

Current Behavior

When there always exists a future state in the persistence layer for an item, then the item continues to update to the persisted state values at the future timestamps. As soon as that chain of future states no longer exists, the item stops updating. When more future states are added, the item does not update to these states.

Workaround: My fix to this is renaming the item and then renaming it back (I'm on file based config). Restarting openHAB also cures this.

Possible Solution

I wasn't sure where to log this issue, but I can also reproduce this adding a future state via the REST API where no future states exist. I wasn't expecting this as #4087 is resolved, which suggests this might be multiple issues or a common one.

Steps to Reproduce (for Bugs)

my.items:

Number MyItem

influxdb.persist

Strategies { default = everyChange }
Items { MyItem : strategy = forecast, restoreOnStartup }

script:

var usageSeries = new items.TimeSeries('REPLACE');
usageSeries.add(time.toZDT().plusMinutes(1), '1');
usageSeries.add(time.toZDT().plusMinutes(2), '2');
usageSeries.add(time.toZDT().plusMinutes(3), '3');
items.MyItem.persistence.persist(usageSeries);

Create item and persistence, run script, see that state remains NULL (or previously restored state).

Rerun script, quickly rename item MyItem to MyItem1 and back to MyItem. See states are updated at timestamps.

Context

I retrieve future half hourly electricity prices, which I retrieve from an API ~ 16h00 every day, and they have the following day's prices through to 22h30. The retrieval is done by JS scripting, which generates a time series from API data, and stores this in an item, with a persistence strategy of forecast. As the price changes over time the item is updated with the current price.

In the rare event the prices are not available from the API until after 2230, the prices often eventually arrive, and are successfully persisted, but the item remains out of date, stuck on the previous value, despite their being database values for the current and future timestamps.

Your Environment

openHAB Docker openhab/openhab:latest on linux/amd64
InfluxDB 2.0

@jamesmelville jamesmelville added the bug An unexpected problem or unintended behavior of the Core label Nov 28, 2024
@jamesmelville
Copy link
Contributor Author

I realise next steps are probably increasing debug levels on org.openhab.core.persistence.internal.PersistenceManager and the influxdb addon, will investigate further in time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug An unexpected problem or unintended behavior of the Core
Projects
None yet
Development

No branches or pull requests

1 participant