Skip to content

Commit

Permalink
added location data to the forecast screen
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisveilleux committed May 12, 2021
1 parent cdac179 commit 05134fb
Showing 1 changed file with 16 additions and 9 deletions.
25 changes: 16 additions & 9 deletions __init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -540,7 +540,9 @@ def handle_sunset(self, message: Message):
self._display_sunrise_sunset_mark_ii(intent_weather, weather_location)
self._speak_weather(dialog)

def _display_sunrise_sunset_mark_ii(self, forecast: DailyWeather, weather_location: str):
def _display_sunrise_sunset_mark_ii(
self, forecast: DailyWeather, weather_location: str
):
"""Display the sunrise and sunset.
:param forecast: daily forecasts to display
Expand Down Expand Up @@ -596,7 +598,7 @@ def _report_current_weather(self, message: Message):
self._display_hourly_forecast(weather, weather_location)
else:
four_day_forecast = weather.daily[1:5]
self._display_multi_day_forecast(four_day_forecast)
self._display_multi_day_forecast(four_day_forecast, intent_data)

def _display_current_conditions(
self, weather: WeatherReport, weather_location: str
Expand Down Expand Up @@ -650,7 +652,7 @@ def _build_display_location(self, intent_data: WeatherIntent) -> str:
return ", ".join(location)

def _display_more_current_conditions(
self, weather: WeatherReport, weather_location: str
self, weather: WeatherReport, weather_location: str
):
"""Display current weather conditions on a device that supports a GUI.
Expand Down Expand Up @@ -767,7 +769,7 @@ def _report_multi_day_forecast(self, message: Message, days: int):
self.speak_dialog("seven.days.available")
forecast = weather.get_forecast_for_multiple_days(7)
dialogs = self._build_forecast_dialogs(forecast, intent_data)
self._display_multi_day_forecast(forecast)
self._display_multi_day_forecast(forecast, intent_data)
for dialog in dialogs:
self._speak_weather(dialog)

Expand All @@ -781,7 +783,7 @@ def _report_weekend_forecast(self, message: Message):
if weather is not None:
forecast = weather.get_weekend_forecast()
dialogs = self._build_forecast_dialogs(forecast, intent_data)
self._display_multi_day_forecast(forecast)
self._display_multi_day_forecast(forecast, intent_data)
for dialog in dialogs:
self._speak_weather(dialog)

Expand Down Expand Up @@ -817,7 +819,7 @@ def _report_week_summary(self, message: Message):
forecast = weather.get_forecast_for_multiple_days(7)
dialogs = self._build_weekly_condition_dialogs(forecast, intent_data)
dialogs.append(self._build_weekly_temperature_dialog(forecast, intent_data))
self._display_multi_day_forecast(forecast)
self._display_multi_day_forecast(forecast, intent_data)
for dialog in dialogs:
self._speak_weather(dialog)

Expand Down Expand Up @@ -857,17 +859,21 @@ def _build_weekly_temperature_dialog(

return dialog

def _display_multi_day_forecast(self, forecast: List[DailyWeather]):
def _display_multi_day_forecast(
self, forecast: List[DailyWeather], intent_data: WeatherIntent
):
"""Display daily forecast data on devices that support the GUI.
:param forecast: daily forecasts to display
"""
if self.platform == MARK_II:
self._display_multi_day_mark_ii(forecast)
self._display_multi_day_mark_ii(forecast, intent_data)
else:
self._display_multi_day_scalable(forecast)

def _display_multi_day_mark_ii(self, forecast: List[DailyWeather]):
def _display_multi_day_mark_ii(
self, forecast: List[DailyWeather], intent_data: WeatherIntent
):
"""Display daily forecast data on a Mark II.
The Mark II supports displaying four days of a forecast at a time.
Expand All @@ -887,6 +893,7 @@ def _display_multi_day_mark_ii(self, forecast: List[DailyWeather]):
)
self.gui.clear()
self.gui["dailyForecast"] = dict(days=daily_forecast[:4])
self.gui["weatherLocation"] = self._build_display_location(intent_data)
self.gui.show_page(page_name)
if len(forecast) > 4:
sleep(15)
Expand Down

0 comments on commit 05134fb

Please sign in to comment.