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

Missing weather when using GPS #69

Open
clach04 opened this issue Jun 30, 2023 · 3 comments
Open

Missing weather when using GPS #69

clach04 opened this issue Jun 30, 2023 · 3 comments

Comments

@clach04
Copy link
Contributor

clach04 commented Jun 30, 2023

I'm missing weather when GPS has not been on for (~16 hours), and enabling GPS fixes the issue. This is an idea for a feature, assuming I've diagnosed the problem correctly ;-)

Most of the time I set config to the location I care about, I.e. Location override is NOT left blank. My use case is I don't travel very far, very often, so I always want to see "home" weather. I also don't turn the GPS on that much.

When I travel I'll often leave it blank (to indicate Using GPS. ) but sometimes GPS will be off (e.g. saving power) I'll forget to re-enable. This ends up with blank weather information, force-fetching does NOT fix the issue. Have to re-enable GPS.

Idea is that if Location override is left blank, use GPS as per current behavior to get location, then:

  1. Use (browser) local storage to save that information, if the location is the same as current cache leave alone.
  2. If GPS lookup fails, use cache location information

For me this would work great for my use case.

I'm not sure if this would work for everyone, if not this approach would also need a new "cache location" option added to the config page.

Seeking feedback :-)

@clach04
Copy link
Contributor Author

clach04 commented Nov 19, 2023

Main logic located in

WeatherProvider.prototype.withGpsCoordinates = function(callback) {

Ideas:

  1. Add local storage cache (maybe with bounding box for when to update cache?)
  2. Use Infinity for maximum age instead of 10k milliseconds (10 seconds)

clach04 added a commit to clach04/pebble-forecaswatch2-fcsw2-fcw2 that referenced this issue Nov 19, 2023
@clach04
Copy link
Contributor Author

clach04 commented Nov 23, 2023

I experimented with number 2 above with clach04@16b5cb0 and been running for a few days and this does not work (at least on my Android 10 device).

Which leaves number 1 with some sort of delta offset/bounding box to avoid updating the cache EVERY time . Updating cache may not be that terrible, we record the last successful pull already:

https://github.com/mattrossman/forecaswatch2/blob/a84a3a79753fe6dddfa6d066b8b1db4df7c20fc7/src/pkjs/index.js#L13C57-L13C57

localStorage.setItem('lastFetchSuccess', JSON.stringify(fetchStatus));

in lastFetchSuccess.time, idea is to add a new attribute to:

var fetchStatus = {

var fetchStatus = {
    time: new Date(),
    id: provider.id,
    name: provider.name
}

clach04 added a commit to clach04/pebble-forecaswatch2-fcsw2-fcw2 that referenced this issue Nov 23, 2023
clach04 added a commit to clach04/pebble-forecaswatch2-fcsw2-fcw2 that referenced this issue Nov 23, 2023
clach04 added a commit to clach04/pebble-forecaswatch2-fcsw2-fcw2 that referenced this issue Dec 2, 2023
clach04 added a commit to clach04/pebble-forecaswatch2-fcsw2-fcw2 that referenced this issue Dec 3, 2023
Actually de-serialize cached dictionary.
clach04 added a commit to clach04/pebble-forecaswatch2-fcsw2-fcw2 that referenced this issue Dec 3, 2023
Actually de-serialize cached dictionary.
@clach04
Copy link
Contributor Author

clach04 commented Dec 3, 2023

Finally got some time to spend on this. I have a prototype branch https://github.com/clach04/pebble-forecaswatch2-fcsw2-fcw2/tree/issue69_cached_gps_location

It unconditionally caches GPS location, and then uses that on a GPS lookup failure.

Possible improvements:

  1. add an option to enable/disable this behavior? I personally always want this on.
  2. do not update cached location if the new location is "close" to the cached location, via some config option? Not sure if there are negative implications for updating local storage on each GPS read.

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

No branches or pull requests

1 participant