@@ -231,9 +231,16 @@ def handle_next_precipitation(self, message):
231
231
today = extract_datetime (" " )[0 ] # this is None
232
232
when = extract_datetime (message .data .get ('utterance' ))[0 ]
233
233
if today == when :
234
- forecasting = 'today'
234
+ timeframe = 'today'
235
235
else :
236
- forecasting = 'expected'
236
+ timeframe = 'expected'
237
+
238
+ data = {
239
+ "modifier" : "" ,
240
+ "precip" : "none" ,
241
+ "day" : self .__to_day (when ),
242
+ "location" : report ['location' ]
243
+ }
237
244
238
245
# search the forecast for precipitation
239
246
for weather in self .owm .daily_forecast (
@@ -242,8 +249,8 @@ def handle_next_precipitation(self, message):
242
249
report ['lon' ]).get_forecast ().get_weathers ():
243
250
244
251
forecastDate = datetime .fromtimestamp (weather .get_reference_time ())
245
-
246
- # TODO: "will it rain tomorrow" returns forecast for today, if it rains today
252
+
253
+ # TODO: "will it rain tomorrow" returns forecast for today, if it rains today
247
254
if when != today :
248
255
# User asked about a specific date, is this it?
249
256
whenGMT = self .__to_GMT (when )
@@ -252,35 +259,27 @@ def handle_next_precipitation(self, message):
252
259
253
260
rain = weather .get_rain ()
254
261
if rain and rain ["all" ] > 0 :
255
- data = {
256
- "modifier" : "" ,
257
- "precip" : "rain" ,
258
- "day" : self .__to_day (forecastDate )
259
- }
262
+ data ["precip" ] = "rain"
263
+ data ["day" ] = self .__to_day (forecastDate )
260
264
if rain ["all" ] < 10 :
261
265
data ["modifier" ] = self .__translate ("light" )
262
266
elif rain ["all" ] > 20 :
263
267
data ["modifier" ] = self .__translate ("heavy" )
264
268
265
- self .speak_dialog ("precipitation." + forecasting , data )
266
- return
269
+ break
267
270
268
271
snow = weather .get_snow ()
269
272
if snow and snow ["all" ] > 0 :
270
- data = {
271
- "modifier" : "" ,
272
- "precip" : "snow" ,
273
- "day" : self .__to_day (forecastDate )
274
- }
273
+ data ["precip" ] = "snow"
274
+ data ["day" ] = self .__to_day (forecastDate )
275
275
if snow ["all" ] < 10 :
276
276
data ["modifier" ] = self .__translate ("light" )
277
277
elif snow ["all" ] > 20 :
278
278
data ["modifier" ] = self .__translate ("heavy" )
279
279
280
- self .speak_dialog ("precipitation." + forecasting , data )
281
- return
282
-
283
- self .speak_dialog ("precipitation.not_expected" , report )
280
+ break
281
+
282
+ self .__report_precipitation (timeframe , data )
284
283
285
284
# Handle: What's the weather later?
286
285
@intent_handler (IntentBuilder ("NextHoursWeatherIntent" ).require (
@@ -492,6 +491,21 @@ def __initialize_report(self, message):
492
491
'full_location' : location ,
493
492
'scale' : self .__get_temperature_unit ()
494
493
}
494
+
495
+ def __report_precipitation (self , timeframe , data ):
496
+ if data ['precip' ] == "none" :
497
+ expected = ".not_expected"
498
+ elif timeframe == "today" :
499
+ expected = ".today"
500
+ else :
501
+ expected = ".expected"
502
+
503
+ if data ['location' ] == self .location_pretty :
504
+ local = ".local"
505
+ else :
506
+ local = ""
507
+
508
+ self .speak_dialog ("precipitation" + expected + local , data )
495
509
496
510
def __report_weather (self , timeframe , report ):
497
511
# Tell the weather to the user (verbal and visual)
0 commit comments