From 52bec9171a1f7b432d9671887d35b81d45b2f101 Mon Sep 17 00:00:00 2001 From: bdamokos <163609735+bdamokos@users.noreply.github.com> Date: Tue, 14 Jan 2025 23:18:45 +0100 Subject: [PATCH] fix default for weather --- weather/providers/factory.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/weather/providers/factory.py b/weather/providers/factory.py index 7855ab0..57ab7e7 100644 --- a/weather/providers/factory.py +++ b/weather/providers/factory.py @@ -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)