Skip to content

Conversation

@devansh287
Copy link

@devansh287 devansh287 commented Aug 8, 2025

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.py to include fields for each weather api service provider. Then I modified the save_forecasts_to_db function in weather.py to 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.

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>
@nhoening
Copy link

nhoening commented Aug 8, 2025

Does this close issue #10?

Then please add "Closes #10" to the PR description, which is helpful for context but also automate a few things in GitHub (creates a link on both issue&PR, auto-closes issue if PR is merged)

@devansh287
Copy link
Author

Does this close issue #10?

Then please add "Closes #10" to the PR description, which is helpful for context but also automate a few things in GitHub (creates a link on both issue&PR, auto-closes issue if PR is merged)

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.

@nhoening
Copy link

nhoening commented Aug 9, 2025

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.

@devansh287
Copy link
Author

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.

@devansh287 devansh287 requested a review from nhoening August 11, 2025 06:54
@devansh287
Copy link
Author

@nhoening just bumping this

@nhoening
Copy link

Yes, sorry.
Vacation and other things in the way.
Good to keep reminding me.

Signed-off-by: Nicolas Höning <nicolas@seita.nl>
Copy link

@nhoening nhoening left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?)

@nhoening
Copy link

@devansh287 just bumping this :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Make OWM and WAPI mappings independent

2 participants