Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix condition/.. requests with location information #175

Open
wants to merge 3 commits into
base: 21.02
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 20 additions & 20 deletions __init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def initialize(self):
IntentBuilder("")
.optionally("query")
.one_of("weather", "forecast")
.optionally("location")
.optionally("Location")
.optionally("today")
)
def handle_current_weather(self, message: Message):
Expand All @@ -90,7 +90,7 @@ def handle_current_weather(self, message: Message):
.require("query")
.require("like")
.require("outside")
.optionally("location")
.optionally("Location")
)
def handle_like_outside(self, message: Message):
"""Handle current weather requests such as: what's it like outside?
Expand All @@ -105,7 +105,7 @@ def handle_like_outside(self, message: Message):
.optionally("query")
.one_of("weather", "forecast")
.require("number-days")
.optionally("location")
.optionally("Location")
)
def handle_number_days_forecast(self, message: Message):
"""Handle multiple day forecast without specified location.
Expand All @@ -130,7 +130,7 @@ def handle_number_days_forecast(self, message: Message):
.optionally("query")
.one_of("weather", "forecast")
.require("relative-day")
.optionally("location")
.optionally("Location")
)
def handle_one_day_forecast(self, message):
"""Handle forecast for a single day.
Expand All @@ -149,7 +149,7 @@ def handle_one_day_forecast(self, message):
.require("query")
.require("weather")
.require("later")
.optionally("location")
.optionally("Location")
)
def handle_weather_later(self, message: Message):
"""Handle future weather requests such as: what's the weather later?
Expand All @@ -165,7 +165,7 @@ def handle_weather_later(self, message: Message):
.one_of("weather", "forecast")
.require("relative-time")
.optionally("relative-day")
.optionally("location")
.optionally("Location")
)
def handle_weather_at_time(self, message: Message):
"""Handle future weather requests such as: what's the weather tonight?
Expand All @@ -180,7 +180,7 @@ def handle_weather_at_time(self, message: Message):
.require("query")
.one_of("weather", "forecast")
.require("weekend")
.optionally("location")
.optionally("Location")
)
def handle_weekend_forecast(self, message: Message):
"""Handle requests for the weekend forecast.
Expand All @@ -195,7 +195,7 @@ def handle_weekend_forecast(self, message: Message):
.optionally("query")
.one_of("weather", "forecast")
.require("week")
.optionally("location")
.optionally("Location")
)
def handle_week_weather(self, message: Message):
"""Handle weather for week (i.e. seven days).
Expand All @@ -209,7 +209,7 @@ def handle_week_weather(self, message: Message):
IntentBuilder("")
.optionally("query")
.require("temperature")
.optionally("location")
.optionally("Location")
.optionally("unit")
.optionally("today")
.optionally("now")
Expand All @@ -231,7 +231,7 @@ def handle_current_temperature(self, message: Message):
.optionally("query")
.require("temperature")
.require("relative-day")
.optionally("location")
.optionally("Location")
.optionally("unit")
)
def handle_daily_temperature(self, message: Message):
Expand All @@ -250,7 +250,7 @@ def handle_daily_temperature(self, message: Message):
.require("temperature")
.require("relative-time")
.optionally("relative-day")
.optionally("location")
.optionally("Location")
)
def handle_hourly_temperature(self, message: Message):
"""Handle requests for current temperature at a relative time.
Expand All @@ -269,7 +269,7 @@ def handle_hourly_temperature(self, message: Message):
.optionally("query")
.require("high")
.optionally("temperature")
.optionally("location")
.optionally("Location")
.optionally("unit")
.optionally("relative-day")
.optionally("now")
Expand All @@ -292,7 +292,7 @@ def handle_high_temperature(self, message: Message):
.optionally("query")
.require("low")
.optionally("temperature")
.optionally("location")
.optionally("Location")
.optionally("unit")
.optionally("relative-day")
.optionally("now")
Expand All @@ -314,7 +314,7 @@ def handle_low_temperature(self, message: Message):
IntentBuilder("")
.require("confirm-query-current")
.one_of("hot", "cold")
.optionally("location")
.optionally("Location")
.optionally("today")
)
def handle_is_it_hot(self, message: Message):
Expand All @@ -330,7 +330,7 @@ def handle_is_it_hot(self, message: Message):
.optionally("query")
.one_of("hot", "cold")
.require("confirm-query")
.optionally("location")
.optionally("Location")
.optionally("relative-day")
.optionally("today")
)
Expand All @@ -348,7 +348,7 @@ def handle_how_hot_or_cold(self, message):
IntentBuilder("")
.require("confirm-query")
.require("windy")
.optionally("location")
.optionally("Location")
.optionally("relative-day")
)
def handle_is_it_windy(self, message: Message):
Expand All @@ -365,7 +365,7 @@ def handle_is_it_windy(self, message: Message):
.require("windy")
.optionally("confirm-query")
.optionally("relative-day")
.optionally("location")
.optionally("Location")
)
def handle_windy(self, message):
"""Handler for weather requests such as: how windy is it?
Expand All @@ -379,7 +379,7 @@ def handle_windy(self, message):
IntentBuilder("")
.require("confirm-query")
.require("snow")
.optionally("location")
.optionally("Location")
)
def handle_is_it_snowing(self, message: Message):
"""Handler for weather requests such as: is it snowing today?
Expand All @@ -393,7 +393,7 @@ def handle_is_it_snowing(self, message: Message):
IntentBuilder("")
.require("confirm-query")
.require("clear")
.optionally("location")
.optionally("Location")
)
def handle_is_it_clear(self, message: Message):
"""Handler for weather requests such as: is the sky clear today?
Expand All @@ -407,7 +407,7 @@ def handle_is_it_clear(self, message: Message):
IntentBuilder("")
.require("confirm-query")
.require("clouds")
.optionally("location")
.optionally("Location")
.optionally("relative-time")
)
def handle_is_it_cloudy(self, message: Message):
Expand Down
10 changes: 5 additions & 5 deletions skill/dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
from mycroft.util.time import now_local
from .config import WeatherConfig
from .intent import WeatherIntent
from .util import get_speakable_day_of_week, get_time_period
from .util import get_speakable_day_of_week, get_time_period, get_tz_info
from .weather import (
CURRENT,
CurrentWeather,
Expand Down Expand Up @@ -154,7 +154,7 @@ def build_sunrise_dialog(self):
if self.intent_data.location is None:
now = now_local()
else:
now = now_local(tz=self.intent_data.geolocation["timezone"])
now = now_local(tz=get_tz_info(self.intent_data.geolocation["timezone"]))
if now < self.weather.sunrise:
self.name += "-sunrise-future"
else:
Expand All @@ -167,11 +167,11 @@ def build_sunset_dialog(self):
if self.intent_data.location is None:
now = now_local()
else:
now = now_local(tz=self.intent_data.geolocation["timezone"])
now = now_local(tz=get_tz_info(self.intent_data.geolocation["timezone"]))
if now < self.weather.sunset:
self.name += ".sunset.future"
self.name += "-sunset-future"
else:
self.name = ".sunset.past"
self.name = "-sunset-past"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Found another one. This should be self.name += "-sunset-past"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

self.data = dict(time=nice_time(self.weather.sunset))
self._add_location()

Expand Down
2 changes: 1 addition & 1 deletion skill/intent.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def __init__(self, message, language):
:param language: The configured language of the device
"""
self.utterance = message.data["utterance"]
self.location = message.data.get("location")
self.location = message.data.get("Location")
self.language = language
self.unit = message.data.get("unit")
self.timeframe = CURRENT
Expand Down