Skip to content
5 changes: 4 additions & 1 deletion netbox_device_map/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@


def get_device_location(device: Device) -> LatLon | None:
"""Extract device geolocation from special custom field"""
"""If netbox longitude and latitude fields are populated for a device then use them."""
if device.longitude and device.latitude:
return (device.longitude, device.latitude)
"""... Otherwise extract device geolocation from special custom field"""
if location_cf := device.custom_field_data.get(LOCATION_CF_NAME):
return tuple(map(float, location_cf.replace(' ', '').split(',', maxsplit=1)))

Expand Down