‼️UPDATE LOCATION🗺️

this is a fail safe change to fuzzing the default location. This may change the way you use the bot today and should evaluate the change specifically test the auto alerts for proper data for emergency alerts etc.`fuzzConfigLocation = True`
This commit is contained in:
SpudGunMan
2025-10-13 09:49:10 -07:00
parent b07a7fb0cc
commit 11687cb7ba
4 changed files with 38 additions and 29 deletions
+2
View File
@@ -171,6 +171,8 @@ bbsAPI_enabled = False
enabled = True
lat = 48.50
lon = -123.0
fuzzConfigLocation = True
fuzzItAll = False
# Default to metric units rather than imperial
useMetric = False
+3 -3
View File
@@ -338,9 +338,9 @@ def abbreviate_noaa(row):
line = row
for key, value in replacements.items():
# case insensitive replace
line = line.replace(key, value).replace(key.capitalize(), value).replace(key.upper(), value)
for variant in (key, key.capitalize(), key.upper()):
if variant != value:
line = line.replace(variant, value)
return line
def getWeatherAlertsNOAA(lat=0, lon=0, useDefaultLatLon=False):
+2
View File
@@ -273,6 +273,8 @@ try:
location_enabled = config['location'].getboolean('enabled', True)
latitudeValue = config['location'].getfloat('lat', 48.50)
longitudeValue = config['location'].getfloat('lon', -123.0)
fuzz_config_location = config['location'].getboolean('fuzzConfigLocation', True) # default True
fuzzItAll = config['location'].getboolean('fuzzAllLocations', False) # default False, only fuzz config location
use_meteo_wxApi = config['location'].getboolean('UseMeteoWxAPI', False) # default False use NOAA
use_metric = config['location'].getboolean('useMetric', False) # default Imperial units
repeater_lookup = config['location'].get('repeaterLookup', 'rbook') # default repeater lookup source
+31 -26
View File
@@ -518,39 +518,44 @@ def get_node_list(nodeInt=1):
return node_list
def get_node_location(nodeID, nodeInt=1, channel=0):
def get_node_location(nodeID, nodeInt=1, channel=0, round_digits=2):
"""
Returns [latitude, longitude] for a node.
- Always returns a fuzzed (rounded) config location as fallback.
- returns their actual position if available, else fuzzed config location.
"""
interface = globals()[f'interface{nodeInt}']
# Get the location of a node by its number from nodeDB on device
# if no location data, return default location
latitude = latitudeValue
longitude = longitudeValue
position = [latitudeValue,longitudeValue]
fuzzed_position = [round(latitudeValue, round_digits), round(longitudeValue, round_digits)]
# Try to find an exact location for the requested node
if interface.nodes:
for node in interface.nodes.values():
if nodeID == node['num']:
if 'position' in node and node['position'] is not {}:
pos = node.get('position')
if (
pos and isinstance(pos, dict)
and pos.get('latitude') is not None
and pos.get('longitude') is not None
):
try:
latitude = node['position']['latitude']
longitude = node['position']['longitude']
logger.debug(f"System: location data for {nodeID} is {latitude},{longitude}")
position = [latitude,longitude]
# Got a valid position
latitude = pos['latitude']
longitude = pos['longitude']
if fuzzItAll:
latitude = round(latitude, round_digits)
longitude = round(longitude, round_digits)
logger.debug(f"System: Fuzzed location data for {nodeID}")
return [latitude, longitude]
except Exception as e:
logger.debug(f"System: No location data for {nodeID} use default location")
return position
else:
logger.debug(f"System: No location data for {nodeID} using default location")
# request location data
# try:
# logger.debug(f"System: Requesting location data for {number}")
# interface.sendPosition(destinationId=number, wantResponse=False, channelIndex=channel)
# except Exception as e:
# logger.error(f"System: Error requesting location data for {number}. Error: {e}")
return position
else:
logger.warning(f"System: Location for NodeID {nodeID} not found in nodeDb")
return position
logger.warning(f"System: Error processing position for node {nodeID}: {e}")
if fuzz_config_location:
# Return fuzzed config location if no valid position found
return fuzzed_position
else:
return [latitudeValue, longitudeValue]
def get_closest_nodes(nodeInt=1,returnCount=3):
interface = globals()[f'interface{nodeInt}']
node_list = []