예제 #1
0
    def __init__(self, bot):
        self.bot = bot
        self.nanoip = self.bot.nano_config['ipAddress']
        self.nanoauth = self.bot.nano_config['authToken']

        self.nanopanels = Nanoleaf(
            ip=self.bot.nano_config['ipAddress'],
            auth_token=self.bot.nano_config['authToken'],
            print_errors=True)
예제 #2
0
def get_scenes(props, prop):
    if device_ip is not None and auth_key is not None:
        nl = Nanoleaf(device_ip, auth_key)
        s1 = obs.obs_properties_get(props, "scene_on")
        s2 = obs.obs_properties_get(props, "scene_off")
        for light_scene in nl.list_effects():
            obs.obs_property_list_add_string(s1, light_scene, light_scene)
            obs.obs_property_list_add_string(s2, light_scene, light_scene)
        return True
예제 #3
0
 def connect_nanoleaf(self, *args):
     try:
         self.nl = Nanoleaf('192.168.0.108')
         auth_token = 'authentication token'  #Real token was removed by authors for protecting security
         self.nl = Nanoleaf('192.168.0.108', auth_token)
     except Exception:
         content = GridLayout(cols=1)
         content.add_widget(Label(text='No valid nanoleaf device found'))
         content_admit = Button(text='OK')
         content.add_widget(content_admit)
         popup = Popup(title='Message', content=content, auto_dismiss=False)
         content_admit.bind(on_release=popup.dismiss)
         popup.open()
예제 #4
0
def authorize_device(props, prop):
    global generated_auth_token
    nl = Nanoleaf(device_ip)
    if nl.generate_auth_token():
        generated_auth_key = nl.auth_token
        s = obs.obs_properties_get(props, "auth_key")
        obs.obs_property_list_add_string(s, generated_auth_key,
                                         generated_auth_key)

        return True
    print('[OBS-Nanoleaf]: Unable to acquire Authorization!')
    print(
        '[OBS-Nanoleaf]: Please make sure to Hold the on-off button down for 5-7 seconds until the LED starts flashing in a pattern'
    )
예제 #5
0
def main():
    cluster_info = GET("").json()
    nl = Nanoleaf(NANOLEAF_IP_PORTLESS, API_KEY)

    if ENABLE_LOGS:
        print("Logs enabled")
        bg = threading.Thread(name='logs', target=write_log)
        bg.start()
    
    with sd.InputStream(callback=update_sound):
        while True:
            time.sleep(0.2)
            
            intensities = associate_panel_id_to_intensity(g_volume, cluster_info)
            payload = intensities_to_payload(intensities)
            nl.write_effect(payload)
예제 #6
0
 def gotocon(self):
     try:
         global nl
         nl = Nanoleaf(lis[0], lis[1])
         print("Connect succesfully to the Nanoleaf")
         Ui_Connection = connection()
         widget.addWidget(Ui_Connection)
         widget.setCurrentIndex(widget.currentIndex() + 1)
     except Exception as e:
         print(str(e))
     print(lis)
예제 #7
0
 def auth(self):
     try:
         nlip = Nanoleaf(lis[0])
         tok = nlip.generate_auth_token()
         if tok == False:
             self.label_3.setText('Token Generation Error')
         else:
             self.label_3.setText(tok)
             with open('connect.txt', 'w') as f:
                 print('### FILE CLEAR ###')
             with open('connect.txt', 'a') as f:
                 res2 = lis[0]
                 lis.clear()
                 f.write(res2 + "\n")
                 f.write(tok + "\n")
                 lis.append(res2)
                 lis.append(tok)
                 print(f'### {res2} + {tok} RESET IN FILE ###')
                 print('generated')
     except Exception as e:
         self.label_3.setText(str(e))
예제 #8
0
class NanoleafController(BaseController):
    """
    This class controls the Nanoleaf lights
    """
    receiving_events = False
    touch_event_dict = {
        0: 'push',
        2: 'up',
        3: 'down',
        4: 'left',
        5: 'right',
    }

    def __init__(self):
        super(NanoleafController, self).__init__()
        self.device = Nanoleaf(ip=config.globals.devices.nanoleaf.ip,
                               auth_token=os.environ["nanoleaf_token"])
        logger.info("Nanoleaf controller has been properly set-up")
        self.events = []

    def get_scene(self):
        return self.device.get_current_effect()

    def set_scene(self, scene):
        self.device.set_effect(scene)

    def power_off(self):
        self.device.power_off()

    def power_on(self):
        self.device.power_on()

    def add_touch_event_listener(self):
        self.receiving_events = True
        self.device.register_event(self.store_event(), event_types=[4])

    def store_event(self):
        def register_event(event):
            self.events.append(event)

        return register_event
예제 #9
0
def api_factory(ip : str) -> Any:
	api = None

	try:
		from nanoleafapi import Nanoleaf, NanoleafConnectionError, NanoleafRegistrationError

		try:
			api = Nanoleaf(ip)
		except NanoleafConnectionError:
			exit(wording.get('connection_no').format('NANOLEAF LIGHT') + wording.get('exclamation_mark'))
		except NanoleafRegistrationError:
			exit(wording.get('press_button').format('PAIRING', 'NANOLEAF LIGHT') + wording.get('exclamation_mark'))
		return api
	except ImportError:
		exit(wording.get('package_no').format('NANOLEAF LIGHT') + wording.get('exclamation_mark'))
예제 #10
0
def send_notice(event_name, key, text):
    url = "https://maker.ifttt.com/trigger/" + 'notice_phone' + "/with/key/" + 'cHfwbFfxP4F2Bm0EZ3oFJFgouwZ3aRDb8Ct5ta1SbYa' + ""
    payload = "{\n    \"value1\": \"" + text + "\"\n}"
    headers = {
        'Content-Type': "application/json",
        'User-Agent': "PostmanRuntime/7.15.0",
        'Accept': "*/*",
        'Cache-Control': "no-cache",
        'Postman-Token':
        "a9477d0f-08ee-4960-b6f8-9fd85dc0d5cc,d376ec80-54e1-450a-8215-952ea91b01dd",
        'Host': "maker.ifttt.com",
        'accept-encoding': "gzip, deflate",
        'content-length': "63",
        'Connection': "keep-alive",
        'cache-control': "no-cache"
    }

    response = requests.request("POST",
                                url,
                                data=payload.encode('utf-8'),
                                headers=headers)
    if response.text == 'Congratulations! You\'ve fired the notice_phone event':
        nl = Nanoleaf('192.168.0.108', 'GqOO9LTcPmhcjO26mjbtvcSaUwU3dd3v')
        nl.identify()
예제 #11
0
# third-party
from discord.ext import commands
from dotenv import load_dotenv
from nanoleafapi import discovery
from nanoleafapi import Nanoleaf

load_dotenv()
TOKEN = os.getenv('DISCORD_TOKEN')
GUILD = os.getenv('DISCORD_GUILD')
NANOLEAF_IP_ADDRESS = os.getenv('NANOLEAF_IP_ADDRESS')
NANOLEAF_AUTH_TOKEN = os.getenv('NANOLEAF_AUTH_TOKEN')

MALFORMED_MESSAGE_ERROR_MESSAGE = 'Malformed message received. Nothing happened!'

nanoleaf = Nanoleaf(NANOLEAF_IP_ADDRESS, NANOLEAF_AUTH_TOKEN)

bot = commands.Bot(command_prefix='!nanoleaf ')


@bot.command(name='debugger', help='Type \"!nanoleaf debugger\" to debug.')
async def debugger(ctx, arg=None, *args):
    breakpoint()


@bot.command(name='connect',
             help='Performs functionality related to connection')
async def connect(ctx, ip_address):
    # TODO Everything
    # Non-developers will not be able to connect their Nanoleafs to Discord Bot Siege Thots
    pass
예제 #12
0
class Sample(commands.Cog):
    def __init__(self, bot):
        self.bot = bot
        self.nanoip = self.bot.nano_config['ipAddress']
        self.nanoauth = self.bot.nano_config['authToken']

        self.nanopanels = Nanoleaf(
            ip=self.bot.nano_config['ipAddress'],
            auth_token=self.bot.nano_config['authToken'],
            print_errors=True)

    @commands.Cog.listener()
    async def on_guild_join(self, guild):
        """
        This event receives the the guild when the bot joins.
        """
        print(f'Joined {guild.name} with {guild.member_count} users!')

    @commands.command()
    async def stop(self, ctx):
        """
        Kills the current server
        """
        await ctx.send('Bye!', delete_after=10)
        exit()

    @commands.group(invoke_without_command=True)
    async def foo(self, ctx: Context):
        """
        A sub command group, Showing how sub command groups can be made.
        """
        await ctx.send('try my subcommand')

    @foo.command(aliases=['an_alias'])
    async def bar(self, ctx: Context):
        """
        I have an alias!, I also belong to command 'foo'
        """
        await ctx.send('foo bar!')

    @commands.group(invoke_without_command=True)
    async def nano(self, ctx: Context):
        await ctx.send('Nanopanels command', delete_after=20)

    @nano.command()
    async def on(self, ctx: Context):
        """
        Turns the nanopanels on if they are off, otherwise does nothing
        """
        if not self.nanopanels.get_power():
            self.nanopanels.toggle_power()

        await ctx.send('Nanopanels on', delete_after=20)

    @nano.command()
    async def off(self, ctx: Context):
        """
        Turns the nanopanels off if they are on
        """
        if self.nanopanels.get_power():
            self.nanopanels.toggle_power()

        await ctx.send('Nanopanels off', delete_after=20)

    @nano.command()
    async def brightness(self, ctx: Context):
        """
        Set the nanopanels brightness, value must be between 0 and 100
        """
        args = ctx.message.content.split(' ')
        if len(args) < 3:
            await ctx.send('Error: must have a `brightness` value',
                           delete_after=10)

        brightness = int(args[2])
        duration = abs(int(args[3])) if len(args) >= 4 else 0

        if 0 <= brightness <= 100:
            self.nanopanels.set_brightness(brightness=brightness,
                                           duration=duration)
            await ctx.send(f'Set brightness to {brightness}', delete_after=10)
        else:
            await ctx.send('Invalid values', delete_after=10)

    @nano.command()
    async def effects(self, ctx: Context):
        """
        Displays available scenes
        """
        msg = ''
        for i, effect in enumerate(self.nanopanels.list_effects()):
            msg += f'{i+1}. {effect}\n'

        await ctx.send(f'```md\n{msg}```', delete_after=60)

    @nano.command()
    async def effect(self, ctx: Context):
        """
        Sets the provided effect
        """
        _, _, element_no = ctx.message.content.split(' ')
        element_no = int(element_no)
        effects = self.nanopanels.list_effects()

        # check for out of bounds
        if element_no > len(effects):
            return

        selected = effects[element_no - 1]
        if self.nanopanels.set_effect(selected):
            await ctx.send(f'Set effect `{selected}`', delete_after=20)
        else:
            await ctx.send(f'Error setting effect `{selected}`',
                           delete_after=10)

    @nano.command()
    async def info(self, ctx: Context):
        """
        Prints out information about the nanopanels in a readable format
        """
        # info to print: brightness, on/off state, current effect
        info = self.nanopanels.get_info()
        brightness = info['state']['brightness']['value']
        state = 'on' if info['state']['on']['value'] else 'off'
        effect = info['effects']['select']
        print(json.dumps(self.nanopanels.get_info(), indent=4))

        message = f'effect: `{effect}`\nbrightness: `{brightness}`\nstate: `{state}`'
        await ctx.send(message, delete_after=20)
예제 #13
0
 def __init__(self):
     super(NanoleafController, self).__init__()
     self.device = Nanoleaf(ip=config.globals.devices.nanoleaf.ip,
                            auth_token=os.environ["nanoleaf_token"])
     logger.info("Nanoleaf controller has been properly set-up")
     self.events = []
예제 #14
0
from nanoleafapi import Nanoleaf
from nanoleafapi import RED, ORANGE,YELLOW,BLUE,GREEN,WHITE,LIGHT_BLUE,PINK,PURPLE
from variables import ip, authtoken

nl = Nanoleaf(ip,authtoken)

def powerOff():
    nl.power_off()
    return

class weatherControl():

    @staticmethod
    def thunderStorm():
        nl.set_effect("Thunder")
        return

    @staticmethod
    def rain():
        nl.set_effect("Rain")
        return
    
    @staticmethod
    def sunshine():
        nl.set_effect("Sunlight")
        return
    
    @staticmethod
    def clouds():
        nl.set_effect("Clouds")
        return
예제 #15
0
from nanoleafapi import discovery, Nanoleaf
from nanoleafapi import RED, ORANGE, YELLOW, GREEN, LIGHT_BLUE, BLUE, LIGHT_BLUE, PINK, PURPLE, WHITE
from flask import Flask

app = Flask(__name__)

auth_token = "yD3RlM2LKIBAUJXxILjnjeBIKtxLGroB"
ip = "192.168.3.34"

nl = Nanoleaf(ip, auth_token)

#nl.set_color(PURPLE)
#nl.set_color((210,105,30))

x = nl.list_effects()
print (x)

effects = ['Color Burst', 'Falling Whites', 'Fireworks', 'Flames', 'Forest', 'Inner Peace', 'Meteor Shower', 'Nemo', 'Northern Lights', 'Paint Splatter', 'Pulse PopBeats', 'Radial Sound Bar', 'Rhythmic Northern Lights', 'Romantic', 'Sound Bar', 'Streaking Notes']
 
nl.set_effect(effects[0])

y = nl.get_current_effect()
print (y)
예제 #16
0
def deactivate_light_scene():
    global scene_off
    nl = Nanoleaf(device_ip, auth_key)
    if use_last_light_scene:
        scene_off = last_light_scene
    nl.set_effect(scene_off)
예제 #17
0
def get_nanoleaf_obj():
    """Setup the nanoleaf"""
    print('Setting up nanoleaf')
    nanoleaf_ip = '10.0.0.1'
    return Nanoleaf(nanoleaf_ip)
예제 #18
0
def activated_light_scene():
    global last_light_scene
    nl = Nanoleaf(device_ip, auth_key)
    last_light_scene = nl.get_current_effect()
    nl.set_effect(scene_on)
예제 #19
0
class TestApp(App):
    def connect_nanoleaf(self, *args):
        try:
            self.nl = Nanoleaf('192.168.0.108')
            auth_token = 'authentication token'  #Real token was removed by authors for protecting security
            self.nl = Nanoleaf('192.168.0.108', auth_token)
        except Exception:
            content = GridLayout(cols=1)
            content.add_widget(Label(text='No valid nanoleaf device found'))
            content_admit = Button(text='OK')
            content.add_widget(content_admit)
            popup = Popup(title='Message', content=content, auto_dismiss=False)
            content_admit.bind(on_release=popup.dismiss)
            popup.open()

    def power_on(self, *args):
        try:
            self.nl.power_on()
        except AttributeError:
            content = GridLayout(cols=1)
            content.add_widget(
                Label(text='Please connect to nanoleaf at first'))
            content_admit = Button(text='OK')
            content.add_widget(content_admit)
            popup = Popup(title='Message', content=content, auto_dismiss=False)
            content_admit.bind(on_release=popup.dismiss)
            popup.open()

    def power_off(self, *args):
        try:
            self.nl.power_off()
        except AttributeError:
            content = GridLayout(cols=1)
            content.add_widget(
                Label(text='Please connect to nanoleaf at first'))
            content_admit = Button(text='OK')
            content.add_widget(content_admit)
            popup = Popup(title='Message', content=content, auto_dismiss=False)
            content_admit.bind(on_release=popup.dismiss)
            popup.open()

    def turn_up(self, *args):
        try:
            if self.nl.get_power() == True:
                self.nl.increment_brightness(10)
        except AttributeError:
            content = GridLayout(cols=1)
            content.add_widget(
                Label(text='Please connect to nanoleaf at first'))
            content_admit = Button(text='OK')
            content.add_widget(content_admit)
            popup = Popup(title='Message', content=content, auto_dismiss=False)
            content_admit.bind(on_release=popup.dismiss)
            popup.open()

    def turn_down(self, *args):
        try:
            if self.nl.get_power() == True:
                if self.nl.get_brightness() > 0:
                    self.nl.set_brightness(self.nl.get_brightness() - 10)
                else:
                    self.nl.set_brightness(0)
        except AttributeError:
            content = GridLayout(cols=1)
            content.add_widget(
                Label(text='Please connect to nanoleaf at first'))
            content_admit = Button(text='OK')
            content.add_widget(content_admit)
            popup = Popup(title='Message', content=content, auto_dismiss=False)
            content_admit.bind(on_release=popup.dismiss)
            popup.open()

    def set_color(self, *args):
        try:
            if self.nl.get_power() == True:
                content = GridLayout(cols=2)
                content_admit = Button(text='OK')
                content_cancel = Button(text='Cancel')
                self.content_input = TextInput(multiline=False)
                content.add_widget(Label(text='Please input color in R,G,B:'))
                content.add_widget(self.content_input)
                content.add_widget(content_admit)
                content.add_widget(content_cancel)
                popup = Popup(title='Message',
                              content=content,
                              auto_dismiss=False)
                content_cancel.bind(on_release=popup.dismiss)
                content_admit.bind(on_release=self.pressed)
                popup.open()
        except AttributeError:
            content = GridLayout(cols=1)
            content.add_widget(
                Label(text='Please connect to nanoleaf at first'))
            content_admit = Button(text='OK')
            content.add_widget(content_admit)
            popup = Popup(title='Message', content=content, auto_dismiss=False)
            content_admit.bind(on_release=popup.dismiss)
            popup.open()

    def pressed(self, instance):
        color = self.content_input.text
        try:
            if color == 'RED':
                self.nl.set_color(RED)
            elif color == 'ORANGE':
                self.nl.set_color(ORANGE)
            elif color == 'YELLOW':
                self.nl.set_color(YELLOW)
            elif color == 'BLUE':
                self.nl.set_color(BLUE)
            elif color == 'GREEN':
                self.nl.set_color(GREEN)
            elif color == 'WHITE':
                self.nl.set_color(WHITE)
            elif color == 'LIGHT_BLUE':
                self.nl.set_color(LIGHT_BLUE)
            elif color == 'PINK':
                self.nl.set_color(PINK)
            elif color == 'PURPLE':
                self.nl.set_color(PURPLE)
            elif type(int(color.split(',')[0])) == int and type(int(color.split(',')[1])) == int and type(
                    int(color.split(',')[2])) == int and color.count(',') == 2 and \
                    (0 <= int(color.split(',')[0]) <= 255) == True and (
                    0 <= int(color.split(',')[1]) <= 255) == True and (0 <= int(color.split(',')[2]) <= 255) == True:
                self.nl.set_color(
                    (int(color.split(',')[0]), int(color.split(',')[1]),
                     int(color.split(',')[2])))

        except ValueError:
            content = GridLayout(cols=1)
            content.add_widget(Label(text='Please input valid numbers'))
            content_cancel = Button(text='OK')
            content.add_widget(content_cancel)
            popup = Popup(title='Warning', content=content, auto_dismiss=False)
            content_cancel.bind(on_release=popup.dismiss)
            popup.open()
        except IndexError:
            content = GridLayout(cols=1)
            content.add_widget(Label(text='Please input valid numbers'))
            content_cancel = Button(text='OK')
            content.add_widget(content_cancel)
            popup = Popup(title='Warning', content=content, auto_dismiss=False)
            content_cancel.bind(on_release=popup.dismiss)
            popup.open()

    def flash(self, *args):
        try:
            self.nl.identify()
        except AttributeError:
            content = GridLayout(cols=1)
            content.add_widget(
                Label(text='Please connect to nanoleaf at first'))
            content_admit = Button(text='OK')
            content.add_widget(content_admit)
            popup = Popup(title='Message', content=content, auto_dismiss=False)
            content_admit.bind(on_release=popup.dismiss)
            popup.open()

    def random_color(self, *args):
        try:
            if self.nl.get_power() == True:
                R = random.randint(0, 255)
                G = random.randint(0, 255)
                B = random.randint(0, 255)
                self.nl.set_color((R, G, B))
        except AttributeError:
            content = GridLayout(cols=1)
            content.add_widget(
                Label(text='Please connect to nanoleaf at first'))
            content_admit = Button(text='OK')
            content.add_widget(content_admit)
            popup = Popup(title='Message', content=content, auto_dismiss=False)
            content_admit.bind(on_release=popup.dismiss)
            popup.open()

    def on_value2(self, brightness):
        try:
            self.brightnessValue = "%d" % brightness
            self.nl.set_brightness(int(self.brightnessValue))
        except AttributeError:
            content = GridLayout(cols=1)
            content.add_widget(
                Label(text='Please connect to nanoleaf at first'))
            content_admit = Button(text='OK')
            content.add_widget(content_admit)
            popup = Popup(title='Message', content=content, auto_dismiss=False)
            content_admit.bind(on_release=popup.dismiss)
            popup.open()

    def on_value1(self, hue):
        try:
            self.hueValue = "%d" % hue
            self.nl.set_hue(int(self.hueValue))
        except AttributeError:
            content = GridLayout(cols=1)
            content.add_widget(
                Label(text='Please connect to nanoleaf at first'))
            content_admit = Button(text='OK')
            content.add_widget(content_admit)
            popup = Popup(title='Message', content=content, auto_dismiss=False)
            content_admit.bind(on_release=popup.dismiss)
            popup.open()

    def weatherControl(self):
        # self.state=active
        try:
            if self.aV1 == True and self.nl.get_power() == True:
                url = 'http://api.openweathermap.org/data/2.5/weather?id=5946768&appid=authentication token'  #Real token was removed by authors for protecting security
                json_data = requests.get(url).json()
                condition = json_data['weather'][0]['main']
                '''content=GridLayout(cols=1)
                content_admit=Button(text='OK')
                content.add_widget(Label(text='Weather is: '+condition))
                content.add_widget(content_admit)
                popup = Popup(title='Message',content=content,auto_dismiss=False)
                content_admit.bind(on_release=popup.dismiss)
                popup.open()'''
                if (condition == "Clear"):
                    self.sunny()
                elif (condition == "Clouds"):
                    self.cloudy()
                elif (condition == "Snow"):
                    self.snowy()
                elif (condition == "Rain"):
                    self.rainy()
                else:
                    pass
                t = Timer(5, self.weatherControl)
                t.start()
            else:
                t = Timer(5, self.weatherControl)
                t.cancel()

        except AttributeError:
            content = GridLayout(cols=1)
            content.add_widget(
                Label(text='Please connect to nanoleaf at first'))
            content_admit = Button(text='OK')
            content.add_widget(content_admit)
            popup = Popup(title='Message', content=content, auto_dismiss=False)
            content_admit.bind(on_release=popup.dismiss)
            popup.open()

    def sunControl(self):
        try:
            if self.aV3 == True:
                t1 = datetime.datetime.now()
                if t1.hour >= 8 and t1.hour <= 16:
                    self.nl.power_off()

                elif t1.hour == 7:
                    if t1.minute >= 40:
                        self.nl.power_off()
                    else:
                        self.nl.power_on()

                elif t1.hour == 17:
                    if t1.minute <= 45:
                        self.nl.power_off()
                    else:
                        self.nl.power_on()

                else:
                    self.nl.power_on()
                t = Timer(5, self.sunControl)
                t.start()

            else:
                # self.nl.power_off()
                t = Timer(5, self.sunControl)
                t.cancel()

        except AttributeError:
            content = GridLayout(cols=1)
            content.add_widget(
                Label(text='Please connect to nanoleaf at first'))
            content_admit = Button(text='OK')
            content.add_widget(content_admit)
            popup = Popup(title='Message', content=content, auto_dismiss=False)
            content_admit.bind(on_release=popup.dismiss)
            popup.open()

    def activeValue1(self, active):
        self.aV1 = active
        self.weatherControl()

    def activeValue2(self, active):
        self.aV2 = active
        self.tempControl()

    def activeValue3(self, active):
        self.aV3 = active
        self.sunControl()

    def activeValue4(self, active):
        self.aV4 = active
        self.sunLab()

    def activeValue5(self, active):
        self.aV5 = active
        self.sunBed()

    def activeValue6(self, active):
        self.aV6 = active
        self.sunLiving()

    def activeValue7(self, active):
        self.aV7 = active
        self.sunWhite()

    def activeValue8(self, active):
        self.aV8 = active
        self.weatherLab()

    def activeValue9(self, active):
        self.aV9 = active
        self.weatherBed()

    def activeValue10(self, active):
        self.aV10 = active
        self.weatherLiving()

    def activeValue11(self, active):
        self.aV11 = active
        self.weatherWhite()

    def activeValue12(self, active):
        self.aV12 = active
        self.geofencinglab()

    def activeValue13(self, active):
        self.aV13 = active
        self.geofencingBed()

    def activeValue14(self, active):
        self.aV14 = active
        self.geofencingLiving()

    def activeValue15(self, active):
        self.aV15 = active
        self.geofencingWhite()

    def activeValue16(self, active):
        self.aV16 = active
        self.musiclab()

    def activeValue17(self, active):
        self.aV17 = active
        self.labscreen()

    def activeValue18(self, active):
        self.aV18 = active
        self.musicbed()

    def activeValue19(self, active):
        self.aV19 = active
        self.bedscreen()

    def activeValue20(self, active):
        self.aV20 = active
        self.musicliving()

    def activeValue22(self, active):
        self.aV22 = active
        self.musicwhite()

    def activeValue23(self, active):
        self.aV23 = active
        self.on_checkbox_active()

    def musicbed(self):
        if self.aV18 == True:
            import lightningstrike

    def musiclab(self):
        if self.aV16 == True:
            import lightningstrike

    def labscreen(self):
        if self.aV17 == True:
            import screen

    def bedscreen(self):
        if self.aV19 == True:
            import screen

    def musicliving(self):
        if self.aV20 == True:
            import lightningstrike

    def musicwhite(self):
        if self.aV22 == True:
            import lightningstrike

    def geofencinglab(self):
        if self.aV12 == True:
            from geofencing import src
            import app

    def geofencingBed(self):
        if self.aV13 == True:
            from geofencing import src
            import app

    def geofencingLiving(self):
        if self.aV14 == True:
            from geofencing import src
            import app

    def geofencingWhite(self):
        if self.aV15 == True:
            from geofencing import src
            import app

    def sunLab(self):
        if self.aV4 == True:
            t1 = datetime.datetime.now()
            if t1.hour >= 8 and t1.hour <= 16:
                self.b.set_light(2, 'on', False)

            elif t1.hour == 7:
                if t1.minute >= 40:
                    self.b.set_light(2, 'on', False)
                else:
                    self.b.set_light(2, 'on', True)

            elif t1.hour == 17:
                if t1.minute <= 45:
                    self.b.set_light(2, 'on', False)
                else:
                    self.b.set_light(2, 'on', True)

            else:
                self.b.set_light(2, 'on', True)
            t = Timer(5, self.sunLab)
            t.start()

        else:

            t = Timer(5, self.sunLab)
            t.cancel()

    def weatherLab(self):
        if self.aV8 == True:
            import weather
            t = Timer(5, self.weatherLab)
            t.start()

        else:
            from phue import Bridge
            b = Bridge('192.168.0.13')
            b.set_light(2, 'on', False)

            t = Timer(5, self.weatherLab)
            t.cancel()

    def weatherBed(self):
        if self.aV9 == True:
            import weather
            t = Timer(5, self.weatherBed)
            t.start()

        else:

            from phue import Bridge
            b = Bridge('192.168.0.13')
            b.set_light(1, 'on', False)

            t = Timer(5, self.weatherLab)
            t.cancel()

            t = Timer(5, self.weatherBed)
            t.cancel()

    def weatherLiving(self):
        if self.aV10 == True:
            import weather
            t = Timer(5, self.weatherLiving)
            t.start()

        else:

            t = Timer(5, self.weatherLiving)
            t.cancel()

    def weatherWhite(self):
        if self.aV11 == True:
            import weather
            t = Timer(5, self.weatherWhite)
            t.start()

        else:

            t = Timer(5, self.weatherWhite)
            t.cancel()

    def sunBed(self):
        if self.aV5 == True:
            t1 = datetime.datetime.now()
            if t1.hour >= 8 and t1.hour <= 16:
                self.b.set_light(1, 'on', False)

            elif t1.hour == 7:
                if t1.minute >= 40:
                    self.b.set_light(1, 'on', False)
                else:
                    self.b.set_light(1, 'on', True)

            elif t1.hour == 17:
                if t1.minute <= 45:
                    self.b.set_light(1, 'on', False)
                else:
                    self.b.set_light(1, 'on', True)

            else:
                self.b.set_light(1, 'on', True)
            t = Timer(5, self.sunBed)
            t.start()

        else:

            t = Timer(5, self.sunBed)
            t.cancel()

    def sunLiving(self):
        if self.aV6 == True:
            t1 = datetime.datetime.now()
            if t1.hour >= 8 and t1.hour <= 16:
                self.b.set_light(3, 'on', False)

            elif t1.hour == 7:
                if t1.minute >= 40:
                    self.b.set_light(3, 'on', False)
                else:
                    self.b.set_light(3, 'on', True)

            elif t1.hour == 17:
                if t1.minute <= 45:
                    self.b.set_light(3, 'on', False)
                else:
                    self.b.set_light(3, 'on', True)

            else:
                self.b.set_light(3, 'on', True)
            t = Timer(5, self.sunLiving)
            t.start()

        else:

            t = Timer(5, self.sunLiving)
            t.cancel()

    def sunWhite(self):
        if self.aV7 == True:
            t1 = datetime.datetime.now()
            if t1.hour >= 8 and t1.hour <= 16:
                self.b.set_light(4, 'on', False)

            elif t1.hour == 7:
                if t1.minute >= 40:
                    self.b.set_light(4, 'on', False)
                else:
                    self.b.set_light(4, 'on', True)

            elif t1.hour == 17:
                if t1.minute <= 45:
                    self.b.set_light(4, 'on', False)
                else:
                    self.b.set_light(4, 'on', True)

            else:
                self.b.set_light(4, 'on', True)
            t = Timer(5, self.sunWhite)
            t.start()

        else:

            t = Timer(5, self.sunWhite)
            t.cancel()

    def snowy(self):
        self.nl.set_color(WHITE)
        return

    def rainy(self):
        self.nl.set_color((30, 144, 255))
        return

    def sunny(self):
        self.nl.set_color((ORANGE))
        return

    def cloudy(self):
        self.nl.set_color((135, 206, 235))
        return

    def tempControl(self):
        try:
            if self.aV2 == True and self.nl.get_power() == True:
                url = 'http://api.openweathermap.org/data/2.5/weather?id=5946768&appid=authentication token'  #Real token was removed by authors for protecting security
                json_data = requests.get(url).json()
                temp = json_data['main']['temp']
                cel = float(temp) - 273.15
                '''content=GridLayout(cols=1)
                content_admit=Button(text='OK')
                content.add_widget(Label(text='Temperature is: '+str(cel)+'°C'))
                content.add_widget(content_admit)
                popup = Popup(title='Message',content=content,auto_dismiss=False)
                content_admit.bind(on_release=popup.dismiss)
                popup.open()'''
                if (temp >= 303.15):
                    self.extreme()
                elif (temp >= 293.15 and temp < 303.15):
                    self.hot()
                elif (temp >= 283.15 and temp < 293.15):
                    self.medium()
                elif (temp >= 273.15 and temp < 283.15):
                    self.chilly()
                elif (temp >= 263.15 and temp < 273.15):
                    self.cold()
                elif (temp >= 253.15 and temp < 263.15):
                    self.freezing()
                else:
                    pass
                t = Timer(5, self.tempControl)
                t.start()
            else:
                t = Timer(5, self.tempControl)
                t.cancel()
        except AttributeError:
            content = GridLayout(cols=1)
            content.add_widget(
                Label(text='Please connect to nanoleaf at first'))
            content_admit = Button(text='OK')
            content.add_widget(content_admit)
            popup = Popup(title='Message', content=content, auto_dismiss=False)
            content_admit.bind(on_release=popup.dismiss)
            popup.open()

    def extreme(self):
        self.nl.set_color(RED)
        return

    def hot(self):
        self.nl.set_color(ORANGE)
        return

    def medium(self):
        self.nl.set_color(YELLOW)
        return

    def chilly(self):
        self.nl.set_color(GREEN)
        return

    def cold(self):
        self.nl.set_color((0, 255, 255))
        return

    def freezing(self):
        self.nl.set_color(BLUE)
        return

    def on_value3(self, brightness):
        self.labValue = "%d" % brightness
        self.b.set_light(2, 'bri', int(self.labValue))

    def on_value4(self, brightness):
        self.bedValue = "%d" % brightness
        self.b.set_light(1, 'bri', int(self.bedValue))

    def on_value5(self, brightness):
        self.livingValue = "%d" % brightness
        self.b.set_light(3, 'bri', int(self.livingValue))

    def on_value6(self, brightness):
        self.whiteValue = "%d" % brightness
        self.b.set_light(4, 'bri', int(self.whiteValue))

    def lab_on(self, *args):
        try:
            self.b.set_light(2, 'on', True)
        except phue.PhueRequestTimeout:
            content = GridLayout(cols=1)
            content.add_widget(
                Label(text='Please connect to philips  at first'))
            content_admit = Button(text='OK')
            content.add_widget(content_admit)
            popup = Popup(title='Message', content=content, auto_dismiss=False)
            content_admit.bind(on_release=popup.dismiss)
            popup.open()

    def lab_off(self, *args):
        self.b.set_light(2, 'on', False)

    def lab_up(self, *args):
        brightness = self.b.get_light(2, 'bri')
        if self.b.get_light(2, 'on') == True and brightness < 238:
            self.b.set_light(2, 'bri', brightness + 17)

    def lab_down(self, *args):
        brightness = self.b.get_light(2, 'bri')
        if self.b.get_light(2, 'on') == True and brightness > 17:
            self.b.set_light(2, 'bri', brightness - 17)

    def bed_on(self, *args):
        self.b.set_light(1, 'on', True)

    def bed_off(self, *args):
        self.b.set_light(1, 'on', False)

    def bed_up(self, *args):
        brightness = self.b.get_light(1, 'bri')
        if self.b.get_light(1, 'on') == True and brightness < 238:
            self.b.set_light(1, 'bri', brightness + 17)

    def bed_down(self, *args):
        brightness = self.b.get_light(1, 'bri')
        if self.b.get_light(1, 'on') == True and brightness > 17:
            self.b.set_light(1, 'bri', brightness - 17)

    def living_on(self, *args):
        self.b.set_light(3, 'on', True)

    def living_off(self, *args):
        self.b.set_light(3, 'on', False)

    def living_up(self, *args):
        brightness = self.b.get_light(1, 'bri')
        if self.b.get_light(3, 'on') == True and brightness < 238:
            self.b.set_light(3, 'bri', brightness + 17)

    def living_down(self, *args):
        brightness = self.b.get_light(3, 'bri')
        if self.b.get_light(3, 'on') == True and brightness > 17:
            self.b.set_light(3, 'bri', brightness - 17)

    def white_on(self, *args):
        self.b.set_light(4, 'on', True)

    def white_off(self, *args):
        self.b.set_light(4, 'on', False)

    def white_up(self, *args):
        brightness = self.b.get_light(4, 'bri')
        if self.b.get_light(4, 'on') == True and brightness < 238:
            self.b.set_light(4, 'bri', brightness + 17)

    def white_down(self, *args):
        brightness = self.b.get_light(4, 'bri')
        if self.b.get_light(4, 'on') == True and brightness > 17:
            self.b.set_light(4, 'bri', brightness - 17)

    def connect_hue(self, *args):
        self.b = Bridge('192.168.0.13')

    def callback1(self, *args):
        self.disabled = False

    def build(self):
        return Builder.load_string(kv)