Skip to content

Commit

Permalink
Adafruit_IO_Power_Relay: update to settings.toml
Browse files Browse the repository at this point in the history
  • Loading branch information
dhalbert authored Apr 9, 2024
1 parent cf6ffd5 commit 7f94997
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions Adafruit_IO_Power_Relay/code.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#
# SPDX-License-Identifier: MIT

import os
import time
import board
import busio
Expand All @@ -15,12 +16,10 @@

### WiFi ###

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

# If you are using a board with pre-defined ESP32 Pins:
esp32_cs = DigitalInOut(board.ESP_CS)
Expand Down Expand Up @@ -55,7 +54,7 @@

### 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 = os.getenv("AIO_USERNAME") + "/feeds/relay"

### Code ###

Expand Down Expand Up @@ -107,8 +106,8 @@ def on_relay_msg(client, topic, value):
# Set up a MiniMQTT Client
client = MQTT.MQTT(
broker="io.adafruit.com",
username=secrets["aio_username"],
password=secrets["aio_key"],
username=os.getenv("AIO_USERNAME"),
password=os.getenv("AIO_KEY"),
socket_pool=pool,
ssl_context=ssl_context,
)
Expand Down

0 comments on commit 7f94997

Please sign in to comment.