Skip to content

Commit

Permalink
Update milight.py
Browse files Browse the repository at this point in the history
  • Loading branch information
Strontvlieg authored Jan 7, 2017
1 parent 0690069 commit d3592d1
Showing 1 changed file with 43 additions and 41 deletions.
84 changes: 43 additions & 41 deletions milight.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@
import socket;
import sys;


###################
## Configuration ##
###################
IBOX_MODEL = "80 00 00 00 11" # iBox2
IBOX_IP = "192.168.1.18"
UDP_PORT_SEND = 5987
UDP_PORT_RECEIVE = 55054
UDP_MAX_TRY = 3
UDP_MAX_TRY = 5
UDP_TIMEOUT = 5
############################################################################################################

Expand All @@ -21,17 +22,18 @@
"##########################\n"
"## Command line options ##\n"
"##########################\n"
"Use command line as follow : milight.sh CMD1 CMD2\n"
"Use command line as follow : milight.py CMD1 CMD2\n"
" : CMD1 Bulb zone\n"
" : CMD2 Bulb command\n"
"-------------------------------------------------------------------------------------------\n"
"-------------------------------------------------------------------------------\n"
"Select the bulb zone : 00 01 02 03 04\n"
"Bulb on/off : ON OFF NIGHTON WHITEON\n"
"Mode Speed up/down : SPEEDUP SPEEDDOWN\n"
"Kelvin warmwhite : WW00 WW25 WW50 WW75 WW100\n"
"Brightness : DIM00 DIM25 DIM50 DIM75 DIM100\n"
"Saturation : SATUR00 SATUR25 SATUR50 SATUR75 SATUR100\n"
"Mode (discomode) : MODE01 MODE02 MODE03 MODE04 MODE05 MODE06 MODE07 MODE08 MODE09\n"
"Mode Speed up/down : SPEEDUP SPEEDDOWN\n"
"Mode (discomode) : MODE01 MODE02 MODE03 MODE04 MODE05\n"
" : MODE06 MODE07 MODE08 MODE09\n"
"Bulb color : COLOR001 COLOR002 COLOR003 COLOR004\n"
)

Expand All @@ -52,41 +54,41 @@
#########################
def iBox2BulbCommand(x):
return {
"COLOR001" : "31 00 00 08 01 BA BA BA BA",
"COLOR002" : "31 00 00 08 01 FF FF FF FF",
"COLOR003" : "31 00 00 08 01 7A 7A 7A 7A",
"COLOR004" : "31 00 00 08 01 1E 1E 1E 1E",
"SATUR00" : "31 00 00 08 02 64 00 00 00",
"SATUR25" : "31 00 00 08 02 4B 00 00 00",
"SATUR50" : "31 00 00 08 02 32 00 00 00",
"SATUR75" : "31 00 00 08 02 19 00 00 00",
"SATUR100" : "31 00 00 08 02 00 00 00 00",
"DIM00" : "31 00 00 08 03 64 00 00 00",
"DIM25" : "31 00 00 08 03 4B 00 00 00",
"DIM50" : "31 00 00 08 03 32 00 00 00",
"DIM75" : "31 00 00 08 03 19 00 00 00",
"DIM100" : "31 00 00 08 03 00 00 00 00",
"ON" : "31 00 00 08 04 01 00 00 00",
"OFF" : "31 00 00 08 04 02 00 00 00",
"NIGHTON" : "31 00 00 08 04 05 00 00 00",
"WHITEON" : "31 00 00 08 05 64 00 00 00",
"SPEEDUP" : "31 00 00 08 04 03 00 00 00",
"SPEEDDOWN" : "31 00 00 08 04 04 00 00 00",
"WW00" : "31 00 00 08 05 64 00 00 00",
"WW25" : "31 00 00 08 05 4B 00 00 00",
"WW50" : "31 00 00 08 05 32 00 00 00",
"WW75" : "31 00 00 08 05 19 00 00 00",
"WW100" : "31 00 00 08 05 00 00 00 00",
"MODE01" : "31 00 00 08 06 01 00 00 00",
"MODE02" : "31 00 00 08 06 02 00 00 00",
"MODE03" : "31 00 00 08 06 03 00 00 00",
"MODE04" : "31 00 00 08 06 04 00 00 00",
"MODE05" : "31 00 00 08 06 05 00 00 00",
"MODE06" : "31 00 00 08 06 06 00 00 00",
"MODE07" : "31 00 00 08 06 07 00 00 00",
"MODE08" : "31 00 00 08 06 08 00 00 00",
"MODE09" : "31 00 00 08 06 09 00 00 00",
}.get(x)
"COLOR001" : "31 00 00 08 01 BA BA BA BA",
"COLOR002" : "31 00 00 08 01 FF FF FF FF",
"COLOR003" : "31 00 00 08 01 7A 7A 7A 7A",
"COLOR004" : "31 00 00 08 01 1E 1E 1E 1E",
"SATUR00" : "31 00 00 08 02 64 00 00 00",
"SATUR25" : "31 00 00 08 02 4B 00 00 00",
"SATUR50" : "31 00 00 08 02 32 00 00 00",
"SATUR75" : "31 00 00 08 02 19 00 00 00",
"SATUR100" : "31 00 00 08 02 00 00 00 00",
"DIM00" : "31 00 00 08 03 64 00 00 00",
"DIM25" : "31 00 00 08 03 4B 00 00 00",
"DIM50" : "31 00 00 08 03 32 00 00 00",
"DIM75" : "31 00 00 08 03 19 00 00 00",
"DIM100" : "31 00 00 08 03 00 00 00 00",
"ON" : "31 00 00 08 04 01 00 00 00",
"OFF" : "31 00 00 08 04 02 00 00 00",
"NIGHTON" : "31 00 00 08 04 05 00 00 00",
"SPEEDUP" : "31 00 00 08 04 03 00 00 00",
"SPEEDDOWN" : "31 00 00 08 04 04 00 00 00",
"WHITEON" : "31 00 00 08 05 64 00 00 00",
"WW00" : "31 00 00 08 05 64 00 00 00",
"WW25" : "31 00 00 08 05 4B 00 00 00",
"WW50" : "31 00 00 08 05 32 00 00 00",
"WW75" : "31 00 00 08 05 19 00 00 00",
"WW100" : "31 00 00 08 05 00 00 00 00",
"MODE01" : "31 00 00 08 06 01 00 00 00",
"MODE02" : "31 00 00 08 06 02 00 00 00",
"MODE03" : "31 00 00 08 06 03 00 00 00",
"MODE04" : "31 00 00 08 06 04 00 00 00",
"MODE05" : "31 00 00 08 06 05 00 00 00",
"MODE06" : "31 00 00 08 06 06 00 00 00",
"MODE07" : "31 00 00 08 06 07 00 00 00",
"MODE08" : "31 00 00 08 06 08 00 00 00",
"MODE09" : "31 00 00 08 06 09 00 00 00",
}.get(x)


###########################
Expand All @@ -103,7 +105,7 @@ def getChecksum(data):
checksum = 0
for x in bytearray.fromhex(data):
checksum += x
return format(checksum, "04X")[2:]
return format(checksum, "04X")[2:]


###################
Expand Down

0 comments on commit d3592d1

Please sign in to comment.