Hi Memphiz,
is it maybe possible to get support for milight bulbs?
I allready have something working but it does not really do nice.
Here is what i got:
boblight.conf:
Code:
[device]
name WifiLed
output python /storage/.kodi/userdata/addon_data/service.multimedia.boblightd/milight.py
channels 3
type popen
interval 100000
debug off
[color]
name WIFIred
rgb FF0000
blacklevel 0.00
[color]
name WIFIgreen
rgb 00FF00
blacklevel 0.00
[color]
name WIFIblue
rgb 0000FF
blacklevel 0.00
[light]
name WI1
color WIFIred WifiLed 1
color WIFIgreen WifiLed 2
color WIFIblue WifiLed 3
hscan 0 100
vscan 0 100
milight.py:
Code:
import colorsys
import sys
import socket
logger=None
class Logger:
logfile=None
def __init__(self,activateLogging,path):
if(activateLogging):
self.logfile = file(path, "wb")
def writeLine(self,msg):
if(self.logfile!=None):
self.logfile.write(str(msg))
self.logfile.flush()
class boblightMilightConnector:
def __init__(self):
self.readInputStream()
def readInputStream(self):
milight=milightController("192.168.178.44",8899)
while True:
input = sys.stdin.readline()
logger.writeLine("Input: "+input)
inputData=input.split(' ')
if(len(inputData)>3):
r = float(inputData[0])
g = float(inputData[1])
b = float(inputData[2])
milight.setRGB(r,g,b)
class milightController:
ip=None
port=None
sock=socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
def __init__(self,IP,Port):
self.ip=IP
self.port=Port
def setRGB(self,r,g,b):
h, s, v = colorsys.rgb_to_hsv(float(r), float(g), float(b))
logger.writeLine("H: "+str(h)+" S: "+str(s)+" v: "+str(v))
if(s<0.02):
MESSAGE1 = "\xC5\x00"
if(h>0.3333):
htmp=h-0.3333
logger.writeLine("Vk1: "+str(htmp))
vtmp=htmp/0.6666
logger.writeLine("Vk2: "+str(vtmp))
vtmp=(2*vtmp)
logger.writeLine("Vk3: "+str(vtmp))
v=v/vtmp
logger.writeLine("Vk4: "+str(v))
else:
#Korrektur Gelb
if (h < 0.33333):
h= h *0.5
#Korrektur Cyan
if (h > 0.33333 and h < 0.5):
h= h*0.9
if(h>0.3333):
htmp=h-0.3333
logger.writeLine("Vk1: "+str(htmp))
vtmp=htmp/0.6666
logger.writeLine("Vk2: "+str(vtmp))
vtmp=(2*vtmp)
logger.writeLine("Vk3: "+str(vtmp))
v=v/vtmp
logger.writeLine("Vk4: "+str(v))
h = int((h) * 256)
#Korrektur Farbverschiebung
h=h+85
if(h>256):
h=256-(h%256)
else:
h=abs(h-256)
h=int(h)
MESSAGE1 = "\x40" + chr(h)
if (v>=0.75):
v=0.75
v=v*25
v=int(round(v))
v=v+2
v=min(27,v)
v = max(2,v)
MESSAGE2 = "\x4E" + chr(v)
logger.writeLine("H2: "+str(h)+" S2: "+str(s)+" v2: "+str(v))
self.sock.sendto(MESSAGE1, (self.ip, self.port))
self.sock.sendto(MESSAGE2, (self.ip, self.port))
logger=Logger(False,"/storage/milight.log")
boblightMilightConnector()
This still works but there is one big problem, if i stop video playback and normal ambilight (arduino with ws2801) turns off the milight.py sends the command to set the milights to white mode and this will happen permanent, that means if i don't look video and wnat to turn of the milight bulbs with the remote or the smartphone app they immediatelly will turn on again because boblight will trigger the milight.py script even if there is no playback.
How did you realize that my arduino turn off the lights and how can i integrate the milights better, any idea appreaciated
Here is a link to the api of the milights or how ever they name em:
http://www.limitlessled.com/dev/
the milights are a good and cheaper alternative to the philips hue lights, i payed 80€ for 3 9w RGBW Milight Bulbs + RF Remote + WLAN Bridge, philips hue is about 200€
Reagrds X23