Re: SunTracker - with moving ghost
Posted: Mon Mar 21, 2016 12:11 pm
GREAT!!! thanks a lot - that fixed it!
Code: Select all
print eg.plugins.Suntracker.GetForecasts()
print eg.plugins.Suntracker.GetCurrentCondition()
#print eg.plugins.Suntracker.GetWeatherCondition()
#print eg.plugins.Suntracker.GetWindData()
#print eg.plugins.Suntracker.GetAtmosphereData()
#print eg.plugins.Suntracker.GetSunStateWithTimeStamp()
#print eg.plugins.Suntracker.GetSunState()
print eg.plugins.Suntracker.plugin.weather_data
Code: Select all
13:52:03 Error in Action: "SunTracker: GetForecasts"
13:52:03 Traceback (most recent call last) (1722):
13:52:03 File "C:\Program Files (x86)\EventGhost\eg\Classes\ActionBase.py", line 170, in CallWrapper
13:52:03 return self(*args)
13:52:03 File "C:\Program Files (x86)\EventGhost\plugins\SunTracker\__init__.py", line 5318, in __call__
13:52:03 return self.plugin.weather_data['forecasts']
13:52:03 TypeError: 'NoneType' object is unsubscriptable
Code: Select all
print eg.plugins.Suntracker.GetWeatherCondition()
print eg.plugins.Suntracker.GetForecasts()
Code: Select all
15:14:21 Light Rain
15:14:21 [{'day_of_week': u'Wednesday', 'high': u'7', 'sunset': u'7:44 PM', 'low': u'3', 'night': {'brief_text': u'Clear Late', 'text': u'Clouds Early / Clearing Late', 'chance_precip': u'20', 'humidity': u'84', 'wind': {'gust': u'N/A', 'direction': u'241', 'speed': u'30', 'text': u'WSW'}, 'icon': u'29'}, 'date': u'Apr 6', 'day': {'brief_text': u'Showers', 'text': u'Showers', 'chance_precip': u'60', 'humidity': u'84', 'wind': {'gust': u'N/A', 'direction': u'241', 'speed': u'30', 'text': u'WSW'}, 'icon': u'11'}, 'sunrise': u'5:59 AM'}, {'day_of_week': u'Thursday', 'high': u'10', 'sunset': u'7:44 PM', 'low': u'3', 'night': {'brief_text': u'Cloudy', 'text': u'Cloudy', 'chance_precip': u'20', 'humidity': u'80', 'wind': {'gust': u'N/A', 'direction': u'191', 'speed': u'22', 'text': u'S'}, 'icon': u'26'}, 'date': u'Apr 7', 'day': {'brief_text': u'Light Rain', 'text': u'Light Rain', 'chance_precip': u'70', 'humidity': u'75', 'wind': {'gust': u'N/A', 'direction': u'191', 'speed': u'22', 'text': u'S'}, 'icon': u'11'}, 'sunrise': u'5:59 AM'}, {'day_of_week': u'Friday', 'high': u'10', 'sunset': u'7:44 PM', 'low': u'2', 'night': {'brief_text': u'P Cloudy', 'text': u'Partly Cloudy', 'chance_precip': u'10', 'humidity': u'79', 'wind': {'gust': u'N/A', 'direction': u'224', 'speed': u'19', 'text': u'SW'}, 'icon': u'29'}, 'date': u'Apr 8', 'day': {'brief_text': u'Cloudy', 'text': u'Cloudy', 'chance_precip': u'20', 'humidity': u'67', 'wind': {'gust': u'N/A', 'direction': u'224', 'speed': u'19', 'text': u'SW'}, 'icon': u'26'}, 'sunrise': u'5:59 AM'}, {'day_of_week': u'Saturday', 'high': u'12', 'sunset': u'7:44 PM', 'low': u'0', 'night': {'brief_text': u'P Cloudy', 'text': u'Partly Cloudy', 'chance_precip': u'0', 'humidity': u'78', 'wind': {'gust': u'N/A', 'direction': u'247', 'speed': u'14', 'text': u'WSW'}, 'icon': u'29'}, 'date': u'Apr 9', 'day': {'brief_text': u'P Cloudy', 'text': u'Partly Cloudy', 'chance_precip': u'10', 'humidity': u'58', 'wind': {'gust': u'N/A', 'direction': u'247', 'speed': u'14', 'text': u'WSW'}, 'icon': u'30'}, 'sunrise': u'5:59 AM'}, {'day_of_week': u'Sunday', 'high': u'12', 'sunset': u'7:44 PM', 'low': u'0', 'night': {'brief_text': u'M Clear', 'text': u'Mostly Clear', 'chance_precip': u'0', 'humidity': u'75', 'wind': {'gust': u'N/A', 'direction': u'72', 'speed': u'9', 'text': u'ENE'}, 'icon': u'33'}, 'date': u'Apr 10', 'day': {'brief_text': u'M Sunny', 'text': u'Mostly Sunny', 'chance_precip': u'0', 'humidity': u'61', 'wind': {'gust': u'N/A', 'direction': u'72', 'speed': u'9', 'text': u'ENE'}, 'icon': u'34'}, 'sunrise': u'5:59 AM'}]
Code: Select all
fc = eg.plugins.Suntracker.GetForecasts()
nc_p = fc[1]['night']['chance_precip']
nf = fc[1]['night']['text']
dc_p = fc[1]['day']['chance_precip']
df = fc[1]['day']['text']
print 'Forecast tomorrow night: ', nf
print 'Forecast tomorrow day: ', df
if nc_p <= 10:
eg.TriggerEvent(
'No rain tomorrow night',
payload = '',
prefix = 'WeatherForecast'
)
if nc_p > 10 and nc_p <= 20:
eg.TriggerEvent(
'Drizzle tomorrow night',
payload = '',
prefix = 'WeatherForecast'
)
if nc_p > 20 and nc_p <= 30:
eg.TriggerEvent(
'??? tomorrow night',
payload = '',
prefix = 'WeatherForecast'
)
if dc_p <= 10:
eg.TriggerEvent(
'No rain tomorrow day',
payload = '',
prefix = 'WeatherForecast'
)
if dc_p > 10 and nc_p <= 20:
eg.TriggerEvent(
'Drizzle tomorrow day',
payload = '',
prefix = 'WeatherForecast'
)
if dc_p > 20 and nc_p <= 30:
eg.TriggerEvent(
'??? tomorrow day',
payload = '',
prefix = 'WeatherForecast'
)
# etc, etc, etc, just add more rules for night & day
Oh wow, thanks for the reply!krambriw wrote:message





Code: Select all
fc = eg.plugins.Suntracker.GetForecasts()
nc_p = int(fc[1]['night']['chance_precip'])
nf = fc[1]['night']['text']
dc_p = int(fc[1]['day']['chance_precip'])
df = fc[1]['day']['text']
print 'Forecast tomorrow night: ', nf
print 'Forecast tomorrow day: ', df
if nc_p <= 10:
eg.TriggerEvent(
'No rain tomorrow night',
payload = '',
prefix = 'WeatherForecast'
)
if nc_p > 10 and nc_p <= 20:
eg.TriggerEvent(
'Drizzle tomorrow night',
payload = '',
prefix = 'WeatherForecast'
)
if nc_p > 20 and nc_p <= 30:
eg.TriggerEvent(
'??? tomorrow night',
payload = '',
prefix = 'WeatherForecast'
)
if dc_p <= 10:
eg.TriggerEvent(
'No rain tomorrow day',
payload = '',
prefix = 'WeatherForecast'
)
if dc_p > 10 and nc_p <= 20:
eg.TriggerEvent(
'Drizzle tomorrow day',
payload = '',
prefix = 'WeatherForecast'
)
if dc_p > 20 and nc_p <= 30:
eg.TriggerEvent(
'??? tomorrow day',
payload = '',
prefix = 'WeatherForecast'
)
# etc, etc, etc, just add more rules for night & day