Skip to content

Commit 4b03672

Browse files
authored
Merge pull request #8 from justmobilize/fix-invalid-secret-lookup
Fix invalid secret lookup
2 parents 6658818 + e9437fa commit 4b03672

File tree

2 files changed

+7
-8
lines changed

2 files changed

+7
-8
lines changed

adafruit_qualia/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ class Qualia(PortalBase):
6262
:param scale: Default scale is 1, but can be an integer of 1 or greater
6363
:param debug: Turn on debug print outs. Defaults to False.
6464
:param use_network: Enable network initialization. Defaults to True.
65-
Setting to False will allow you to use the library without a secrets.py
65+
Setting to False will allow you to use the library without a settings.toml
6666
file with wifi configuration in it.
6767
6868
"""

adafruit_qualia/network.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -69,13 +69,12 @@ def __init__(
6969

7070
def init_io_mqtt(self) -> IO_MQTT:
7171
"""Initialize MQTT for Adafruit IO"""
72-
try:
73-
aio_username = self._secrets["aio_username"]
74-
aio_key = self._secrets["aio_key"]
75-
except KeyError:
76-
raise KeyError(
77-
"Adafruit IO secrets are kept in secrets.py, please add them there!\n\n"
78-
) from KeyError
72+
aio_username = self._get_setting["ADAFRUIT_AIO_USERNAME"]
73+
aio_key = self._get_setting["ADAFRUIT_AIO_KEY"]
74+
if None in [aio_username, aio_key]:
75+
raise AttributeError(
76+
"Adafruit IO keys are kept in settings.toml, please add them there."
77+
)
7978

8079
return self.init_mqtt(IO_MQTT_BROKER, 8883, aio_username, aio_key, True)
8180

0 commit comments

Comments
 (0)