Skip to content

Provider independence#11

Merged
nhoening merged 7 commits into
mainfrom
provider-independence
Jun 5, 2026
Merged

Provider independence#11
nhoening merged 7 commits into
mainfrom
provider-independence

Conversation

@devansh287

@devansh287 devansh287 commented Aug 8, 2025

Copy link
Copy Markdown

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

nhoening commented Aug 8, 2025

Copy link
Copy Markdown
Member

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
Copy Markdown
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

nhoening commented Aug 9, 2025

Copy link
Copy Markdown
Member

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
Copy Markdown
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
Copy Markdown
Author

@nhoening just bumping this

@nhoening

Copy link
Copy Markdown
Member

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

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

@nhoening nhoening left a comment

Copy link
Copy Markdown
Member

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
Copy Markdown
Member

@devansh287 just bumping this :)

Comment thread flexmeasures_weather/utils/weather.py
@nhoening

Copy link
Copy Markdown
Member

Hi @devansh287 just bumping this :)

Signed-off-by: Nicolas Höning <nicolas@seita.nl>
@nhoening nhoening self-assigned this Jun 1, 2026
nhoening added 3 commits June 5, 2026 12:59
Signed-off-by: Nicolas Höning <nicolas@seita.nl>
Signed-off-by: Nicolas Höning <nicolas@seita.nl>
Signed-off-by: Nicolas Höning <nicolas@seita.nl>
@nhoening

nhoening commented Jun 5, 2026

Copy link
Copy Markdown
Member

I fixed the tests and tested manually that the command works (I used OWM).

@nhoening nhoening merged commit ec5032d into main Jun 5, 2026
5 checks passed
@nhoening nhoening deleted the provider-independence branch June 5, 2026 11:28
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

3 participants