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

[Feature suggestion] Add the weather prediction to the calculation #193

Open
avi12 opened this issue Dec 18, 2020 · 7 comments
Open

[Feature suggestion] Add the weather prediction to the calculation #193

avi12 opened this issue Dec 18, 2020 · 7 comments
Labels
enhancement New feature or request

Comments

@avi12
Copy link

avi12 commented Dec 18, 2020

Typically, when it's rainy (maybe snowy as well; can't test in Israel), the sky will become darker earlier due to many clouds being together across a wide area
Currently, to combat this I need to manually specify a large offset (the other day it was as much as -66 minutes), but it isn't reliable, as in Israel the next day might be sunny, thus the sky will turn dark later

I believe that the calculation shouldn't be hard: If it's predicted to be rainy (e.g. showers), offset the time to the rain time if it's close to the afternoon (e.g. 3 PM)

@Armin2208
Copy link
Member

good idea, hard to implement. will see how this goes.

@Spiritreader
Copy link
Member

Weather query APIs generally aren't free, so I don't see this to be possible in the near future

@Spiritreader Spiritreader added the enhancement New feature or request label Oct 5, 2021
@Spiritreader
Copy link
Member

Spiritreader commented Nov 4, 2021

This is now theoretically possibly by using OpenWeather's OneCall API (https://openweathermap.org/api/one-call-api)
However the feature needs a lot more functional definition and specification.

I would put this feature in the ballpark of "possible, if more people contribute to it".

@eymay
Copy link

eymay commented Dec 25, 2021

Good idea would love to support it

@Spiritreader
Copy link
Member

Good idea would love to support it

if you want to contribute, it would be nice to have a proof of concept C# application that reads and parses openweathermap API data

@eymay
Copy link

eymay commented Dec 25, 2021

Here is an easy snippet or a library we can use.

I'm kind of unsure, regarding the current architecture, how to implement it.

@Spiritreader
Copy link
Member

I think a good way to implement this would be to create a WeatherHandler and introduce an additional offset variable.

Concept

The WeatherHandler is responsibe for querying the weather API and returning weather information for a provided geo position (Lat/Lon)

It would be a static class that has at least two public methods handle

  • getting data from the weather API
  • parsing the data

For example
T GetWeather(int lat, int lon) to retrieve the weather data.

Weather ParseWeatherData(T weatherData) where the return type Weather is an Enum consisting of for example:

  • Cloudy
  • Sunny
  • Rainy
  • Windy
    etc.

Ideally that happens asynchronously so the application doesn't pause.

Having that WeatherHandler available would go a long way in being able to implement this.

Integration in ADM

That weatherhandle can be wrapped by a module and update periodically.
The module updates a variable in its global app state.
This variable can then be used in the location service based switching logic to apply the offset.

Config

The rest would involve creating a config that stores offset values for certain weather types.

...
Sunny: -15
Rainy: 25
Cloudy: 10
...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants