'Get the latest data from Dark Sky and updates the states.'

def update(self):

    self.forecast_data.update()
    self.update_unit_of_measurement()
    if (self.type == 'minutely_summary'):
        self.forecast_data.update_minutely()
        minutely = self.forecast_data.data_minutely
        self._state = getattr(minutely, 'summary', '')
        self._icon = getattr(minutely, 'icon', '')
    elif (self.type == 'hourly_summary'):
        self.forecast_data.update_hourly()
        hourly = self.forecast_data.data_hourly
        self._state = getattr(hourly, 'summary', '')
        self._icon = getattr(hourly, 'icon', '')
    elif ((self.forecast_day > 0) or (self.type in ['daily_summary', 'temperature_min', 'temperature_max', 'apparent_temperature_min', 'apparent_temperature_max', 'precip_intensity_max'])):
        self.forecast_data.update_daily()
        daily = self.forecast_data.data_daily
        if (self.type == 'daily_summary'):
            self._state = getattr(daily, 'summary', '')
            self._icon = getattr(daily, 'icon', '')
        elif hasattr(daily, 'data'):
            self._state = self.get_state(daily.data[self.forecast_day])
        else:
            self._state = 0
    else:
        self.forecast_data.update_currently()
        currently = self.forecast_data.data_currently
        self._state = self.get_state(currently)
