Rudd-O / homeassistant-meteoswiss

:sun_behind_rain_cloud: :switzerland: Meteo Swiss Integration for Home Assistant (forked from websylv)
74 stars 8 forks source link

Todays forecast? #10

Closed theskyisthelimit closed 8 months ago

theskyisthelimit commented 1 year ago

Hello, I just discovered this amazing integration. Thank you!

I was wondering if there's a way to also see today's forecast. From what I can tell, the card only displays tomorrow's forecast. Am I missing something?"

Forecast

badewanne1234 commented 1 year ago

+1 for this, on the website of Meteo Swiss, the current day is also forecasted, so it should be possible I guess. Looking for this for ages :)

Edit: It has been done on the websylv fork, but its missing approval: https://github.com/websylv/homeassistant-meteoswiss/pull/82

Benson17 commented 1 year ago

would be nice to have this, at the moment i only see current temperature but don't see min/max for today...

EDIT: just made changes as in the above mentioned commit and i can confirm my forecast for today is back!

FlohEinstein commented 1 year ago

Disregard previous version of this comment, I realized that this is not an issue for the homeassistant integration but first needs to be addressed in the underlying python libary https://github.com/Rudd-O/hamsclientfork Anyone else would like a much more detailed prognosis: we meet over there and remove &graph=false from the API :-)

razowski commented 1 year ago

Workaround to get today forecast... ;-) I've modified the code to consider the day_0 forecast...

Replace "def forecast(self)..." function in the "/config/custom_components/meteoswiss/weather.py" by this one and reboot HA :

def forecast(self):
    currentDate = datetime.datetime.now()
    one_day = datetime.timedelta(days=1)
    fcdata_out = []
    # Skip the first element - it's the forecast for the current day
    for forecast in self._forecastData["regionForecast"][0:]:
        # calculating date of the forecast
        #currentDate = currentDate + one_day
        data_out = {}
        data_out[ATTR_FORECAST_TIME] = currentDate.strftime("%Y-%m-%d")
        data_out[ATTR_FORECAST_NATIVE_TEMP_LOW] = float(
            forecast["temperatureMin"],
        )
        data_out[ATTR_FORECAST_NATIVE_TEMP] = float(
            forecast["temperatureMax"],
        )
        data_out[ATTR_FORECAST_CONDITION] = next(
            (
                k
                for k, v in CONDITION_CLASSES.items()
                if int(forecast["iconDay"]) in v
            ),
            None,
        )
        fcdata_out.append(data_out)
        currentDate = currentDate + one_day
    return fcdata_out
Rudd-O commented 8 months ago

I fixed this a few weeks ago. Original author was shaving off the first day so you couldn't get today's forecast. I fixed that.