Home Assistant Unofficial Reference 2024.12.1
homeassistant.util.location Namespace Reference

Classes

class  LocationInfo
 

Functions

dict[str, Any]|None _get_whoami (aiohttp.ClientSession session)
 
LocationInfo|None async_detect_location_info (aiohttp.ClientSession session)
 
float|None distance (float|None lat1, float|None lon1, float lat2, float lon2)
 
float|None vincenty (tuple[float, float] point1, tuple[float, float] point2, bool miles=False)
 

Variables

int AXIS_A = 6378137
 
float AXIS_B = 6356752.314245
 
int CONVERGENCE_THRESHOLD = 1e-12
 
int FLATTENING = 1 / 298.257223563
 
int MAX_ITERATIONS = 200
 
float MILES_PER_KILOMETER = 0.621371
 
string WHOAMI_URL = "https://services.home-assistant.io/whoami/v1"
 
string WHOAMI_URL_DEV = "https://services-dev.home-assistant.workers.dev/whoami/v1"
 

Detailed Description

Module with location helpers.

detect_location_info and elevation are mocked by default during tests.

Function Documentation

◆ _get_whoami()

dict[str, Any] | None homeassistant.util.location._get_whoami ( aiohttp.ClientSession  session)
private
Query whoami.home-assistant.io for location data.

Definition at line 162 of file location.py.

◆ async_detect_location_info()

LocationInfo | None homeassistant.util.location.async_detect_location_info ( aiohttp.ClientSession  session)
Detect location information.

Definition at line 49 of file location.py.

◆ distance()

float | None homeassistant.util.location.distance ( float | None  lat1,
float | None  lon1,
float  lat2,
float   lon2 
)
Calculate the distance in meters between two points.

Async friendly.

Definition at line 62 of file location.py.

◆ vincenty()

float | None homeassistant.util.location.vincenty ( tuple[float, float]  point1,
tuple[float, float]  point2,
bool   miles = False 
)
Vincenty formula (inverse method) to calculate the distance.

Result in kilometers or miles between two points on the surface of a
spheroid.

Async friendly.

Definition at line 80 of file location.py.

Variable Documentation

◆ AXIS_A

int homeassistant.util.location.AXIS_A = 6378137

Definition at line 22 of file location.py.

◆ AXIS_B

float homeassistant.util.location.AXIS_B = 6356752.314245

Definition at line 26 of file location.py.

◆ CONVERGENCE_THRESHOLD

int homeassistant.util.location.CONVERGENCE_THRESHOLD = 1e-12

Definition at line 30 of file location.py.

◆ FLATTENING

int homeassistant.util.location.FLATTENING = 1 / 298.257223563

Definition at line 24 of file location.py.

◆ MAX_ITERATIONS

int homeassistant.util.location.MAX_ITERATIONS = 200

Definition at line 29 of file location.py.

◆ MILES_PER_KILOMETER

float homeassistant.util.location.MILES_PER_KILOMETER = 0.621371

Definition at line 28 of file location.py.

◆ WHOAMI_URL

string homeassistant.util.location.WHOAMI_URL = "https://services.home-assistant.io/whoami/v1"

Definition at line 16 of file location.py.

◆ WHOAMI_URL_DEV

string homeassistant.util.location.WHOAMI_URL_DEV = "https://services-dev.home-assistant.workers.dev/whoami/v1"

Definition at line 17 of file location.py.