-
Notifications
You must be signed in to change notification settings - Fork 2
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
Why extra queries to fusionsolar for date in future #36
Comments
That's very good point, thanks! IIRC, the 2-days query was to fix some backfill issue, so querying the future is not needed in in-sync operations at all. Let me test your fix over a 2 days to make sure it works as expected :-) |
Hm, it stopped to work after midnight and now I think I recall that It would be for sure beneficial to get rid of the extra call, but not knowing the logic in the backend it could just introduce delays in the data delivery... What do you think, @rvk01 ? |
I've noticed that this morning too :) I will investigate this and get back. |
Ok, I investigated this. (assuming current date/time 18-02-2023 13:00) What we really want is all data until today/tonight at midnight. So until 19-02-2023 00:00. Something like:
The only downside of this is that because there is no reports to pvoutput after sundown, it will still try to retrieve the previous complete day from 00:00 to sunrise AND the current day, resulting in those extra calls in that timeslot. But it's already much better than calling for the next day in the timeslot sunrise to 23:59, which it did (because pvoutput was up to date). (This code is running now so I will keep an eye on it :) ) |
Fantastic investigation! If the code works as expected, feel free to push a PR, I'm happy to merge :-) |
For now it seems to be working correctly. From the logs (below) it will pull 7 requests (from one day) until 00:00. This weekend there was maintenance on fusionsolar site and my version crashed out with first some Backing off call_api(...) Connection refused. Then after 10 minutes, it got a "Login successful" after which it crashed out with "TypeError: getattr(): attribute name must be string". Not a big deal but I thought I mention it. For pushing a PR, I'm still not very familiar with GIT. I've always used github in combination with SVN myself. But I also found that, for me, the 7-14 requests are not all needed. I only use it in combination with pvoutput, and for that only day_cap and active_power are needed (30016 and 30014). Now they are pulled in with different requests, per unit (including lots I don't need), but I can request 30016 and 30014 together in one call (even though the units differ, kwH and Wh), cutting down the request from 7 to 14 to just 1 or 2. Furthermore, I was also thinking about querying the device-list before every loop. In it, there is inverter shutdown and startup. If shutdown is > startup, you know the inverter hasn't had any data after that. So there would be no need to query for the data (cutting down the requests to just one). I first thought about pulling device-real-kpi to get the startup and shutdown, but that only works when the inverter is online. After shutdown, it only reports that the device isn't connected. But the device-list keeps both times. Another thought would be to just use sunrise and sunset times and sleeping (not querying) during sunset+1hour to sunrise-1hour. Although in that case it might be needed to still do a call to idle on fusionsolar. But then the calls can be cut down to absolute minimum. Those where just some of my ideas... :) 2023-02-19 23:51:51,610 No data to update |
In query() in huawei-solar/api/fusionsolar.py you call self.query_single_unit_2_days.
But if the date is for today/now (because you are up to date with pvoutput) the self.query_single_unit() is still called for timestamp+24*3600 in self.query_single_unit_2_days(), which is tomorrow (a date in the future).
Is there a special reason for this?
This is done for every signal so about 7 extra calls which return empty days.
Wouldn't it be better to check in query_single_unit() (or somewhere else) that querying a date in the future isn't done?
Something like:
The text was updated successfully, but these errors were encountered: