Adafruit_IO_Power_Relay: update to settings.toml
This commit is contained in:
parent
cf6ffd5ca0
commit
7f949978a3
1 changed files with 8 additions and 9 deletions
|
|
@ -2,6 +2,7 @@
|
|||
#
|
||||
# SPDX-License-Identifier: MIT
|
||||
|
||||
import os
|
||||
import time
|
||||
import board
|
||||
import busio
|
||||
|
|
@ -15,12 +16,10 @@ import adafruit_minimqtt.adafruit_minimqtt as MQTT
|
|||
|
||||
### 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)
|
||||
|
|
@ -55,7 +54,7 @@ power_pin.switch_to_output()
|
|||
|
||||
### 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 ###
|
||||
|
||||
|
|
@ -107,8 +106,8 @@ ssl_context = adafruit_connection_manager.get_radio_ssl_context(esp)
|
|||
# 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,
|
||||
)
|
||||
|
|
|
|||
Loading…
Reference in a new issue