Skip to content

Commit

Permalink
fix default for weather
Browse files Browse the repository at this point in the history
  • Loading branch information
bdamokos committed Jan 14, 2025
1 parent 6c62a20 commit 52bec91
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions weather/providers/factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,19 @@ def create_weather_provider(
ValueError: If provider_name is invalid or coordinates are missing
"""
# Use environment variables if coordinates not provided - default to Brussels
lat = lat or os.getenv('Coordinates_LAT', 50.8503)
lon = lon or os.getenv('Coordinates_LNG', 4.3517)
lat = lat or os.getenv('Coordinates_LAT', '50.8503')
lon = lon or os.getenv('Coordinates_LNG', '4.3517')
unit = unit or os.getenv('weather_unit', 'celsius').lower()

logger.debug(f"Coordinates: lat={lat} ({type(lat)}), lon={lon} ({type(lon)})")

# Convert coordinates to float
try:
lat = float(lat)
lon = float(lon)
except (TypeError, ValueError):
raise ValueError("Invalid coordinates format. Must be numeric values.")

# Convert unit string to enum
try:
unit_enum = TemperatureUnit(unit)
Expand Down

0 comments on commit 52bec91

Please sign in to comment.