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

weather update failing (late July 2022, number 2) due to location look up error (locationIQ) #57

Closed
clach04 opened this issue Jul 25, 2022 · 12 comments

Comments

@clach04
Copy link
Contributor

clach04 commented Jul 25, 2022

EDITED

Workaround

  • Deleting app (rather than re-installing)
  • installing
  • remove location override and rely on GPS - this avoids the failing look up step

That then allows openweathermap to work for me. Both Underground and Darksky appear to get stuck on callback (using web browser or curl on same URL that's used in code works fine). From quick scan of code, adding error handling for bad results with a console.log() may reveal more information.

Original report:

Not related to #56

Related to #41 - similar but different

reverse geocoding location call to https://us1.locationiq.com/ is returning:

{"error":"Key not active - Please write to hello@locationiq.org"}

Previously

{"error":"Rate Limited Day"}

This then kills weather updates :-(

I do not have a solution :-( Options:

@clach04
Copy link
Contributor Author

clach04 commented Jul 25, 2022

Actual logs (for https://github.com/mattrossman/forecaswatch2/releases/tag/v1.19.0) below:

[09:41:17] pkjs> FCW2:110 Force fetch!
[09:41:17] pkjs> FCW2:222 Fetching from OpenWeatherMap
[09:41:17] pkjs> FCW2:446 Using geocoded coordinates
[09:41:17] pkjs> FCW2:113 Closing clay: {"timeLeadingZero":true,"timeShowAmPm":false,"axisTimeFormat":"24h","timeFont":"roboto","weekStartDay":"mon","firstWeek":"
prev","temperatureUnits":"f","provider":"openweathermap","darkSkyApiKey":"**REDACTED**","owmApiKey":"**REDACTED**","fetch":true,"location":
"**REDACTED**","showQt":true,"vibe":true,"btIcons":"both"}
[09:41:17] pkjs> FCW2:69 TypeError: Cannot read properties of undefined (reading 'lat')
TypeError: Cannot read properties of undefined (reading 'lat')
    at file:///data/user/0/com.getpebble.android.basalt/app_js_app_files/7ed9b053-1521-4e49-be8b-6e12c68978ae/pebble-js-app.js:417:79
    at xhr.onload (file:///data/user/0/com.getpebble.android.basalt/app_js_app_files/7ed9b053-1521-4e49-be8b-6e12c68978ae/pebble-js-app.js:335:10)
[09:41:17] pkjs> FCW2:417 Uncaught TypeError: Cannot read properties of undefined (reading 'lat')
[09:41:17] app_message.c:10> Message received!

line 417 is the console.log line

WeatherProvider.prototype.withGeocodeCoordinates = function(callback) {
    // callback(lattitude, longtitude)
    var url = 'https://us1.locationiq.com/v1/search.php?key=dd15eccc31178e'
        + '&q=' + this.location
        + '&format=json';
    request(url, 'GET', function (response) {
        var locations = JSON.parse(response);
        if (locations.length === 0) {
            console.log('[!] No geocoding results')
        }
        else {
            var closest = locations[0];
            console.log('Query ' + this.location + ' geocoded to ' + closest.lat + ', ' + closest.lon);  // line 417
            callback(closest.lat, closest.lon);
        }
    });
}

@mattrossman
Copy link
Owner

I swear, these API issues always pop up during the few days that I'm not wearing my pebble. Thanks for bringing it to my attention.

I'd be fine with switching to another reverse geocoding API. I don't actually remember how I set up the LocationIQ stuff -- if I registered for an API key then I no longer have access to the account's email address.

Any suggestions on alternatives? I'll need to do some research to see what other options are out there, it would need to be something with a generous free tier.

I'd also like to make it save the coordinates returned by the lookup API rather than running the query every time -- one less point of failure since that output isn't really expected to change.

@clach04
Copy link
Contributor Author

clach04 commented Jul 25, 2022

Sadly I do not have alternative suggestions, I've not really dug in to this yet.

👍 on the caching.

What's interesting about my use case is that I had hard coded in lat and long values for the override, AA.BB, XX.YY and the reverse lookup call still takes place. I might have some ideas on how to avoid that with a regex.

I'm not going to be able to look into this in more detail for a while though. I will try and get a PR for extra tracing at some point (that would have helped reduce time exploring the js code with this issue and the issue I'm seeing with the other two providers).

As always, thanks for the watchface! I hope you are having a great summer!

@mattrossman
Copy link
Owner

What's interesting about my use case is that I had hard coded in lat and long values for the override, AA.BB, XX.YY and the reverse lookup call still takes place. I might have some ideas on how to avoid that with a regex.

Heh yeah I was lazy and just forwarded everything to the locationIQ API since it's pretty flexible with the query format. I like your idea of using a regex to detect a valid lat/long input and skip the lookup.

@clach04
Copy link
Contributor Author

clach04 commented Jul 26, 2022

https://github.com/clach04/pebble-forecaswatch2-fcsw2-fcw2/tree/js_log_rest_calls contains quick and dirty log all URL requests.

Seeing this:

pkjs> FCW2:341 GET URL: https://us1.locationiq.com/v1/search.php?key=dd15eccc31178e&q=37.769310,-122.259890&format=json
....
pkjs> FCW2:338 URL returned{"error":"Key not active - Please write to hello@locationiq.org"}

Which now matches what I see in the web browser (the rate limit from this morning is replaced with the above.

@PowerScissor
Copy link

Is there a workaround for us non-coders to get the API up and working?

I would be so grateful for any ideas, as I've really become dependent on this watchface.

@clach04
Copy link
Contributor Author

clach04 commented Jul 26, 2022

@PowerScissor Yes, see the top description. Remove location and rely on GPS using the openweathermap provider.

A coding solution is possible but will be a while.

@PowerScissor
Copy link

PowerScissor commented Jul 26, 2022

@PowerScissor Yes, see the top description. Remove location and rely on GPS using the openweathermap provider.

A coding solution is possible but will be a while.

My options are weather underground & dark sky. I always use GPS.

I'm going to assume the watch app version that was installed through the Rebble app store is outdated / not updated there is why I don't see any openweather option. I'll research how to install the most current version watch app from here and see if that gives me the working options.

Thanks.

Update: I installed v 1.19, and did get the open weather option. It also fails to work regardless of using GPS or not. Just an FYI if anyone else is interested in the info...not expecting a response.

@clach04 clach04 changed the title weather update failing (late July 2022, number 2) due to location look up error weather update failing (late July 2022, number 2) due to location look up error (locationIQ) Jul 26, 2022
@clach04
Copy link
Contributor Author

clach04 commented Jul 26, 2022

@PowerScissor I opened #60

@clach04
Copy link
Contributor Author

clach04 commented Jul 26, 2022

Update: I installed v 1.19, and did get the open weather option. It also fails to work regardless of using GPS or not. Just an FYI if anyone else is interested in the info...not expecting a response.

Doh! Not sure if it helps, but it works for me (with a GPS location in the US). The other providers do not (hence opening #60), however those providers are relatively easy to fix.

@clach04
Copy link
Contributor Author

clach04 commented Jul 26, 2022

I'd be fine with switching to another reverse geocoding API. I don't actually remember how I set up the LocationIQ stuff -- if I registered for an API key then I no longer have access to the account's email address.

I tested last night with a new locationIQ key and it works fine. Quickest option would be for you to register a new key and use that. Longer term, maybe prompt the user for a key as part of config?

@mattrossman
Copy link
Owner

I'll include a new locationiq key in the next release, thanks

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

3 participants