-
Notifications
You must be signed in to change notification settings - Fork 781
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Secrets Cleanup: A #2989
base: main
Are you sure you want to change the base?
Secrets Cleanup: A #2989
Conversation
# Get WiFi details and Adafruit IO keys, ensure these are setup in settings.toml | ||
# (visit io.adafruit.com if you need to create an account, or if you need your Adafruit IO key.) | ||
ssid = getenv("CIRCUITPY_WIFI_SSID") | ||
password = getenv("CIRCUITPY_WIFI_PASSWORD") | ||
aio_username = getenv("ADAFRUIT_AIO_USERNAME") | ||
aio_key = getenv("ADAFRUIT_AIO_KEY") | ||
|
||
if None in [ssid, password, aio_username, aio_key]: | ||
raise RuntimeError( | ||
"WiFi and Adafruit IO settings are kept in settings.toml, " | ||
"please add them there. The settings file must contain " | ||
"'CIRCUITPY_WIFI_SSID', 'CIRCUITPY_WIFI_PASSWORD', " | ||
"'ADAFRUIT_AIO_USERNAME' and 'ADAFRUIT_AIO_KEY' at a minimum." | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
New standard wifi+aio block
wifi.radio.connect(ssid, password) | ||
print(f"Connected to {ssid}!") | ||
print(f"IP: {wifi.radio.ipv4_address}") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
standard cleanup
# Set your Adafruit IO Username and Key in secrets.py | ||
# (visit io.adafruit.com if you need to create an account, | ||
# or if you need your Adafruit IO key.) | ||
aio_username = secrets["aio_username"] | ||
aio_key = secrets["aio_key"] | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
common to have this after the fact, now up top
from adafruit_lc709203f import LC709203F, PackSize | ||
from adafruit_bme280 import basic as adafruit_bme280 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pylint
# Get WiFi details, ensure these are setup in settings.toml | ||
ssid = getenv("CIRCUITPY_WIFI_SSID") | ||
password = getenv("CIRCUITPY_WIFI_PASSWORD") | ||
|
||
if None in [ssid, password]: | ||
raise RuntimeError( | ||
"WiFi settings are kept in settings.toml, " | ||
"please add them there. The settings file must contain " | ||
"'CIRCUITPY_WIFI_SSID', 'CIRCUITPY_WIFI_PASSWORD', " | ||
"at a minimum." | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
new standard wifi only block
status_pixel = neopixel.NeoPixel(board.NEOPIXEL, 1, brightness=0.2) | ||
wifi = adafruit_esp32spi_wifimanager.WiFiManager(esp, ssid, password, status_pixel=status_pixel) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
standard update to WiFiManager
, status_pixel
is a named arg only, Dan wanted the arg and var to match
@@ -67,10 +76,10 @@ | |||
|
|||
### Feeds ### | |||
# Set up a feed named Relay for subscribing to the relay feed on Adafruit IO | |||
feed_relay = secrets["aio_username"] + "/feeds/relay" | |||
feed_relay = f"{aio_username}/feeds/relay" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
some f-string
cleanup
ssid = os.getenv("CIRCUITPY_WIFI_SSID") | ||
password = os.getenv("CIRCUITPY_WIFI_PASSWORD") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
os
is already imported for other reasons, so left it like that
@FoamyGuy, here is PR number 1. Let's use this to discuss any change you would like to do in the format. I tried to be verbose in the comments on this one for the first time I did something, so it's easy to review the next ones. I added check boxes to each main group, so they could be checked off as updated (let me know if this makes it easy) |
Round of removing secrets from learn guides
secrets.py
secrets.py
secrets.py
secrets.py
from secrets import secrets
secrets.py