Ejemplo n.º 1
0
def disableAlarm(alarmIndex):

    # Try to grab the alarm in question

    success = 0

    if len(ci_config.alarms) >= alarmIndex:

        # error check

        thisAlarm = ci_config.alarms[alarmIndex]

        if ci_config.preferences['useAlarmD'] == 1:

            # We want to use AlarmD to manage alarms

            if int(thisAlarm['alarm_cookie']) > 0:
                result = clearFlipAlarm(int(thisAlarm['alarm_cookie']))

                if result:
                    print 'cleared ok'
                    ci_config.alarms[alarmIndex]['alarm_cookie'] = 0

        ci_config.alarms[alarmIndex]['enabled'] = 0

        # save the config

        ci_config.savePrefs()

        success = 1
    else:

        print 'No alarm for that index found!'

    # Update "next alarm" incase things have changed

    ci_alarm.nextAlarmUpToDate(1)

    return success
Ejemplo n.º 2
0
def enableAlarm(alarmIndex):

    # Try to grab the alarm in question

    success = 0

    if len(ci_config.alarms) >= alarmIndex:

        # error check

        thisAlarm = ci_config.alarms[alarmIndex]

        if int(thisAlarm['alarm_time']) > 0:
            if ci_config.preferences['useAlarmD'] == 1:

                # We want to use alarmD to manage alarms
                # dispatch alarm to alarmD
                # first, check to see if this alarm has been set in the past

                if int(thisAlarm['alarm_cookie']) > 0:
                    clearFlipAlarm(int(thisAlarm['alarm_cookie']))

                # Now we set the new alarm

                returnedCookie = setFlipAlarm(thisAlarm)

                if returnedCookie < 1:

                    # Failed!

                    print 'Failed to set alarm with alarmD!'
                else:
                    ci_config.alarms[alarmIndex]['alarm_cookie'] = \
                        int(returnedCookie)

                    # and now update the prefs array of alarms
                    # ci_config.alarms[alarmIndex]["alarm_cookie"] = returnedCookie

                    ci_config.alarms[alarmIndex]['enabled'] = 1

                    # save the config

                    ci_config.savePrefs()

                    success = 1
            else:

                # We want to manage alarms internally only (Ciro...this is you buddy)

                ci_config.alarms[alarmIndex]['enabled'] = 1

                # save the config

                ci_config.savePrefs()

                success = 1
        else:

            print 'Invalid alarm time, unable to set'
    else:

        print 'No alarm for that index found!'

    # Update "next alarm" incase things have changed

    ci_alarm.nextAlarmUpToDate(1)

    return success