initialstate/wunderground-sensehat

sensehat_wunderground.py running error

Closed this issue · 9 comments

Traceback (most recent call last):
File "sensehat_wunderground.py", line 197, in
main()
File "sensehat_wundergroiund.py", line 139, in main
streamer.log(":house: Location",conditions['current_observation']['display_location']['full'])
KeyError: 'current_observation'

Also how do we change it all to Metric? :)

To change the units, simply replace the variables with the ones that have the desired units and update the name. For example:
streamer.log(CITY + " Temperature(F)",conditions['current_observation']['temp_f'])
becomes
streamer.log(CITY + " Temperature(C)",conditions['current_observation']['temp_c'])

You can see a list of all available variables when you make the api call in your web browser and view what is returned (e.g. http://api.wunderground.com/api/0def10027afaebb7/conditions/q/TN/Franklin.json). For example, you can see there is a wind_kph variable (instead of wind_mph), dewpoint_c (instead of dewpoint_f), etc.

For your error, this is usually caused because the city and state parameters in the user settings is not supported by the Wunderground API. What city and state are you using to get your location? Can you plug your city and state into an API call in your web browser and get a value returned? Don't use spaces.

e.g.
http://api.wunderground.com/api/7677697061ebefb3/conditions/q/YOUR_STATE/YOUR_CITY.json

Hi. Yes this is after I fixed South Africa to use ZA. With the space it gave the same error as the other user reported. Using ZA/Johannesburg it works fine on the API and is reporting the stats but stops with that error. The sensehat.py works perfectly with the same settings as does the wunderground.py. I had already figured out the metric changes needed as well so thanks for that as I have no idea what I'm doing in Python.

----- Original Message -----

From: "jrbail01" notifications@github.com
To: "InitialState/wunderground-sensehat" wunderground-sensehat@noreply.github.com
Cc: "GordonMKF" gordon@cpdata.co.za
Sent: Friday, March 18, 2016 8:41:17 PM
Subject: Re: [wunderground-sensehat] sensehat_wunderground.py running error (#3)

To change the units, simply replace the variables with the ones that have the desired units and update the name. For example:
streamer.log(CITY + " Temperature(F)",conditions['current_observation']['temp_f'])
becomes
streamer.log(CITY + " Temperature(C)",conditions['current_observation']['temp_c'])
You can see a list of all available variables when you make the api call in your web browser and view what is returned (e.g. http://api.wunderground.com/api/7677697061ebefb3/conditions/q/TN/Franklin.json ). For example, you can see there is a wind_kph variable (instead of wind_mph), dewpoint_c (instead of dewpoint_f), etc.
For your error, this is usually caused because the city and state parameters in the user settings is not supported by the Wunderground API. What city and state are you using to get your location? Can you plug your city and state into an API call in your web browser and get a value returned? Don't use spaces.
e.g.
http://api.wunderground.com/api/7677697061ebefb3/conditions/q/YOUR_STATE/YOUR_CITY.json

You are receiving this because you authored the thread.
Reply to this email directly or view it on GitHub

Does it run for a while but error out after some period of time with that error (or does it error out immediately every time)? I noticed that occasionally (as in, every few weeks) mine will do that too, even though the script tries to prevent that from happening with the line of code:
if ((conditions != False) and (astronomy != False)):

It runs for a while then errors out. Seems to be the same amount of time every time. Shows 1 set of sensor info then error and stop

----- Original Message -----

From: "jrbail01" notifications@github.com
To: "InitialState/wunderground-sensehat" wunderground-sensehat@noreply.github.com
Cc: "GordonMKF" gordon@cpdata.co.za
Sent: Friday, March 18, 2016 11:33:25 PM
Subject: Re: [wunderground-sensehat] sensehat_wunderground.py running error (#3)

Does it run for a while but error out after some period of time with that error (or does it error out immediately every time)? I noticed that occasionally (as in, every few weeks) mine will do that too, even though the script tries to prevent that from happening with the line of code:
if ((conditions != False) and (astronomy != False)):

You are receiving this because you authored the thread.
Reply to this email directly or view it on GitHub

I am sure that you already checked this, but is the internet connection stable the entire time on the device itself? I just want to make sure the script isn't trying to make an API call with the connection down.

Pefectly stable. Tier 1 ISP with SLA's etc.

----- Original Message -----

From: "jrbail01" notifications@github.com
To: "InitialState/wunderground-sensehat" wunderground-sensehat@noreply.github.com
Cc: "GordonMKF" gordon@cpdata.co.za
Sent: Friday, March 18, 2016 11:55:01 PM
Subject: Re: [wunderground-sensehat] sensehat_wunderground.py running error (#3)

I am sure that you already checked this, but is the internet connection stable the entire time on the device itself? I just want to make sure the script isn't trying to make an API call with the connection down.

You are receiving this because you authored the thread.
Reply to this email directly or view it on GitHub

Modify the MINUTES_BETWEEN_READS to something shorter (like 5 minutes) and see how many times it gets through that loop before erring out. Are you using your own WUNDERGROUND_API_KEY key (making sure that Wunderground isn't returning a "sorry, this API key has exceeded its # of calls per hour" error).

I just pushed an update to the scripts that should address the errors. I added better error checking to prevent an exit if a call to the Wunderground API fails. Try the updated scripts and let me know if this keeps everything running w/o crashing.

Oh, and I added a METRIC_UNITS option in the User settings to allow you to quickly select Celsius, kph, etc. w/o having to modify the rest of the script.