minor things changed
This commit is contained in:
parent
780060e582
commit
3b39003811
|
@ -3,6 +3,7 @@
|
||||||
# Copyright 2019, Mischa Peters <mischa AT high5 DOT nl>, High5!.
|
# Copyright 2019, Mischa Peters <mischa AT high5 DOT nl>, High5!.
|
||||||
# Version 1.0 - 20191030
|
# Version 1.0 - 20191030
|
||||||
#
|
#
|
||||||
|
# Control a light based on sensor information
|
||||||
# Get ['dark'] from sensor ID and switch on/off light ID
|
# Get ['dark'] from sensor ID and switch on/off light ID
|
||||||
# depending where your sensor is located you can use ['daylight']
|
# depending where your sensor is located you can use ['daylight']
|
||||||
#
|
#
|
||||||
|
@ -20,7 +21,7 @@ import ssl
|
||||||
import urllib.request
|
import urllib.request
|
||||||
import json
|
import json
|
||||||
|
|
||||||
parser = argparse.ArgumentParser(description="Turn light on")
|
parser = argparse.ArgumentParser(description="Control light based on light sensor")
|
||||||
parser.add_argument("bridge", type=str, help="Hue Bridge IP")
|
parser.add_argument("bridge", type=str, help="Hue Bridge IP")
|
||||||
parser.add_argument("token", type=str, help="Hue API Token")
|
parser.add_argument("token", type=str, help="Hue API Token")
|
||||||
parser.add_argument("-s", "--sensor", type=int, required=True, help="sensor id#")
|
parser.add_argument("-s", "--sensor", type=int, required=True, help="sensor id#")
|
||||||
|
|
|
@ -19,7 +19,7 @@ import ssl
|
||||||
import urllib.request
|
import urllib.request
|
||||||
import json
|
import json
|
||||||
|
|
||||||
parser = argparse.ArgumentParser(description="Get all sensors from Hue Bridge")
|
parser = argparse.ArgumentParser(description="Get all group ids from Hue Bridge")
|
||||||
parser.add_argument("bridge", type=str, help="Hue Bridge IP")
|
parser.add_argument("bridge", type=str, help="Hue Bridge IP")
|
||||||
parser.add_argument("token", type=str, help="Hue API Token")
|
parser.add_argument("token", type=str, help="Hue API Token")
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,7 @@ import ssl
|
||||||
import urllib.request
|
import urllib.request
|
||||||
import json
|
import json
|
||||||
|
|
||||||
parser = argparse.ArgumentParser(description="Get all sensors from Hue Bridge")
|
parser = argparse.ArgumentParser(description="Get all light ids from Hue Bridge")
|
||||||
parser.add_argument("bridge", type=str, help="Hue Bridge IP")
|
parser.add_argument("bridge", type=str, help="Hue Bridge IP")
|
||||||
parser.add_argument("token", type=str, help="Hue API Token")
|
parser.add_argument("token", type=str, help="Hue API Token")
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,7 @@ import json
|
||||||
import re
|
import re
|
||||||
import collections
|
import collections
|
||||||
|
|
||||||
parser = argparse.ArgumentParser(description="Get all sensors from Hue Bridge")
|
parser = argparse.ArgumentParser(description="Get all sensor ids from Hue Bridge")
|
||||||
parser.add_argument("bridge", type=str, help="Hue Bridge IP")
|
parser.add_argument("bridge", type=str, help="Hue Bridge IP")
|
||||||
parser.add_argument("token", type=str, help="Hue API Token")
|
parser.add_argument("token", type=str, help="Hue API Token")
|
||||||
|
|
||||||
|
|
14
groupctl.py
14
groupctl.py
|
@ -3,10 +3,10 @@
|
||||||
# Copyright 2019, Mischa Peters <mischa AT high5 DOT nl>, High5!.
|
# Copyright 2019, Mischa Peters <mischa AT high5 DOT nl>, High5!.
|
||||||
# Version 1.0 - 20191102
|
# Version 1.0 - 20191102
|
||||||
#
|
#
|
||||||
# Control a light or plug
|
# Control a group of lights (room)
|
||||||
#
|
#
|
||||||
# For example:
|
# For example:
|
||||||
# $ groupctl.py <bridge IP> <token> -i 24 -a on
|
# $ groupctl.py <bridge IP> <token> -g 4 -a on
|
||||||
#
|
#
|
||||||
# Follow the steps at the Hue Developer site to get the username/token
|
# Follow the steps at the Hue Developer site to get the username/token
|
||||||
# https://developers.meethue.com/develop/get-started-2/
|
# https://developers.meethue.com/develop/get-started-2/
|
||||||
|
@ -19,10 +19,10 @@ import ssl
|
||||||
import urllib.request
|
import urllib.request
|
||||||
import json
|
import json
|
||||||
|
|
||||||
parser = argparse.ArgumentParser(description="Control group lights (room)")
|
parser = argparse.ArgumentParser(description="Control group of lights (room)")
|
||||||
parser.add_argument("bridge", type=str, help="Hue Bridge IP")
|
parser.add_argument("bridge", type=str, help="Hue Bridge IP")
|
||||||
parser.add_argument("token", type=str, help="Hue API Token")
|
parser.add_argument("token", type=str, help="Hue API Token")
|
||||||
parser.add_argument("-i", "--id", type=int, required=True, help="light id#")
|
parser.add_argument("-g", "--group", type=int, required=True, help="group id#")
|
||||||
parser.add_argument("-a", "--action", type=str, default='on', help="on|off|relax|bright|dimmed|nightlight")
|
parser.add_argument("-a", "--action", type=str, default='on', help="on|off|relax|bright|dimmed|nightlight")
|
||||||
parser.add_argument("-v", "--verbose", action='store_true', help="verbose")
|
parser.add_argument("-v", "--verbose", action='store_true', help="verbose")
|
||||||
parser.add_argument("-d", "--debug", action='store_true', help="debug")
|
parser.add_argument("-d", "--debug", action='store_true', help="debug")
|
||||||
|
@ -31,7 +31,7 @@ try:
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
bridge = args.bridge
|
bridge = args.bridge
|
||||||
token = args.token
|
token = args.token
|
||||||
group_id = args.id
|
group = args.group
|
||||||
action = args.action
|
action = args.action
|
||||||
verbose = args.verbose
|
verbose = args.verbose
|
||||||
debug = args.debug
|
debug = args.debug
|
||||||
|
@ -92,5 +92,5 @@ def put_state(id, state):
|
||||||
if verbose or debug: print (f"{res.status} {res.reason}")
|
if verbose or debug: print (f"{res.status} {res.reason}")
|
||||||
return(res)
|
return(res)
|
||||||
|
|
||||||
group_state = get_state(group_id)
|
group_state = get_state(group)
|
||||||
put_state(group_id, group_state)
|
put_state(group, group_state)
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
# Control a light or plug
|
# Control a light or plug
|
||||||
#
|
#
|
||||||
# For example:
|
# For example:
|
||||||
# $ lightctl.py <bridge IP> <token> -i 24 -a relax
|
# $ lightctl.py <bridge IP> <token> -l 24 -a relax
|
||||||
#
|
#
|
||||||
# Follow the steps at the Hue Developer site to get the username/token
|
# Follow the steps at the Hue Developer site to get the username/token
|
||||||
# https://developers.meethue.com/develop/get-started-2/
|
# https://developers.meethue.com/develop/get-started-2/
|
||||||
|
|
Loading…
Reference in New Issue