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
Changes from all 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
@@ -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):
@@ -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?
@@ -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.
@@ -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.
@@ -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?
@@ -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?
@@ -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.
@@ -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).
@@ -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")
@@ -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):
@@ -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.
@@ -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")
@@ -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")
@@ -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):
@@ -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")
)
@@ -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):
@@ -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?
@@ -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?
@@ -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?
@@ -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):
10 changes: 5 additions & 5 deletions skill/dialog.py
Original file line number Diff line number Diff line change
@@ -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,
@@ -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:
@@ -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"
self.data = dict(time=nice_time(self.weather.sunset))
self._add_location()

2 changes: 1 addition & 1 deletion skill/intent.py
Original file line number Diff line number Diff line change
@@ -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