Esempio n. 1
0
def main():
    config = {}
    try:
        config_file = os.path.join(expanduser("~"), ".arehuebusy.yml")
        with open(config_file, 'r') as f:
            config = yaml.load(f)
    except Exception as e:
        print "Error loading config.yml"
        print e
        sys.exit(2)

    valid_status = config["status"].keys()
    if len(sys.argv) < 2 or sys.argv[1] not in valid_status:
        print "Missing or invalid status"
        print "Usage: arehuebusy <%s>" % (','.join(valid_status))
        sys.exit(2)

    status = sys.argv[1]

    logging.basicConfig()
    b = Bridge(config["bridge_ip"])
    b.connect()
    status_config = config["status"][status]
    print status_config["color"]
    print "Setting %s to %s, brightness %s . . ." % (
        config["light"], status_config["color"], status_config["brightness"])
    converter = Converter(GamutC)
    x, y = converter.hex_to_xy(status_config["color"])
    busy_light = b.get_light_objects('name')[config["light"]]
    busy_light.xy = [x, y]
    busy_light.brightness = status_config["brightness"]
Esempio n. 2
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
from rgb_xy import Converter

conv = Converter()

print(conv.rgb_to_xy(255, 255, 255))
Esempio n. 4
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
Esempio n. 5
0
    http://www.apache.org/licenses/LICENSE-2.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
Esempio n. 6
0
import random

import flask
from phue import Bridge
from rgb_xy import GamutC, Converter

converter = Converter(GamutC)
b = Bridge(ip='10.0.0.57')

app = flask.Flask(__name__)


@app.route('/')
def hello():
    return flask.render_template('index.html')


@app.route('/api/change')
def change():
    color = flask.request.args.get('color')

    lights = b.lights
    for light in lights:
        light.brightness = 255

        if color == 'green':
            light.xy = converter.rgb_to_xy(0, 255, 0)
        elif color == 'purple':
            light.xy = converter.rgb_to_xy(128, 0, 128)
        elif color == 'red':
            light.xy = converter.rgb_to_xy(255, 0, 0)
Esempio n. 7
0
import appdaemon.plugins.hass.hassapi as hass
import time
import datetime
from rgb_xy import Converter
import globals as g

conv = Converter()

"""
Sunrise app

Args:
switch: The switch that initializes the script
light: The light that's used for sunrise


"""


class Sunrise(hass.Hass):
    def initialize(self):
        self.log("Initializing sunrise")
        self.switch = self.args["switch"] # The switch to turn on/off the sunrise

        self.entity = "light.bathroom_2" # The light to act as sun

        self.listen_state(self.rise_instant, self.args["switch"], new="on") # Callback for testing

        self.listen_state(self.set_alarm, "input_select.sunrise_hour") # Callback for testing
        self.listen_state(self.set_alarm, "input_select.sunrise_minute") # Callback for testing
        self.listen_state(self.set_alarm, "input_boolean.sunrise_alarm") # Callback for testing