Reorganize API keys under [External_Data] section

- Move n2yo_api_key and airnow_api_key from [Solar_Config] to [External_Data]
- Update code references to use [External_Data] section instead of [Solar_Config]
- Update config.ini.example to match the new organization
- Improve error message to specify the correct config section
- This provides better organization with all external API keys in one place
This commit is contained in:
agessaman
2025-09-06 11:37:45 -07:00
parent 9b74a39872
commit de92fdfdd2
3 changed files with 11 additions and 11 deletions

View File

@@ -152,6 +152,14 @@ tide_api_key =
# Tide update interval in seconds (future feature)
tide_update_interval = 1800
# N2YO API key for satellite pass information
# Get free key at: https://www.n2yo.com/login/
n2yo_api_key =
# AirNow API key for AQI data
# Get free key at: https://docs.airnowapi.org/
airnow_api_key =
[Weather]
# Default state for city name disambiguation
# When users type "wx seattle", it will search for "seattle, WA, USA"
@@ -174,11 +182,3 @@ url_timeout = 10
# true: Use 24-hour UTC format
# false: Use 12-hour local format
use_zulu_time = false
# N2YO API key for satellite pass information
# Get free key at: https://www.n2yo.com/login/
n2yo_api_key =
# AirNow API key for AQI data
# Get free key at: https://www.airnowapi.org/
airnow_api_key =

View File

@@ -37,7 +37,7 @@ class AqiCommand(BaseCommand):
self.default_state = self.bot.config.get('Weather', 'default_state', fallback='WA')
# Get AirNow API key from config
self.api_key = self.bot.config.get('Solar_Config', 'airnow_api_key', fallback='')
self.api_key = self.bot.config.get('External_Data', 'airnow_api_key', fallback='')
if not self.api_key:
self.logger.warning("AirNow API key not configured in config.ini")
@@ -283,7 +283,7 @@ class AqiCommand(BaseCommand):
"""Get AQI data for a location (zipcode, city, or coordinates)"""
try:
if not self.api_key:
return "AirNow API key not configured. Please add airnow_api_key to config.ini"
return "AirNow API key not configured. Please add airnow_api_key to [External_Data] section in config.ini"
# Convert location to lat/lon
if location_type == "zipcode":

View File

@@ -353,7 +353,7 @@ def get_next_satellite_pass(satellite, lat=None, lon=None):
lon = get_config_value('Solar_Config', 'default_longitude', DEFAULT_LONGITUDE)
# API URL
n2yo_key = get_config_value('Solar_Config', 'n2yo_api_key', DEFAULT_N2YO_API_KEY)
n2yo_key = get_config_value('External_Data', 'n2yo_api_key', DEFAULT_N2YO_API_KEY)
if not n2yo_key:
logger.error("System: Missing API key free at https://www.n2yo.com/login/")
return "not configured, bug your sysop"