'Calculate distance.
Will calculate distance from home to a point or between points.
Points can be passed in using state objects or lat/lng coordinates.'

def distance(self, *args):

    locations = []
    to_process = list(args)
    while to_process:
        value = to_process.pop(0)
        if isinstance(value, State):
            latitude = value.attributes.get(ATTR_LATITUDE)
            longitude = value.attributes.get(ATTR_LONGITUDE)
            if ((latitude is None) or (longitude is None)):
                _LOGGER.warning('Distance:State    does    not    contains    a    location:    %s', value)
                return None
        else:
            if (not to_process):
                _LOGGER.warning('Distance:Expected    latitude    and    longitude,    got    %s', value)
                return None
            value_2 = to_process.pop(0)
            latitude = convert(value, float)
            longitude = convert(value_2, float)
            if ((latitude is None) or (longitude is None)):
                _LOGGER.warning('Distance:Unable    to    process    latitude    and    longitude:    %s,    %s', value, value_2)
                return None
        locations.append((latitude, longitude))
    if (len(locations) == 1):
        return self._hass.config.distance(*locations[0])
    return self._hass.config.units.length(loc_util.distance(*(locations[0] + locations[1])), 'm')
