Voting resources, early voting, and poll worker information - VOTE. ... Adafruit is open and shipping.
0

How to get location_id for adafruit_io_weather.py example ap
Moderators: adafruit_support_bill, adafruit

Forum rules
If you're posting code, please make sure your code does not include your Adafruit IO Active Key or WiFi network credentials.
Please be positive and constructive with your questions and comments.

How to get location_id for adafruit_io_weather.py example ap

by rickrump on Sun Sep 27, 2020 5:33 pm

Trying to run adafruit_io_weather.py example app on original PyPortal. Runs to getting weather record from IO, but draws 404 error line 497 in adafruit_io.py. I think the location_id passed from line 64 of adafruit_io_weather.py is wrong. Comment says to obtain code from io.adafruit.com/services/waether. There it says the locationValue is a string (lattitude,longitude) but the library is looking for location_id as an int. So where do I get the int location_id?? (yes, I have the Adafruit IO Plus subscription.) Thanks!

(Posted in Discord.)

rickrump
 
Posts: 74
Joined: Sat Jan 16, 2010 1:54 pm

Re: How to get location_id for adafruit_io_weather.py exampl

by dastels on Mon Sep 28, 2020 12:06 pm

From the code:
Code: Select all | TOGGLE FULL SIZE
# Use cityname, country_code where country_code is ISO3166 format.
# E.g. "New York, US" or "London, GB"


Country codes can be found at https://www.iso.org/obp/ui/#search

It looks like the Alpha-2 code from that list is what you want.

Dave

dastels
 
Posts: 3773
Joined: Tue Oct 20, 2015 3:22 pm

Re: How to get location_id for adafruit_io_weather.py exampl

by rickrump on Mon Sep 28, 2020 2:32 pm

@dastels Thanks for that pointer to the database of COUNTRY codes. But location_id is an INTEGER city code not the string country code. That country code IS used by another PyPortal Weather app (PyPortal weather station which uses OpenWeather's API instead of Weather Underground's API.) I may use that app instead.

But I'd still like to find where to get the list of INTEGER city codes used in my post's original example.

Thanks,

Rick

rickrump
 
Posts: 74
Joined: Sat Jan 16, 2010 1:54 pm

Re: How to get location_id for adafruit_io_weather.py exampl

by dastels on Mon Sep 28, 2020 3:11 pm

I seem to have been looking at the wrong weather station project. Could you link to the project you're looking at, please?

Dave

dastels
 
Posts: 3773
Joined: Tue Oct 20, 2015 3:22 pm

Re: How to get location_id for adafruit_io_weather.py exampl

by rickrump on Mon Sep 28, 2020 3:17 pm

PyPortal Titano Weather Station: https://learn.adafruit.com/pyportal-titano-weather-station

(I know I will have to adjust the graphics in this code because of the smaller screen on the original PyPortal, but right now the code errs on the weather API call as I have written here.)
Last edited by rickrump on Mon Sep 28, 2020 3:46 pm, edited 1 time in total.

rickrump
 
Posts: 74
Joined: Sat Jan 16, 2010 1:54 pm

Re: How to get location_id for adafruit_io_weather.py exampl

by dastels on Mon Sep 28, 2020 3:46 pm

OK, I looked there, but I still have no idea what code you're referring to.

dastels
 
Posts: 3773
Joined: Tue Oct 20, 2015 3:22 pm

Re: How to get location_id for adafruit_io_weather.py exampl

by rickrump on Mon Sep 28, 2020 3:53 pm

Here's the exact link to the code. See line 59 and following as in my original post: https://github.com/adafruit/Adafruit_CircuitPython_AdafruitIO/blob/master/examples/adafruit_io_http/adafruit_io_weather.py

rickrump
 
Posts: 74
Joined: Sat Jan 16, 2010 1:54 pm

Re: How to get location_id for adafruit_io_weather.py exampl

by dastels on Mon Sep 28, 2020 4:00 pm

Ah. Yeah... "1234" looks suspicious.

OK. It works. Log in to AdafruitIO and go to
Code: Select all | TOGGLE FULL SIZE
https://io.adafruit.com/<username>/services/weather
replacing <username> with your account/user name. Then click "+ Add Location" and select your location on the map. Its ID and Lat/Long will now be inthe location list.

Dave

dastels
 
Posts: 3773
Joined: Tue Oct 20, 2015 3:22 pm

Re: How to get location_id for adafruit_io_weather.py exampl

by rickrump on Mon Sep 28, 2020 4:13 pm

Wow! Thanks!!!

I had gone to that page before but saw the code window with locationValue being a string and thought, 'well, that's not right. I'm looking for an integer.'

Thanks for being another set of eyes and seeing me through this thread!

I appreciate it.

rickrump
 
Posts: 74
Joined: Sat Jan 16, 2010 1:54 pm

Re: How to get location_id for adafruit_io_weather.py exampl

by dastels on Mon Sep 28, 2020 5:58 pm

My pleasure. Have fun.

Dave

dastels
 
Posts: 3773
Joined: Tue Oct 20, 2015 3:22 pm

Please be positive and constructive with your questions and comments.