-
Notifications
You must be signed in to change notification settings - Fork 0
/
hues-control.py
38 lines (31 loc) · 1.16 KB
/
hues-control.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import json
import requests
import time
# Caution: store your base_url in a PRIVATE location for security.
class Hue:
def __init__(self):
self.setting = ["dim", "bright"]
# Change location of philips hues endpoint uri here
with open('C:\\Users\\charm\\OneDrive\\Desktop\\Christmas Turkey') as f:
self.base_url = f.read().strip()
def getInstructions(self):
print("Welcome to MSoup's Philips Hues App")
print("-----------------------------------")
print("Commands:")
print("Left / Right arrow: switch between light settings")
print("Q / quit / exit: Exit script")
print("Help: get instructions again")
print("-----------------------------------")
print("By default, your lights will turn on. ")
def turnOn(self):
response = requests.put(self.base_url + 'lights/1/state', json.dumps({'on': True}))
print(response.content)
def turnOff(self):
response = requests.put(self.base_url + 'lights/1/state', json.dumps({'on': False}))
print(response.content)
def run(self):
self.getInstructions()
self.turnOn()
if __name__ == "__main__":
hue = Hue()
hue.run()