示例#1
0
def popen():
	converter = Converter(GamutC)
	spidev = file( os.getcwd()+'/aufruf.log', "wb")
	key = "PmjwE4NWFkA6mFA6agS1b5Wi2oeOeLPrNRGWcy72"
	ip = "192.168.1.175"
	url = '/api/' + key + '/lights/'
	lurl = url + '2/state'
	rurl = url + '1/state'
	burl = url + '4/state'
	#need to be sure that its not 0
	MINIMAL_VALUE=0.000000000

	while True:
		eingabe = sys.stdin.readline()

		if len(eingabe)>0:
			global counter
			counter += 1
			# Get Input
			try:
				lr,lg,lb,rr,rg,rb,br,bg,bb,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 
			rr = (float(rr))*255
			rg = (float(rg))*255
			rb = (float(rb))*255
			br = (float(br))*255
			bg = (float(bg))*255
			bb = (float(bb))*255

			lll = calcLuminance(lr,lg,lb)
			llr = calcLuminance(rr,rg,rb)
			llb = calcLuminance(br,bg,bb)

			if (counter>=10):
				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()
				
				#rparams = {'xy': converter.rgb_to_xy(rr,rg,rb), 'colormode': 'xy', 'bri': int(llr), 'on': True}
				#connection.request('PUT', rurl, json.dumps(rparams))
				#response = connection.getresponse()

				bparams = {'xy': converter.rgb_to_xy(br,bg,bb), 'colormode': 'xy', 'bri': int(llb), 'on': True}
				connection.request('PUT', burl, json.dumps(bparams))
				response = connection.getresponse()

				connection.close()
				counter=0
		else:
			break
示例#2
0
def popen():
    converter = Converter(GamutC)
    spidev = file(os.getcwd() + '/aufruf.log', "wb")
    key = "HIER DEN KEY DER BRIDGE EINTRAGEN"
    ip = "xxx.xxx.xxx.xxx"
    url = '/api/' + key + '/lights/'
    lurl = url + '10/state'
    rurl = url + '11/state'

    MINIMAL_VALUE = 0.000000000

    while True:
        eingabe = sys.stdin.readline()

        if len(eingabe) > 0:
            global counter
            counter += 1

            try:
                lr, lg, lb, rr, rg, rb, 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
            rr = (float(rr)) * 255
            rg = (float(rg)) * 255
            rb = (float(rb)) * 255

            lll = calcLuminance(lr, lg, lb)
            llr = calcLuminance(rr, rg, rb)

            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()

                rparams = {
                    'xy': converter.rgb_to_xy(rr, rg, rb),
                    'colormode': 'xy',
                    'bri': int(llr),
                    'on': True
                }
                connection.request('PUT', rurl, json.dumps(rparams))
                response = connection.getresponse()

                connection.close()
                counter = 0
        else:
            os.system(
                "curl -d '{\"on\":false}' -X PUT  192.168.xxx.xxx/api/HIER DEN KEY DER BRIDGE EINTRAGEN/groups/0/action"
            )
            break
from rgb_xy import Converter

conv = Converter()

print(conv.rgb_to_xy(255, 255, 255))
示例#4
0
 
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License
"""

import rest
import time
from rgb_xy import Converter
from rgb_xy import GamutB

if __name__ == '__main__':
    converter = Converter(GamutB)
    print(converter.rgb_to_xy(255, 0, 0))
    # the base URL
    base_url = 'http://localhost:8000'
    # if you are using the emulator, probably the base_url will be:
    # base_url = 'http://localhost:8000'

    # example username, generated by following https://www.developers.meethue.com/documentation/getting-started
    username = '******'
    # if you are using the emulator, the username is:
    # username = '******'

    # lights URL
    lights_url = base_url + '/api/' + username + '/lights/'

    # get the Hue lights
    all_the_lights = rest.send(url=lights_url)