35 lines
671 B
Python
35 lines
671 B
Python
from button_handler import ButtonHandler
|
|
import urequests as requests
|
|
from wifi import Wifi
|
|
from led import LED
|
|
|
|
def send_request():
|
|
try:
|
|
print("Action triggered")
|
|
r = requests.post(
|
|
"https://192.168.15.119:5000/command/party/play",
|
|
headers={
|
|
"Authorization": "Bearer 0eed89e8-7625-4f8d-bf2a-0872aede0efb"
|
|
}
|
|
)
|
|
r.close()
|
|
except Exception as ex:
|
|
print("Failed to trigger action", ex)
|
|
|
|
try:
|
|
LED_PIN = 2
|
|
SSID = "Proximus-Home-AA68_EXT"
|
|
PASSWORD = "wcsp565un2bbw"
|
|
|
|
led = LED(LED_PIN)
|
|
led.off()
|
|
|
|
wifi = Wifi(SSID, PASSWORD)
|
|
wifi.connect()
|
|
|
|
led.on()
|
|
|
|
button = ButtonHandler(14, send_request)
|
|
|
|
except Exception as e:
|
|
print("Unable to start", e) |