Improve the dahboard 6

This commit is contained in:
Urtzi Alfaro
2025-08-18 21:14:42 +02:00
parent 954f9a3c3f
commit d6fd53e461
3 changed files with 87 additions and 12 deletions

View File

@@ -51,7 +51,7 @@ async def get_current_weather(
weather = await weather_service.get_current_weather(latitude, longitude)
if not weather:
raise HTTPException(status_code=404, detail="Weather data not available")
raise HTTPException(status_code=503, detail="Weather service temporarily unavailable")
# Publish event
try:
@@ -133,8 +133,10 @@ async def get_weather_forecast(
forecast = await weather_service.get_weather_forecast(request.latitude, request.longitude, request.days)
# Don't return 404 for empty forecast - return empty list with 200 status
if not forecast:
raise HTTPException(status_code=404, detail="Weather forecast not available")
logger.info("Weather forecast unavailable - returning empty list")
return []
# Publish event
try:
@@ -180,11 +182,10 @@ async def get_hourly_weather_forecast(
request.latitude, request.longitude, request.hours
)
# Don't return 404 for empty hourly forecast - return empty list with 200 status
if not hourly_forecast:
raise HTTPException(
status_code=404,
detail="Hourly weather forecast not available. Please check AEMET API configuration."
)
logger.info("Hourly weather forecast unavailable - returning empty list")
return []
# Publish event
try: