Windows-Auto-Night-Mode icon indicating copy to clipboard operation
Windows-Auto-Night-Mode copied to clipboard

[Feature suggestion] Add the weather prediction to the calculation

Open avi12 opened this issue 5 years ago • 8 comments

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)

avi12 avatar Dec 18 '20 13:12 avi12

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

Armin2208 avatar Dec 18 '20 19:12 Armin2208

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

Spiritreader avatar Oct 05 '21 14:10 Spiritreader

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".

Spiritreader avatar Nov 04 '21 11:11 Spiritreader

Good idea would love to support it

eymay avatar Dec 25 '21 14:12 eymay

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

Spiritreader avatar Dec 25 '21 17:12 Spiritreader

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

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

eymay avatar Dec 25 '21 19:12 eymay

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
...

Spiritreader avatar Apr 26 '23 19:04 Spiritreader