CLI tool to control your IoT gadgets.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
roomcomputer/hue_controller.py

21 lines
675 B

import requests as req # Used for HTTP requests for the Hue API
import json # API uses JSON
4 years ago
import config # Configuration for the controller (/config.py <- change this file)
def genUrl(params: str):
4 years ago
return "http://" + config.address + "/api/" + config.username + params
4 years ago
await def API_Request(ReqType: str="GET", params: str=""): # Requests for the API
try:
apiReq = req.Request( ReqType, genUrl(params) )
apiReqPrep = apiReq.prepare()
4 years ago
apiSession = req.Session()
response = apiSession.send(apiReqPrep)
print(response.body)
except req.exceptions.RequestException as err:
raise SystemExit(err) # throw the error