Conversation
I added a separate sensor name for each API service. The save_forecasts_to_db function now checks which service we are using, and accordingly maps the value we are interested in to the relevant Flexmeasures sensor. Signed-off-by: Devansh Sharma <46666171+devansh287@users.noreply.github.com>
Here we ensure that the mock API response is as per the API service provider. Also popping the values for the API service provider sensors in commands. Signed-off-by: Devansh Sharma <46666171+devansh287@users.noreply.github.com>
Really appreciate you pointing this out, @nhoening. I just added "Closes #10" to the PR description. Will do so for all future PRs and their related issues. |
|
I haven't tested yet but one thing I can say: Earlier you added a Readme section called "Extending to Other Weather API Services" - I believe that now needs an extension, to also add the mapping for the service in the right place. |
@nhoening, I am waiting for the review on my changes to the code to be completed. Once that is done, I will accordingly update the README in this PR itself or a separate PR, whatever you prefer. |
|
@nhoening just bumping this |
|
Yes, sorry. |
Signed-off-by: Nicolas Höning <nicolas@seita.nl>
nhoening
left a comment
There was a problem hiding this comment.
There are two failing tests (which work well on main) - please investigate.
Here some output:
[FLEXMEASURES] Task get-weather-forecasts encountered a problem: "'time_epoch'".
More details: {'src_module': '/home/nicolas/workspace/seita/flexmeasures-weather/flexmeasures_weather/utils/weather.py', 'src_linenr': 212, 'src_func': 'save_forecasts_in_db', 'src_code': 'time_key = fc["dt"] if provider == "OWM" else fc["time_epoch"]'}
You'll have to git pull, as I fixed a formatting error that black didn't like during linting (are you running pre-commit locally?)
|
@devansh287 just bumping this :) |
| "WEATHER_MAXIMAL_DEGREE_LOCATION_DISTANCE", | ||
| DEFAULT_MAXIMAL_DEGREE_LOCATION_DISTANCE, | ||
| ) | ||
| provider = str(current_app.config.get("WEATHER_PROVIDER", "")) |
There was a problem hiding this comment.
My best guess for why tests might be failing is that this configuration setting is empty when the tests are run, so in line 212 you default to using fc["time_epoch"] (a WAPI key). It might be better to use OWM keys as the default, and/or to explicitly default the provider to OWM instead of to an empty string.
Description
I have made the mapping of the data received from Weather API to Flexmeasures sensors independent of what is going on in OWM. I did that by modifying the mapping dicts in
sensor_specs.pyto include fields for each weather api service provider. Then I modified thesave_forecasts_to_dbfunction inweather.pyto check which API service provider it is and accordingly map the data received from the api call to the flexmeasures sensor. I also made the test mock API response be as per the API service provider.This PR Closes #10.
How to test
One can test by running the flexmeasures get-weather-forecasts command on the CLI.