From ed93b821bf3f00dd518a29fc5e2a9d53f05c0046 Mon Sep 17 00:00:00 2001 From: Justin Myers Date: Tue, 25 Feb 2025 06:47:17 -0800 Subject: [PATCH] Fix invalid secret lookup --- adafruit_esp32s2tft/__init__.py | 2 +- adafruit_esp32s2tft/network.py | 13 ++++++------- docs/conf.py | 1 - 3 files changed, 7 insertions(+), 9 deletions(-) diff --git a/adafruit_esp32s2tft/__init__.py b/adafruit_esp32s2tft/__init__.py index 1ab1a73..f527fab 100755 --- a/adafruit_esp32s2tft/__init__.py +++ b/adafruit_esp32s2tft/__init__.py @@ -64,7 +64,7 @@ class ESP32S2TFT(PortalBase): :param scale: Default scale is 1, but can be an integer of 1 or greater :param debug: Turn on debug print outs. Defaults to False. :param use_network: Enable network initialization. Defaults to True. - Setting to False will allow you to use the library without a secrets.py + Setting to False will allow you to use the library without a settings.toml file with wifi configuration in it. """ diff --git a/adafruit_esp32s2tft/network.py b/adafruit_esp32s2tft/network.py index affc57b..ee306c2 100755 --- a/adafruit_esp32s2tft/network.py +++ b/adafruit_esp32s2tft/network.py @@ -73,13 +73,12 @@ def __init__( def init_io_mqtt(self) -> IO_MQTT: """Initialize MQTT for Adafruit IO""" - try: - aio_username = self._secrets["aio_username"] - aio_key = self._secrets["aio_key"] - except KeyError: - raise KeyError( - "Adafruit IO secrets are kept in secrets.py, please add them there!\n\n" - ) from KeyError + aio_username = self._get_setting["ADAFRUIT_AIO_USERNAME"] + aio_key = self._get_setting["ADAFRUIT_AIO_KEY"] + if None in [aio_username, aio_key]: + raise AttributeError( + "Adafruit IO keys are kept in settings.toml, please add them there." + ) return self.init_mqtt(IO_MQTT_BROKER, 8883, aio_username, aio_key, True) diff --git a/docs/conf.py b/docs/conf.py index 75290a4..1d00d77 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -33,7 +33,6 @@ "ssl", "wifi", "socketpool", - "secrets", "bitmaptools", ]