7 Day Weather Forecast

I originally had the problem that it was giving me Unknown for the state but quickly worked out it was the breaking change from min/max to daytime_high/overnight_low

But I can’t work out the days. They just stay as this:
image

I understand it’s probably because of a breaking change associated with dark_sky_friendly_names.py but not sure what exactly

This is the code in the python script

###############################################################################
# Author:      Alok R. Saboo
# Description:  This script takes the dark_sky forecast sensors and updates
#               their friendly_name to include the date and day.
#               https://github.com/arsaboo/homeassistant-config/blob/master/packages/weather.yaml
###############################################################################
dark_sky_entities = ["sensor.forecast_1", "sensor.forecast_2", "sensor.forecast_3",
                     "sensor.forecast_4", "sensor.forecast_5", "sensor.forecast_6",
                     "sensor.forecast_7"]
days = ["Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"]

triggeredEntity = data.get('entity_id')
# logger.warning("trigger is {}".format(triggeredEntity))
now = datetime.datetime.now()
today = now.weekday()

if triggeredEntity is None:
    for entity_id in dark_sky_entities:
        # copy it's state
        state = hass.states.get(entity_id)
        newState = state.state
        forecastdays = int(entity_id.split('_')[1])
        day = datetime.timedelta(days = forecastdays)
        forecastdate = now + day
        newEntityPicture = state.attributes.get('icon')
        if today + forecastdays > 6:
            newDay = days[today + forecastdays - 7]
        else:
            newDay = days[today + forecastdays]
        # Set states
        hass.states.set(entity_id, newState, {
            'friendly_name': "{} ({}/{})".format(newDay, forecastdate.month, forecastdate.day),
            'icon': newEntityPicture,
        })
else:
    state = hass.states.get(triggeredEntity)
    newState = state.state
    forecastdays = int(triggeredEntity.split('_')[1])
    day = datetime.timedelta(days = forecastdays)
    forecastdate = now + day
    newEntityPicture = state.attributes.get('icon')
    if today + forecastdays > 6:
        newDay = days[today + forecastdays - 7]
    else:
        newDay = days[today + forecastdays]
    # Set states
    hass.states.set(triggeredEntity, newState, {
        'friendly_name': "{} ({}/{})".format(newDay, forecastdate.month, forecastdate.day),
        'icon': newEntityPicture,
    })

I just updated to 0.92 this morning and it looks like all my forecasts states are set to unknown and there are messages in the logs for each day that failed.

Card
image

Logs

I can’t find any of the sensor.forecast_N sensors in my entities lists. I wonder if the dark_sky component is in flux at the moment…

I saw a couple of entities had changed. Easiest way is to check the entity names in dev tools and amend lovelace to match.

Same here. I know it wasn’t an entity name change because none of my sensor values aren’t showing the ##/##/## output.

This change happened in 0.91, did you update your entities to accommodate this breaking change?

“Dark Sky provides hourly forecasts for various monitored conditions. This change creates new sensors for each hourly forecasted condition with suffix _<hour>h while adding the suffix _<day>d to the daily forecasted conditions. For example, now a sensor.dark_sky_summary_<day>d and sensor.dark_sky_summary_<hour>h will be created if the forecast and hourly_forecast parameters are populated. (@rtclauss - #21820) (darksky docs)”

Is there actually a way to limit the temperature display to integer numbers?

Yup, that was it. Thanks DetroitEE. I had previously adjusted it for the “overnight_low” and “daytime_high” change but the added ‘d’ was unexpected and overlooked (by me). :stuck_out_tongue: