Re: Weather Underground Plugin
Posted: Mon Apr 10, 2017 6:30 am
ok only 1 action to go.
OK there are 2 requests for this I will make it that wayyokel22 wrote:I played around with it a little bit today. Most things seem to be working well. I here you on the copy/paste but agree with "loveleejohn" that the location should be set in the plugin config, not in each actions config.
how about this??. I will add the global location information. but I will leave the ones in the action as well they will just auto populate with the global ones. that way all you would need to do is to change it in that actions config. and if you pass no parameters in the call to the action it will use the global ones. doing it this way is always going to return the plugins data object.yokel22 wrote:If you need multiple locations, you can multiload the plugin, or add an action to change the location.
yokel22 wrote:I was wondering if you could add an option to return "raw Json"? Similar to how you have the "return xml string" action setup currently.
I believe i mentioned this.. but the thing to remember is you get the 10 free calls per minute no matter what level of API key you select. the highest tier allows for all of the API to function. so get the best one. because for a single seat use 10 calls per minute is a whole lot. I have been thinking about adding a polling thread for current weather, 4 day forecast and 10 day forecast that would only trigger an event if something has changed. and the user could select the polling interval and would produce a warning if it is set over 10 calls per minute. personally i think a call once every 10 is a lot but if you are using this to grab data from a PWS then yeah maybe once a minute.yokel22 wrote:Just an FYI to anyone that's new to Weather Undergrounds api, the free keys they give out are limited to 10 requests a minute. They don't usually shut you off but something to keep in mind when testing stuff.
Code: Select all
item = eg.plugins.WeatherUnderground.Forecast10Day(u'66203', u'Shawnee', u'', False, False, True, False)
for day in item['forecast']['simpleforecast']['forecastday']:
print day['high']['fahrenheit']
for text in item['forecast']['txt_forecast']['forecastday']:
print text['title']
print text['fcttext']
Code: Select all
item = eg.plugins.WeatherUnderground.Conditions(u'66203', u'Shawnee', u'', False, False, True, False)
print item['current_observation']['temp_f']
Code: Select all
item = eg.plugins.WeatherUnderground.Forecast10Day(u'66203', u'Shawnee', u'', False, True, False, False)
# the _ is the date used to access the forecast data if calling it directly
# we don't need it but we still have to account for it being returned.
for _, forecast in item:
print '%s, %s' % (forecast.title, forecast.date.pretty)
print ' High Temp: %s\xB0 F' % forecast.high
print ' Low Temp: %s\xB0 F' % forecast.low
Code: Select all
print item.Apr14['high']['fahrenheit']
print item.Apr14['high']['celsius']
# this will work also
print item['apr14']['high']['fahrenheit']
print item['apr14']['high']['celsius']
Code: Select all
eg.globals.SOME_FORECAST.Update()
if eg.globals.SOME_FORECAST.IsDirty():
do your code here.
Code: Select all
import datetime
date = datetime.datetime.now()
forecast_date = date .strftime('%b%d').lower()
forecast = eg.globals.SOME_FORECAST[forecast_date]
forecast .Update()
if forecast.IsDirty():
do code here
Code: Select all
# this will include day and night forecast
print str(item.Apr14)
# this will be only the night
print str(item.Apr14.Night)
Code: Select all
import datetime
date = datetime.datetime.now()
forecast_date = date .strftime('%b%d').lower()
forecast = SOME_FORECAST[forecast_date]
Code: Select all
import datetime
date = datetime.datetime.now()
date += datetime.timedelta(days=1)
forecast_date = date .strftime('%b%d').lower()
forecast = SOME_FORECAST[forecast_date]
Code: Select all
import datetime
date = datetime.datetime.now()
forecast_date = date .strftime('%b%d').lower() + '10'
forecast = SOME_FORECAST[forecast_date]
Code: Select all
import datetime
date = datetime.datetime.now()
forecast_date = date .strftime('%b%d').lower() + '22'
forecast = SOME_FORECAST[forecast_date]
Code: Select all
import datetime
date = datetime.datetime.now()
date += datetime.timedelta(days=1)
forecast_date = date .strftime('%b%d').lower() + '10'
forecast = SOME_FORECAST[forecast_date]
Code: Select all
import datetime
date = datetime.datetime.now()
date += datetime.timedelta(days=1)
forecast_date = date .strftime('%b%d').lower() + '22'
forecast = SOME_FORECAST[forecast_date]
Yep, i just have a handful of fairly complicated scripts that were making calls directly to the api. Essential, just waiting to be worked into a plugin, ya just beat me to itI just want to let you know that you can iterate the data class that i made to represent the weather data.
Code: Select all
Weather Underground: Current Conditions
Error in Action: "Weather Underground: Current Conditions"
Traceback (most recent call last) (1722):
File "C:\Program Files (x86)\EventGhost\eg\Classes\ActionBase.py", line 170, in CallWrapper
return self(*args)
File "C:\ProgramData\EventGhost\plugins\WeatherUnderground\__init__.py", line 332, in __call__
payload = func(loc1, loc2, pws_id, metric, xml, data_obj, data_str)
File "C:\ProgramData\EventGhost\plugins\WeatherUnderground\wu\__init__.py", line 411, in __call__
return update()
File "C:\ProgramData\EventGhost\plugins\WeatherUnderground\wu\__init__.py", line 379, in update
except ET.ParseError:
AttributeError: 'module' object has no attribute 'ParseError'
Code: Select all
METRIC IMPERIAL
c f
m i
km mi
mb in
cm in
mm in
mb inches
kph mph
metric english
metric in
celsius fahrenheit