-
-
Notifications
You must be signed in to change notification settings - Fork 30.9k
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
Requesting data from last seven days #49485
Conversation
Wait, shouldn't this be reverted/fixed in the upstream library? |
Thank you for the quick review. I don't know where it should be fixed, maybe the new values for the optional parameters makes sense to have in the upstream library? Personally I never liked optional parameters because it could lead to exactly these kind of bugs. Now this code set values instead of relying on "hidden" defaults. Feel free to decline and close the PR if you think that is the correct thing to do. |
But one way or another we need a solution. Could @ronaldheft maybe look at it. It seems that @vangorra has stopped maintaining this Integration |
@mariwing The reason the parameters now have a default of a date is due to the arrow 1.0 dependency. The migration guide for arrow 1.0 says this:
The previous defaults for the parameters were The correct fix is to set to a reasonable start and end date for the date instead of passing You won't see this error if your Home Assistant install is using an older version of arrow <1.0, which might be what schachar observed in his patch. Setting a value for the date will fix it for both arrow >= 1.0 and arrow <1.0. I don't have the time at the moment to test and submit a PR myself, but I would think maybe a time range of 7 days or 30 days may be a reasonable time range? It's only going to return the latest data in the time range specified. |
Thank you @ronaldheft for the explanation! I will do some local testing and update this PR with date values. |
@mariwing Good luck. Looking forward to your findings and PR. |
@frenck If you have time to review this again that would be great! After feedback from @ronaldheft I got a better understanding of the issue. I have updated the PR so we now supply dates and ask for data for the last seven days. It has been tested locally and works fine. My understanding of the underlying code is that it sorts the returned data and uses the latest data point for each type of data. So getting data for the last 7 days means that a measurement needs to have happened during the last 7 days to appear in Home Assistant. I think that is a reasonable balance between fetching large amount of data that will just get discarded and having measurements available on the first run of the integration. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great. Thank you @mariwing @ronaldheft, @schachar and @frenck |
Breaking change
Proposed change
This PR fixes an issue caused by changes in dependency vangorra/python_withings_api@02a3164 that changed default values for date parameters from None to UtcNow. The fix now specify all the optional parameters as None, in effect restoring the old default values.
Thanks to schachar for figuring it out!
Type of change
Example entry for
configuration.yaml
:# Example configuration.yaml
Additional information
Checklist
black --fast homeassistant tests
)If user exposed functionality or configuration variables are added/changed:
If the code communicates with devices, web services, or third-party tools:
Updated and included derived files by running:
python3 -m script.hassfest
.requirements_all.txt
.Updated by running
python3 -m script.gen_requirements_all
..coveragerc
.The integration reached or maintains the following Integration Quality Scale:
To help with the load of incoming pull requests: