Skip to content

Commit

Permalink
Fix weather sentences without a name (#1690)
Browse files Browse the repository at this point in the history
  • Loading branch information
synesthesiam authored Nov 29, 2023
1 parent df071d9 commit 6d54282
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
6 changes: 4 additions & 2 deletions sentences/en/weather_HassGetWeather.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@ intents:
HassGetWeather:
data:
- sentences:
- "<what_is>[ the] weather[ like][( for| in| at) <name>]"
- "<what_is>[ the] weather[( for| in| at) <name>] like"
- "<what_is>[ the] weather[ like]"
- sentences:
- "<what_is>[ the] weather[ like] (for|in|at) <name>"
- "<what_is>[ the] weather (for|in|at) <name>[ like]"
- "<what_is>[ the] <name> weather[ like]"
requires_context:
domain: weather
3 changes: 3 additions & 0 deletions shared/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ def get_matched_states(
if result.intent.name in ("HassClimateGetTemperature", "HassClimateSetTemperature"):
# Match climate entities only
states = [state for state in states if state.domain == "climate"]
elif result.intent.name in ("HassGetWeather",):
# Match weather entities only
states = [state for state in states if state.domain == "weather"]

# Implement some matching logic from Home Assistant
entity_name: Optional[str] = None
Expand Down
7 changes: 7 additions & 0 deletions tests/en/weather_HassGetWeather.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
language: en
tests:
- sentences:
- "what's the weather?"
- "what is the weather like"
intent:
name: HassGetWeather
response: 47 °F and raining

- sentences:
- "what's the weather like in london?"
- "what is the weather in London like"
Expand Down

0 comments on commit 6d54282

Please sign in to comment.