Skip to content

Instantly share code, notes, and snippets.

@vwillcox
Last active October 23, 2018 18:17
Show Gist options
  • Save vwillcox/e2ab3e89914dc74ed917a486ccdc80a3 to your computer and use it in GitHub Desktop.
Save vwillcox/e2ab3e89914dc74ed917a486ccdc80a3 to your computer and use it in GitHub Desktop.
#!/usr/bin/python3
import sys, getopt
import tikteck
def connecttoBulb(b):
bulb = tikteck.tikteck(b, "Smart Light", "[PASSWORD]")
bulb.connect()
return bulb
def main(argv):
cmd = ''
value = ''
zone = ''
try:
opts, args = getopt.getopt(argv, "hc:v:z:r:g:b:", ["cmd=", "value=", "zone=", "red=", "green=", "blue="])
except getopt.GetoptError:
print("Usage: python veho.py -c <command> -v <value> -z <zone>")
sys.exit(2)
for opt, arg in opts:
if opt == '-h':
print("Usage: python veho.py -c <command> -v <value> -z <zone>")
sys.exit()
elif opt in ("-c", "--cmd"):
cmd = arg
elif opt in ("-v", "--value"):
value = arg
elif opt in ("-z", "--zone"):
try:
zone = int(arg)
except ValueError:
sys.exit(2)
elif opt in ("-r", "--red"):
red = arg
elif opt in ("-g", "--green"):
green = arg
elif opt in ("-b", "--blue"):
blue = arg
if zone == 1:
bulb = connecttoBulb("[MAC1]")
elif zone == 2:
bulb = connecttoBulb("[MAC2]")
elif zone == 3:
bulb = connecttoBulb("[MAC3]")
elif zone == 4:
bulb = connecttoBulb("[MAC4]")
if cmd == 'on' and value == "white":
bulb.set_state(0xff, 0xff, 0xff, 0xff)
elif cmd == 'off':
bulb.set_state(0x0, 0x0, 0x0, 0x0)
elif cmd == 'dim':
value = int(value)
bulb.set_state(255,255,255,value)
elif cmd == 'colour':
bulb.set_state(int(red), int(green), int(blue), 255)
if __name__ == "__main__":
main(sys.argv[1:])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment