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

20 lines
675 B

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