def distance(hass, *args):
    'Calculate distance.\n\n    Will calculate distance from home to a point or between points.\n    Points can be passed in using state objects or lat/lng coordinates.\n    '
    locations = []
    to_process = list(args)
    while to_process:
        value = to_process.pop(0)
        if (isinstance(value, str) and (not valid_entity_id(value))):
            point_state = None
        else:
            point_state = _resolve_state(hass, value)
        if (point_state is None):
            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
        else:
            if (not loc_helper.has_location(point_state)):
                _LOGGER.warning('Distance:State does not contain valid location: %s', point_state)
                return None
            latitude = point_state.attributes.get(ATTR_LATITUDE)
            longitude = point_state.attributes.get(ATTR_LONGITUDE)
        locations.append((latitude, longitude))
    if (len(locations) == 1):
        return hass.config.distance(*locations[0])
    return hass.config.units.length(loc_util.distance(*(locations[0] + locations[1])), LENGTH_METERS)
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(hass, *args):
    'Calculate distance.\n\n    Will calculate distance from home to a point or between points.\n    Points can be passed in using state objects or lat/lng coordinates.\n    '
    locations = []
    to_process = list(args)
    while to_process:
        value = to_process.pop(0)
        if (isinstance(value, str) and (not valid_entity_id(value))):
            point_state = None
        else:
            point_state = _resolve_state(hass, value)
        if (point_state is None):
            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
        else:
            if (not loc_helper.has_location(point_state)):
                _LOGGER.warning('Distance:State does not contain valid location: %s', point_state)
                return None
            latitude = point_state.attributes.get(ATTR_LATITUDE)
            longitude = point_state.attributes.get(ATTR_LONGITUDE)
        locations.append((latitude, longitude))
    if (len(locations) == 1):
        return hass.config.distance(*locations[0])
    return hass.config.units.length(loc_util.distance(*(locations[0] + locations[1])), LENGTH_METERS)