def on_remote_alarm():
     '''
     If this clients server or other clients has an alarm
     turn on this device siren
     '''
     if steelsquid_utils.get_flag("alarm_security") and steelsquid_utils.get_flag("alarm_remote_siren"):
         alarm_for_seconds = int(steelsquid_utils.get_parameter("alarm_security_seconds"))
         GLOBAL.siren(True)
         steelsquid_utils.execute_delay(alarm_for_seconds, GLOBAL.siren, ((False),))
def clear(wait=0, address=0x70):
    '''
    Clear all leds
    Wait wait number of seconds before clear
    '''
    if wait==0:
        for i in range(0x10):
            steelsquid_i2c.write_8_bit(address, i, 0x00)    
    else:
        steelsquid_utils.execute_delay(wait, clear, (0, address,))
Example #3
0
def clear(wait=0, address=0x70):
    '''
    Clear all leds
    Wait wait number of seconds before clear
    '''
    if wait == 0:
        for i in range(0x10):
            steelsquid_i2c.write_8_bit(address, i, 0x00)
    else:
        steelsquid_utils.execute_delay(wait, clear, (
            0,
            address,
        ))
def animate_typing(status, rotate=2, address=0x70):
    '''
    Animate a typing icon
    status = boolean: start or stop animation
    status = int: aimate for this number of seconds
    '''
    global leav_this_on_stop
    leav_this_on_stop = None
    if type(status) == types.BooleanType:
        if status:
            animate_start(matrix_animate_typing, rotate, 0.2)
        else:
            animate_stop()
    else:
        animate_start(matrix_animate_typing, rotate, 0.2)
        steelsquid_utils.execute_delay(status, animate_stop)
Example #5
0
def animate_typing(status, rotate=3, address=0x70):
    '''
    Animate a typing icon
    status = boolean: start or stop animation
    status = int: aimate for this number of seconds
    '''
    global leav_this_on_stop
    leav_this_on_stop = None
    if type(status) == types.BooleanType:
        if status:
            animate_start(matrix_animate_typing, rotate, 0.2)
        else:
            animate_stop()
    else:
        animate_start(matrix_animate_typing, rotate, 0.2)
        steelsquid_utils.execute_delay(status, animate_stop)
def animate_connect(status, rotate=2, address=0x70):
    '''
    Animate a connect
    status = boolean: start or stop animation
    status = int: aimate for this number of seconds
    leav_this = Do not clear, paint this instead
    '''
    global leav_this_on_stop
    leav_this_on_stop = None
    if type(status) == types.BooleanType:
        if status:
            animate_start(matrix_animate_connect, rotate, 0.1)
        else:
            animate_stop()
    else:
        animate_start(matrix_animate_connect, rotate, 0.1)
        steelsquid_utils.execute_delay(status, animate_stop)
Example #7
0
def animate_wait(status, rotate=3, address=0x70):
    '''
    Animate a wait clock
    status = boolean: start or stop animation
    status = int: aimate for this number of seconds
    leav_this = Do not clear, paint this instead
    '''
    global leav_this_on_stop
    leav_this_on_stop = None
    if type(status) == types.BooleanType:
        if status:
            animate_start(matrix_animate_wait, rotate, 0.1)
        else:
            animate_stop()
    else:
        animate_start(matrix_animate_wait, rotate, 0.1)
        steelsquid_utils.execute_delay(status, animate_stop)
def animate_speak(status, leav_this=None, rotate=2, address=0x70):
    '''
    Animate a speaking mouth
    status = boolean: start or stop animation
    status = int: aimate for this number of seconds
    leav_this = Do not clear, paint this instead
    '''
    global leav_this_on_stop
    leav_this_on_stop = leav_this
    if type(status) == types.BooleanType:
        if status:
            animate_start(matrix_animate_speak, rotate, 0.14)
        else:
            animate_stop()
    else:
        animate_start(matrix_animate_speak, rotate, 0.14)
        steelsquid_utils.execute_delay(status, animate_stop)
 def control(parameters):
     '''
     A request from client to change controll method 
     (radio/wifi/4G)
     '''
     con = int(parameters[0])
     code = parameters[1]
     if (con == 1 or con == 2 or con == 3) and code == "1234567":
         SETTINGS.control = con
         if SETTINGS.control==1:
             steelsquid_kiss_global.radio_switch(steelsquid_kiss_global.TYPE_HMTRLRS)
         else:
             steelsquid_kiss_global.radio_switch(steelsquid_kiss_global.TYPE_TCP)
         steelsquid_kiss_global.save_module_settings()
         steelsquid_utils.execute_delay(2, UTILS.set_net_status, (con, ))
         steelsquid_kiss_global.restart(delay=4)
         return []
     else:
         raise Exception("Command error")
 def control(parameters):
     '''
     A request from client to change controll method 
     (radio/wifi/4G)
     '''
     con = int(parameters[0])
     code = parameters[1]
     if (con == 1 or con == 2 or con == 3) and code == "1234567":
         SETTINGS.control = con
         if SETTINGS.control == 1:
             steelsquid_kiss_global.radio_switch(
                 steelsquid_kiss_global.TYPE_HMTRLRS)
         else:
             steelsquid_kiss_global.radio_switch(
                 steelsquid_kiss_global.TYPE_TCP)
         steelsquid_kiss_global.save_module_settings()
         steelsquid_utils.execute_delay(2, UTILS.set_net_status,
                                        (con, ))
         steelsquid_kiss_global.restart(delay=4)
         return []
     else:
         raise Exception("Command error")
 def on_motion(pin, status):
     '''
     Execute on motion
     '''
     GLOBAL.motion_detected = status 
     if steelsquid_utils.get_flag("alarm_security"):
         nr_of_movments = int(steelsquid_utils.get_parameter("alarm_security_movments"))
         movments_under_time = int(steelsquid_utils.get_parameter("alarm_security_movments_seconds"))
         alarm_for_seconds = int(steelsquid_utils.get_parameter("alarm_security_seconds"))
         alarm_security_wait = int(steelsquid_utils.get_parameter("alarm_security_wait"))
         activate_siren = steelsquid_utils.get_flag("alarm_security_activate_siren")
         alarm_security_send_mail = steelsquid_utils.get_flag("alarm_security_send_mail")
         if status==True and GLOBAL.alarm_triggered==False:
             #Activate IR-lamp for 2 minute
             if not GLOBAL.lamp():
                 GLOBAL.lamp(True)
                 steelsquid_utils.execute_delay(120, GLOBAL.lamp, ((False),))
             now = datetime.now()
             delta = now - GLOBAL.last_trigger
             if delta.total_seconds() > alarm_security_wait:
                 if GLOBAL.last_move == 0:
                     GLOBAL.last_move = datetime.now()                
                 delta = now - GLOBAL.last_move
                 if delta.total_seconds()<movments_under_time:
                     GLOBAL.counter=GLOBAL.counter+1
                 else:
                     GLOBAL.counter=0
                     GLOBAL.last_move = 0
                 if GLOBAL.counter>=nr_of_movments:
                     GLOBAL.alarm_triggered=True
                     GLOBAL.last_trigger=datetime.now() 
                     if activate_siren:
                         GLOBAL.siren(True)
                     if alarm_security_send_mail:
                         GLOBAL.send_mail()
                     steelsquid_utils.execute_delay(alarm_for_seconds, GLOBAL.turn_off_alarm, None)