Hallo, hier meine hue.py
Spoiler anzeigen
Liegt es vielleicht daran, dass ich eine Solo 2 habe?
Gruß + Dank
import sys
import os
import time
import json
import httplib
from rgb_xy import Converter
from rgb_xy import GamutC # or GamutB, GamutC (you must look for the type of your lamps)
counter = 12
def popen():
converter = Converter(GamutC)
spidev = file( os.getcwd()+'/aufruf.log', "wb")
key = "mnNKSCuTXDmUUcHZFmUBZKQwjec0l5SZbl6WKNmI"
ip = "192.168.2.59"
url = '/api/' + key + '/lights/'
lurl = url + '1/state' # die 1 ersetzen mit der Nummer deiner Leuchte
MINIMAL_VALUE=0.000000000
while True:
eingabe = sys.stdin.readline()
if len(eingabe)>0:
global counter
counter += 1
try:
lr,lg,lb,x = eingabe.split(' ')
except ValueError:
spidev.write("Not enough input parameter, do you have the same amount of lights (channels) in your enigmalight config?")
spidev.flush()
raise
lr = (float(lr))*255
lg = (float(lg))*255
lb = (float(lb))*255
lll = calcLuminance(lr,lg,lb)
if (counter>=13):
connection = httplib.HTTPConnection(ip, timeout=10)
lparams = {'xy': converter.rgb_to_xy(lr,lg,lb), 'colormode': 'xy', 'bri': int(lll), 'on': True}
connection.request('PUT', lurl, json.dumps(lparams))
response = connection.getresponse()
connection.close()
counter=0
else:
os.system("curl -d '{\"on\":false}' -X PUT 192.168.2.59/api/mnNKSCuTXDmUUcHZFmUBZKQwjec0l5SZbl6WKNmI/groups/0/action")
break
def calcLuminance(r,g,b):
LUM_VALUE=5
luminance=1
if (r + g + b > 1):
luminance= r + g + b + LUM_VALUE
if (luminance>=255):
luminance=254
return luminance
import time
time.sleep(1)
popen()
import os
import time
import json
import httplib
from rgb_xy import Converter
from rgb_xy import GamutC # or GamutB, GamutC (you must look for the type of your lamps)
counter = 12
def popen():
converter = Converter(GamutC)
spidev = file( os.getcwd()+'/aufruf.log', "wb")
key = "mnNKSCuTXDmUUcHZFmUBZKQwjec0l5SZbl6WKNmI"
ip = "192.168.2.59"
url = '/api/' + key + '/lights/'
lurl = url + '1/state' # die 1 ersetzen mit der Nummer deiner Leuchte
MINIMAL_VALUE=0.000000000
while True:
eingabe = sys.stdin.readline()
if len(eingabe)>0:
global counter
counter += 1
try:
lr,lg,lb,x = eingabe.split(' ')
except ValueError:
spidev.write("Not enough input parameter, do you have the same amount of lights (channels) in your enigmalight config?")
spidev.flush()
raise
lr = (float(lr))*255
lg = (float(lg))*255
lb = (float(lb))*255
lll = calcLuminance(lr,lg,lb)
if (counter>=13):
connection = httplib.HTTPConnection(ip, timeout=10)
lparams = {'xy': converter.rgb_to_xy(lr,lg,lb), 'colormode': 'xy', 'bri': int(lll), 'on': True}
connection.request('PUT', lurl, json.dumps(lparams))
response = connection.getresponse()
connection.close()
counter=0
else:
os.system("curl -d '{\"on\":false}' -X PUT 192.168.2.59/api/mnNKSCuTXDmUUcHZFmUBZKQwjec0l5SZbl6WKNmI/groups/0/action")
break
def calcLuminance(r,g,b):
LUM_VALUE=5
luminance=1
if (r + g + b > 1):
luminance= r + g + b + LUM_VALUE
if (luminance>=255):
luminance=254
return luminance
import time
time.sleep(1)
popen()
Gruß + Dank
Dieser Beitrag wurde bereits 2 mal editiert, zuletzt von hgdo ()