'Get the latest data and updates the states.'

@asyncio.coroutine
def async_update(self):

    if (not self.is_binary):
        try:
            self.mean = round(statistics.mean(self.states), 2)
            self.median = round(statistics.median(self.states), 2)
            self.stdev = round(statistics.stdev(self.states), 2)
            self.variance = round(statistics.variance(self.states), 2)
        except statistics.StatisticsError as err:
            _LOGGER.error(err)
            self.mean = self.median = STATE_UNKNOWN
            self.stdev = self.variance = STATE_UNKNOWN
        if self.states:
            self.total = round(sum(self.states), 2)
            self.min = min(self.states)
            self.max = max(self.states)
            self.change = (self.states[(-1)] - self.states[0])
            self.average_change = self.change
            if (len(self.states) > 1):
                self.average_change /= (len(self.states) - 1)
        else:
            self.min = self.max = self.total = STATE_UNKNOWN
            self.average_change = self.change = STATE_UNKNOWN
