예제 #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, scope.OFF)
     self.log.debug(
         'Alert devices have been switched off due to they\'ve reached their time limit'
     )
예제 #2
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, scope.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{}_Alert_Max_Timer".format(self.zoneNumber),
                             scope.ON)
예제 #3
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{}_Entry_Timer".format(self.zoneNumber),
                                 scope.OFF)
            postUpdateCheckFirst("Z{}_Exit_Timer".format(self.zoneNumber),
                                 scope.OFF)
            postUpdateCheckFirst("Z{}_Alert_Max_Timer".format(self.zoneNumber),
                                 scope.OFF)

            # Cancel sirens
            for alertDevice in self.alertDevices:
                sendCommandCheckFirst(alertDevice, scope.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)
예제 #4
0
파일: update.py 프로젝트: CrazyIvan359/eos
def update_light(item, scene=None):
    """
    Sends commands to lights based on scene.
    """
    if str(get_value(item.name, META_NAME_EOS)).lower() in META_STRING_FALSE:
        if config.log_trace:
            log.debug(
                "Skipping update for light '{name}' as it is disabled".format(
                    name=item.name
                )
            )
        return
    elif config.log_trace:
        log.debug("Processing update for light '{name}'".format(name=item.name))

    scene = scene if scene and scene != SCENE_PARENT else get_scene_for_item(item)
    if config.log_trace:
        log.debug(
            "Got scene '{scene}' for item '{name}'".format(scene=scene, name=item.name)
        )

    if scene != SCENE_MANUAL:
        newState = get_state_for_scene(item, scene)
        if sendCommandCheckFirst(item.name, newState, floatPrecision=3):
            log.debug(
                "Light '{name}' scene is '{scene}', sent command '{command}'".format(
                    name=item.name, scene=scene, command=newState
                )
            )
        else:
            log.debug(
                "Light '{name}' scene is '{scene}', state is already '{command}'".format(
                    name=item.name, scene=scene, command=newState
                )
            )
    else:
        log.debug(
            "Light '{name}' scene is '{scene}', no action taken".format(
                name=item.name, scene=scene
            )
        )
예제 #5
0
def nefitStatus(event):
    httpHeader = {
        'Content-Type': 'application/json'
    }  #,'Cache-Control': 'no-cache','Pragma': 'no-cache'}
    #--- Get Nefit thermostat info from the easy-server API
    response = requests.get(NEFIT_API_URL + "/status", headers=httpHeader)
    if response.status_code != 200:
        nefitStatus.log.warn(
            "NefitEasy - Invalid API status response [{}]".format(response))
    else:
        #-- Get the relevant parameters ('in house temp' and 'temp setpoint') from the JSON response.
        try:
            events.postUpdate(
                "CV_Temp_Livingroom",
                "{0:.1f}".format(response.json()["in house temp"]))
        except:
            nefitStatus.log.warn(
                "Error setting in house temp; JSON response [{}]".format(
                    response.json()))
        try:
            events.postUpdate(
                "CV_SetPoint_Livingroom",
                "{0:.1f}".format(response.json()["temp setpoint"]))
        except:
            nefitStatus.log.warn(
                "Error setting setpoint temp; JSON response [{}]".format(
                    response.json()))
    #--- Get Nefit Heater water pressure
    response = requests.get(NEFIT_BRIDGE_URL +
                            "/system/appliance/systemPressure",
                            headers=httpHeader)
    if response.status_code != 200:
        nefitStatus.log.warn(
            "NefitEasy - Invalid API pressure response [{}]".format(response))
    else:
        try:
            events.postUpdate("CV_Pressure",
                              "{0:.1f}".format(response.json()['value']))
            events.sendCommand("CV_Watchdog", "ON")
        except:
            nefitStatus.log.warn(
                "Error setting Nefit water pressure; JSON response [{}]".
                format(response.json()))
    #--- Get Nefit CV burner data
    response = requests.get(NEFIT_BRIDGE_URL + "/ecus/rrc/uiStatus",
                            headers=httpHeader)
    if response.status_code != 200:
        nefitStatus.log.warn(
            "NefitEasy - Invalid API burner status response [{}]".format(
                response))
    else:
        # Extract the relevant info from the JSON data
        try:
            burner = response.json()['value']['BAI']
        except:
            nefitStatus.log.warn(
                "Error reading Nefit burner status; JSON response [{}]".format(
                    response.json()))
            burner = "No"
        if burner == "CH":
            sendCommandCheckFirst("CV_Heater_Active", "ON")
            sendCommandCheckFirst("CV_HotWater_Active", "OFF")
        elif burner == "HW":
            sendCommandCheckFirst("CV_Heater_Active", "OFF")
            sendCommandCheckFirst("CV_HotWater_Active", "ON")
        else:
            sendCommandCheckFirst("CV_Heater_Active", "OFF")
            sendCommandCheckFirst("CV_HotWater_Active", "OFF")