ha-solcast-solar: Easier re-startup for returning Solcast users (down for a while...)
Is your feature request related to a problem? Please describe. Came back home today after 2 weeks away, a week and a half of that with HA not working and no remote access to fix. [Weirdly HA seemed to loose outbound IP connectivity, it was still running but couldn’t talk to anything]
So all my Solcast entities were empty.
Restarting HA fixed the remote connectivity but of course no Solcast data until I remembered why and manually ran the Solcast update automation.
For new users (and people like me which have had a broken HA), this extra step to manually run the Solcast update is something that could be improved upon.
Describe the solution you’d like When Solcast integration starts and detects that there is no Solcast data and/or zero API calls made today, it automatically calls the update_solcast service.
One disadvantage of this auto-retrieve is that users may not realise that this retrieve is a ‘freebie’ and they have to write the automation for future polls, but its pretty clear in the documentation
Describe alternatives you’ve considered Leave as-is, users have to remember to create/run the automation themselves.
Additional context I don’t have the logfile any more as I ended up restarting HA and the PC my HA guests upon multiple times [because some weird reason my HA server had been allocated a different IP address, despite having a fixed IP]
But the logfile was pretty clear, it loaded the sites data, the API calls from Solcast and all the ‘data for’ from the cache were zero where now it shows data loaded from the cache:
2024-08-04 18:12:59.646 DEBUG (MainThread) [custom_components.solcast_solar.solcastapi] API counter for ******Db75Av is 2/10
2024-08-04 18:12:59.899 DEBUG (MainThread) [custom_components.solcast_solar.solcastapi] The saved data file exists, file type is <class 'dict'>
2024-08-04 18:13:00.595 DEBUG (MainThread) [custom_components.solcast_solar.solcastapi] Calc forecast start index midnight utc: 2024-08-03 23:00:00+00:00, idx 14961, len 15314
2024-08-04 18:13:00.688 DEBUG (MainThread) [custom_components.solcast_solar.solcastapi] Data for 2024-08-04 contains only 16 of 48 records and may produce inaccurate forecast data
2024-08-04 18:13:00.688 DEBUG (MainThread) [custom_components.solcast_solar.solcastapi] Data for 2024-08-05 contains all 48 records
2024-08-04 18:13:00.688 DEBUG (MainThread) [custom_components.solcast_solar.solcastapi] Data for 2024-08-06 contains all 48 records
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 54
Commits related to this issue
- Startup auto-fetch on stale data #110 — committed to BJReplay/ha-solcast-solar by autoSteve 2 years ago
Restored HA test server, inserted this newest code into
__init__.py, (I didn’t do the other code in solcastapi.py but figured it would sort itself out at the next 5 minute boundary):And sensors populated:

Think we are there!
I probably didn’t wait 5 minutes, but would have thought that things like pv_forecast_today and api_last_polled would have been updated immediately after a Solcast poll?
I just restarted the test VM up and the sensors are all now populated:
With the last time polled (14:12 UTC) corresponding to the prior log file of polling at 15:12 BST
However, when I look at the sensor history, all is revealed:
The poll on initial HA startup at 15:12 must have populated the solcast cache file but NOT the sensors, they only appear to have been updated just now when I restarted the VM 10 minutes ago.
I can re-test this tomorrow if need be, I have got a backup of the test server taken before we started messing around with this fix.
Perfect. In a busted-test-rig kind of way. 😂
This pleases greatly, so thank you, Geoff.
Thanks for all the responses. Do you want me to turn on the extra logging first and post that, or just apply the fix (no logging), or apply fix and turn on logging?
I’ll have a go at testing it but I think I’ll create a second test HA instance first.
I need to do that anyway as I want to test retrieving my missing solar generation & import/export history from the inverters and loading it into HA statistics.
Leave it with me to get the second instance up and running
I raised it to enable a discussion as much as anything else.
My scenario is quite an edge case but I was pretty sure that for new installs it didn’t do a retrieve automatically. I think that’s what happened when I installed initially and when I swapped from oziee to bjreplay fork (and went through a probably unnecessary uninstall)