diff --git a/examples/lifx_simpletest.py b/examples/lifx_simpletest.py index 4766c3d..f538567 100644 --- a/examples/lifx_simpletest.py +++ b/examples/lifx_simpletest.py @@ -11,9 +11,11 @@ import adafruit_lifx -# Get WiFi details, ensure these are setup in settings.toml +# Get WiFi details and LIFX keys, ensure these are setup in settings.toml +# (to obtain a token, visit: https://cloud.lifx.com/settings) ssid = getenv("CIRCUITPY_WIFI_SSID") password = getenv("CIRCUITPY_WIFI_PASSWORD") +lifx_token = getenv("lifx_token") # ESP32 SPI esp32_cs = DigitalInOut(board.ESP_CS) @@ -24,10 +26,6 @@ status_pixel = neopixel.NeoPixel(board.NEOPIXEL, 1, brightness=0.2) wifi = WiFiManager(esp, ssid, password, status_pixel=status_pixel) -# Add your LIFX Personal Access token to secrets.py -# (to obtain a token, visit: https://cloud.lifx.com/settings) -lifx_token = getenv("lifx_token") - if lifx_token is None: raise KeyError("Please add your lifx token to settings.toml") diff --git a/examples/lifx_simpletest_esp32s2.py b/examples/lifx_simpletest_esp32s2.py index 8517165..e125ff3 100644 --- a/examples/lifx_simpletest_esp32s2.py +++ b/examples/lifx_simpletest_esp32s2.py @@ -1,6 +1,7 @@ # SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries # SPDX-License-Identifier: MIT +from os import getenv import ssl import wifi import socketpool @@ -8,22 +9,17 @@ import adafruit_lifx -# Get wifi details and more from a secrets.py file -try: - from secrets import secrets -except ImportError: - print("WiFi and API secrets are kept in secrets.py, please add them there!") - raise +# Get WiFi details and LIFX keys, ensure these are setup in settings.toml +# (to obtain a token, visit: https://cloud.lifx.com/settings) +ssid = getenv("CIRCUITPY_WIFI_SSID") +password = getenv("CIRCUITPY_WIFI_PASSWORD") +lifx_token = getenv("lifx_token") # Set up ESP32-S2 and adafruit_requests session -wifi.radio.connect(ssid=secrets["ssid"], password=secrets["password"]) +wifi.radio.connect(ssid=ssid, password=password) pool = socketpool.SocketPool(wifi.radio) http_session = adafruit_requests.Session(pool, ssl.create_default_context()) -# Add your LIFX Personal Access token to secrets.py -# (to obtain a token, visit: https://cloud.lifx.com/settings) -lifx_token = secrets["lifx_token"] - # Set this to your LIFX light separator label # https://api.developer.lifx.com/docs/selectors lifx_light = "label:Lamp"