Skip to content

Commit cb3f0db

Browse files
authored
Merge pull request #2767 from adafruit/dhalbert-patch-3
PyPortal_LIFX_Controller: get LIFX_TOKEN from settings.toml
2 parents 702166c + 7496891 commit cb3f0db

1 file changed

Lines changed: 8 additions & 8 deletions

File tree

  • PyPortal/PyPortal_LIFX_Controller

PyPortal/PyPortal_LIFX_Controller/code.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
1010
Brent Rubell for Adafruit Industries, 2019
1111
"""
12+
import os
13+
1214
import board
1315
import displayio
1416
from adafruit_bitmap_font import bitmap_font
@@ -24,12 +26,10 @@
2426
# import lifx library
2527
import adafruit_lifx
2628

27-
# Get wifi details and more from a secrets.py file
28-
try:
29-
from secrets import secrets
30-
except ImportError:
31-
print("WiFi secrets are kept in secrets.py, please add them there!")
32-
raise
29+
secrets = {
30+
"ssid" : os.getenv("CIRCUITPY_WIFI_SSID"),
31+
"password" : os.getenv("CIRCUITPY_WIFI_PASSWORD"),
32+
}
3333

3434
# ESP32 SPI
3535
esp32_cs = DigitalInOut(board.ESP_CS)
@@ -47,9 +47,9 @@
4747
calibration=((5200, 59000), (5800, 57000)),
4848
size=(320, 240))
4949

50-
# Set this to your LIFX personal access token in secrets.py
50+
# Set this to your LIFX personal access token in settings.toml
5151
# (to obtain a token, visit: https://cloud.lifx.com/settings)
52-
lifx_token = secrets['lifx_token']
52+
lifx_token = os.getenv("LIFX_TOKEN")
5353

5454
# Initialize the LIFX API Helper
5555
lifx = adafruit_lifx.LIFX(wifi, lifx_token)

0 commit comments

Comments
 (0)