Skip to content
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

Add SMHI as an weather provider for Sweden #51

Merged
merged 6 commits into from
Feb 5, 2023

Conversation

hnnweb
Copy link
Contributor

@hnnweb hnnweb commented Feb 3, 2023

Add SMHI (Swedish Meteorological and Hydrological Institute) as an weather provider for Sweden

@mendhak
Copy link
Owner

mendhak commented Feb 3, 2023

Thanks for that , looks good.

I'm just testing this and going to make a few changes. The weather symbol position in the JSON seems to change so I'll keep a part of the loop. And there's a comment about getting the min/max of the next XX hours, I'm just working on that now, I'll push it up. I've had to do this in another weather provider too so it isn't too difficult.

Some notes for myself:

  • Linting
  • Testing
  • README
  • env.sh.sample
  • Changelog

for param in weather_data[item]['parameters']:
if param['name'] == 't':
temp = param['values'][0]
temp_list.append(temp)
Copy link
Owner

Choose a reason for hiding this comment

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

Looping through 12 forecasts, getting the temperature out, adding it to a list, then below getting min and max of those temperatures. So it acts as a min/max forecast for 12 hours.

The weather symbol unfortunately that's a bit difficult since there's no "min/max" or "average" of symbols.

# Get the weather code of the first item.
for data in weather_data[0]["parameters"]:
if data["name"] == "Wsymb2":
weather_code = data["values"][0]
Copy link
Owner

Choose a reason for hiding this comment

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

In my testing the weather symbol was sometimes appearing in a different location so I decided just keep the looping bit to find the Wsymb2.

@mendhak mendhak merged commit 3670b48 into mendhak:master Feb 5, 2023
@mendhak
Copy link
Owner

mendhak commented Feb 5, 2023

Thanks, done and merged. I've added to the changelog as well.

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.

2 participants