Ejemplo n.º 1
0
 def onAlertMaxTimer(self):
     '''
     Called after the sirens (or whatever alert devices you use) have reached their time limit
     '''
     # Cancel alert devices, e.g. the sirens
     for alertDevice in self.alertDevices:
         sendCommandCheckFirst(alertDevice, OFF)
     self.log.debug(
         'Alert devices have been switched off due to they\'ve reached their time limit'
     )
def onArmingModeChange(zone, newArmingMode, oldArmingMode):
    '''
    This function will be called when there is a change of arming mode for a zone.
    oldArmingMode is None when initializing.
    '''
    if zone.zoneNumber == 1:
        if oldArmingMode is not None:
            Pushover.pushover(
                'An Alarm Zone arming mode change for ' + zone.name +
                ' triggered, new value is: ' + kw(ARMINGMODE, newArmingMode),
                PUSHOVER_DEF_DEV, PUSHOVER_PRIO['NORMAL'])

        if newArmingMode == ARMINGMODE['DISARMED']:
            sendCommandCheckFirst('Alarm_Status_Indicator_1', OFF)
            sendCommandCheckFirst('Wall_Plug_Bedroom_Fan', OFF)
            sayHello()
        elif newArmingMode == ARMINGMODE['ARMED_HOME']:
            sendCommandCheckFirst('Wall_Plug_Bedroom_Fan', ON)

        if newArmingMode != ARMINGMODE['DISARMED']:
            sendCommandCheckFirst('Alarm_Status_Indicator_1', ON)

    log.debug('Custom function: onArmingModeChange: ' +
              zone.name.decode('utf-8') + ' ---> ' +
              kw(ARMINGMODE, newArmingMode))
Ejemplo n.º 3
0
    def onEntryTimer(self):
        '''
        Called whenever the entry timer times out.
        '''
        self.setZoneStatus(ZONESTATUS['ALERT'])

        # We need to make some noise here!
        if not self.alarmTestMode:
            for alertDevice in self.alertDevices:
                sendCommandCheckFirst(alertDevice, ON)
            self.log.info('You should be able to hear the sirens now...')
        else:
            self.log.info('ALARM_TEST_MODE is activated. No sirens!')
        postUpdateCheckFirst('Z' + str(self.zoneNumber) + '_Alert_Max_Timer',
                             ON)
Ejemplo n.º 4
0
    def onEntryTimer(self):
        '''
        Called whenever the entry timer times out.
        '''
        # Double check that the zone status is tripped, we can probably remove this check later
        if self.getZoneStatus() not in [ZONESTATUS['TRIPPED']]:
            raise IdeAlarmError(
                'Entry Timer timed out but zone status is not tripped')
        self.setZoneStatus(ZONESTATUS['ALERT'])

        # We need to make some noise here!
        if not self.alarmTestMode:
            for alertDevice in self.alertDevices:
                sendCommandCheckFirst(alertDevice, ON)
            self.log.info('You should be able to hear the sirens now...')
        else:
            self.log.info('ALARM_TEST_MODE is activated. No sirens!')
        postUpdateCheckFirst('Z' + str(self.zoneNumber) + '_Alert_Max_Timer',
                             ON)
Ejemplo n.º 5
0
    def setZoneStatus(self,
                      newZoneStatus,
                      sendCommand=False,
                      errorMessage=None):
        '''
        Sets the zones current status
        '''
        if newZoneStatus not in [
                ZONESTATUS['NORMAL'], ZONESTATUS['ALERT'], ZONESTATUS['ERROR'],
                ZONESTATUS['TRIPPED'], ZONESTATUS['ARMING']
        ]:
            raise IdeAlarmError('Trying to set an invalid zone status')
        oldZoneStatus = self._zoneStatus
        self._zoneStatus = newZoneStatus

        if newZoneStatus in [ZONESTATUS['NORMAL']]:

            # Cancel all timers so they won't fire
            postUpdateCheckFirst('Z' + str(self.zoneNumber) + '_Entry_Timer',
                                 OFF)
            postUpdateCheckFirst('Z' + str(self.zoneNumber) + '_Exit_Timer',
                                 OFF)
            postUpdateCheckFirst(
                'Z' + str(self.zoneNumber) + '_Alert_Max_Timer', OFF)

            # Cancel sirens
            for alertDevice in self.alertDevices:
                sendCommandCheckFirst(alertDevice, OFF)

        # Sync the Zone Status Item
        postUpdateCheckFirst(self.statusItem, newZoneStatus, sendCommand)

        # Call custom function if available
        if 'onZoneStatusChange' in dir(custom):
            custom.onZoneStatusChange(self,
                                      newZoneStatus,
                                      oldZoneStatus,
                                      errorMessage=errorMessage)