-
Hey all, first off - thank you for continuing the fantastic works of oziee, it's really much appreciated! So, for one reason or another, since a few days now i'm missing my historical data - seems somehow it got corrupted, overwritten - dunno. Since this has happened in the past already (but was quite stable for at least some time now), i'd love to get the old data back. As i do daily backups (running in an LXC container on Proxmox VE, backed up by PBS) i think i could grab saved/old data and merge it with the new? From what i could gather, it previously was saved to a .json file (solcast.json), glancing at the code (sorry, i'm really bad at reading Python) it seems that the data is now saved to the database? I'd really appreciate it if someone could point me in the right direction! |
Beta Was this translation helpful? Give feedback.
Replies: 16 comments 40 replies
-
The JSON is just a cache of the current solar forecast and AFAIK it hasn't been changed. The history has always been kept in the statistics database. If you can't find any history is it because you've changed the entity names when swapping to the BJreplay integration, or maybe you've had a corruption on the HA database and its lost ALL your history for every entity? If the former can you rename your entities to what they were beforehand? If the latter then you should see this in the System log. You can recover HA back to a backup taken before the corruption but I don't know of any way to merge history from an old backup into HA. I lost my own HA database about a month after I first started with HA, would love to recover that history but all the google searches I did came up with what appeared to be some very dodgy scripts and I feared I would corrupt the database again. If there was a published HA solution that'd be great. |
Beta Was this translation helpful? Give feedback.
-
Mine goes back to 11 June. |
Beta Was this translation helpful? Give feedback.
-
So different to @gcoan. Does it coincide with installing a new release? 🤔 This should not mess with any history, and no sensor names/etc. have changed. And I just yesterday installed 4.0.32, so that's ten days of history only, where 730 days should be kept. This happened around 11 June. This from 6 June. |
Beta Was this translation helpful? Give feedback.
-
I wonder if changing the state_class for total_kwh_forecast_today to TOTAL is behind it? This crept in as part of Oziee's v4.0.23 'missing' changes. This in v4.0.28: |
Beta Was this translation helpful? Give feedback.
-
I have restored a parallel instance dating back to Oziee's last release (9 June was all that was available that far back), and have upgraded it to BJReplay 4.0.31. On restart all long term history is there. Presumably a job runs at some stage, maybe midnight to prune things. I'll leave it running overnight and see what happens. (edit) I also updated it from 2024.6.1 to 2024.6.4. No change to long-term. |
Beta Was this translation helpful? Give feedback.
-
We have another data point. Another user reporting an unrelated non-issue said no forecast history when I asked... |
Beta Was this translation helpful? Give feedback.
-
As a test, I set the state_class of the forecast today sensor to None, which is the same as it used to be in Oziee's 3.0.2x. Long term history did not magically come back. How important is this long term history? Does it inform things like Predbat? |
Beta Was this translation helpful? Give feedback.
-
To the original question, @phrozen77... This fascinates: https://community.home-assistant.io/t/custom-integration-to-import-long-term-statistics-from-a-file-like-csv-or-tsv/689793 I'm definitely going to try this! Export data to .CSV from History. |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
From an Oziee latest install, changing to Setting it back to Try that. In sensor.py, comment out the stat_class on line 47, restart HA and see if the history comes back. If it doesn't then there may be a periodic purge, but I have absolutely no idea whether that is the case. (edit) Commenting the line did not work on my 'prod' instance. According to forum posts, LTS are never purged, so this confuses me. It now begs the question, what should we do about it? I'm tending towards reverting that change even if this test doesn't work for you to prevent others hitting it. |
Beta Was this translation helpful? Give feedback.
-
I honestly think that this is being over-thought, and over-worked in trying to get the history back. I know you're hurting, @phrozen77, and I hurt too, but surely this is like seeing whether a forecast high temperature from one year back was accurate. It doesn't matter. It mattered the day before, but now it's just an actual stat that happened. For us, it's just a dotted line on a chart that's missing and makes our eye tick. The bureau that made the temperature forecast would want to know that they messed up, and why, and how they could do better in future, like Solcast would, but we all are just disappointed that it was inaccurate, and just end the forecasted day with a muttered, "Tossers. I bet they buy some more kit at taxpayer expense to do better..." There's nothing we can do about their inaccuracies but #rolleyes. |
Beta Was this translation helpful? Give feedback.
-
Guys, i managed to do it - in the end, it was as simple as i suspected in my first post here. solcast.json is in (my case) the root of the docker volume: /var/lib/docker/volumes/hass_config/_data/solcast.json (which is also why i didn't find it at first - i was looking in custom_components/solcast_solar) I merged the current file with one from the backup, restarted HA, done. |
Beta Was this translation helpful? Give feedback.
-
That's confirmed from me, @phrozen77. It's a bit of mucking around for multiple rooftop sites, but it works. This does pose the question: Why did Where did it go? And why??? 🤔 |
Beta Was this translation helpful? Give feedback.
-
"Troubleshooting FAQ" post updated, BTW. |
Beta Was this translation helpful? Give feedback.
-
Valid questions, tbh - all i can tell you is that it has happened for like 2 or 3 times already to me, which is why it "extra irked" me this time ;) I kind of suspect it to be some kind of race condition when getting new values from solcast which, when it does fail, nulls the file... |
Beta Was this translation helpful? Give feedback.
-
FYI, I think I have uncovered the root of this data loss happening in the first place, and have proposed a change in v4.1.next. Serialising
There are a couple of @BJReplay and I both hit a circumstance today while testing code where an exception occurred in json.dumps(). This resulted in an empty file. I can only speculate, because I have not examined the aiofiles code we're using, but my belief is that what happens in this circumstance is the file gets opened for write, then immediately closed (because The proposal is to prepare the payload completely, then pass to a simple file write block that does not involve a JSON dump as string. This will avoid the issue. |
Beta Was this translation helpful? Give feedback.
Guys, i managed to do it - in the end, it was as simple as i suspected in my first post here.
solcast.json is in (my case) the root of the docker volume: /var/lib/docker/volumes/hass_config/_data/solcast.json (which is also why i didn't find it at first - i was looking in custom_components/solcast_solar)
I merged the current file with one from the backup, restarted HA, done.