Skip to content

Commit 4dcc5f6

Browse files
authored
Merge pull request #26 from justmobilize/remove-secrets
Remove secrets
2 parents 8a5620c + 8eecc81 commit 4dcc5f6

File tree

2 files changed

+10
-16
lines changed

2 files changed

+10
-16
lines changed

examples/lifx_simpletest.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,11 @@
1111

1212
import adafruit_lifx
1313

14-
# Get WiFi details, ensure these are setup in settings.toml
14+
# Get WiFi details and LIFX keys, ensure these are setup in settings.toml
15+
# (to obtain a token, visit: https://cloud.lifx.com/settings)
1516
ssid = getenv("CIRCUITPY_WIFI_SSID")
1617
password = getenv("CIRCUITPY_WIFI_PASSWORD")
18+
lifx_token = getenv("lifx_token")
1719

1820
# ESP32 SPI
1921
esp32_cs = DigitalInOut(board.ESP_CS)
@@ -24,10 +26,6 @@
2426
status_pixel = neopixel.NeoPixel(board.NEOPIXEL, 1, brightness=0.2)
2527
wifi = WiFiManager(esp, ssid, password, status_pixel=status_pixel)
2628

27-
# Add your LIFX Personal Access token to secrets.py
28-
# (to obtain a token, visit: https://cloud.lifx.com/settings)
29-
lifx_token = getenv("lifx_token")
30-
3129
if lifx_token is None:
3230
raise KeyError("Please add your lifx token to settings.toml")
3331

examples/lifx_simpletest_esp32s2.py

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,25 @@
11
# SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries
22
# SPDX-License-Identifier: MIT
33

4+
from os import getenv
45
import ssl
56
import wifi
67
import socketpool
78
import adafruit_requests
89

910
import adafruit_lifx
1011

11-
# Get wifi details and more from a secrets.py file
12-
try:
13-
from secrets import secrets
14-
except ImportError:
15-
print("WiFi and API secrets are kept in secrets.py, please add them there!")
16-
raise
12+
# Get WiFi details and LIFX keys, ensure these are setup in settings.toml
13+
# (to obtain a token, visit: https://cloud.lifx.com/settings)
14+
ssid = getenv("CIRCUITPY_WIFI_SSID")
15+
password = getenv("CIRCUITPY_WIFI_PASSWORD")
16+
lifx_token = getenv("lifx_token")
1717

1818
# Set up ESP32-S2 and adafruit_requests session
19-
wifi.radio.connect(ssid=secrets["ssid"], password=secrets["password"])
19+
wifi.radio.connect(ssid=ssid, password=password)
2020
pool = socketpool.SocketPool(wifi.radio)
2121
http_session = adafruit_requests.Session(pool, ssl.create_default_context())
2222

23-
# Add your LIFX Personal Access token to secrets.py
24-
# (to obtain a token, visit: https://cloud.lifx.com/settings)
25-
lifx_token = secrets["lifx_token"]
26-
2723
# Set this to your LIFX light separator label
2824
# https://api.developer.lifx.com/docs/selectors
2925
lifx_light = "label:Lamp"

0 commit comments

Comments
 (0)