Ejemplo n.º 1
0
def DisarmZone():
    # Routine to arm a zone
    global RemoteZoneDescription
    TempBuffer = []
    TempBuffer.append(RemoteZoneDescription)
    rt = UpdateHost(19, TempBuffer)
    return (0)
Ejemplo n.º 2
0
def NotifyHostEvent(z, status):
    global GPIOList
    global Locations

    # Notify the host that an IO was switched (e.g. door open)
    HostEvent = []
    HostEvent.append(GPIOList[z])
    HostEvent.append(status)
    if globals.LCDAlarmActivity == True:
        #SendToLcd receives an array of 7 values
        #RecordSet[0] : GPIO_Pin_Number
        #RecordSet[1] : Location
        #RecordSet[2] : Display Message
        #RecordSet[3] : type 1=Switch Open, 2=Switch Closed, 3=Temperature, 4=Temperature & Humidity, 5=Free format String, 6=Arm/Disarm, 7=Log
        #RecordSet[4] : Tempeature Value
        #RecordSet[5] : Humidity Value
        #RecordSet[6] : Unit of measure, 0=Centigrade, 1=Fahrenheit
        #RecordSet[7] : Armed/Disarmed 1=Armed, 2=Disarmed
        #RecordSet[8] : DateTime

        if status == 0: switch = 2
        else: switch = 1
        SendToLCD([GPIOList[z], Locations[z], 0, switch, 0, 0, 0, 0, 0])
    rt = UpdateHost(26, HostEvent)
    if rt == 3:
        if globals.LCDAlarmActivity == True:
            SendToLCD([GPIOList[z], Locations[z], 0, 8, 0, 0, 0, 0, 0])
        return (True)
    else:
        return (False)
Ejemplo n.º 3
0
def NotifyHostEvent(GPIOnumber, status):
    # Notify the host that an IO was switched (e.g. door open)
    HostEvent = []
    HostEvent.append(GPIOnumber)
    HostEvent.append(status)
    rt = UpdateHost(26, HostEvent)
    if rt:
        return (True)  # Process email action
    else:
        return (False)
Ejemplo n.º 4
0
def DisarmZone():
    # Routine to arm a zone
    TempBuffer = []
    TempBuffer.append(globals.RemoteZoneDescription)
    rt = UpdateHost(19, TempBuffer)
    if globals.LCDAlarmActivity == True:
        #SendToLcd receives an array of 7 values
        #RecordSet[7] : Armed/Disarmed 1=Armed, 2=Disarmed
        SendToLCD([0, 0, 0, 0, 0, 0, 0, 2])
    return (0)
Ejemplo n.º 5
0
def NotifyHostTemperature():
    numtemp = len(globals.DallasSensorNumbers)
    rt2 = False
    for z in range(0, numtemp, 1):
        TempBuffer = []
        TempBuffer.append(GetTemperature(z))
        if globals.Farenheit:
            TempBuffer.append(1)
        else:
            TempBuffer.append(0)
        TempBuffer.append(globals.DallasSensorNumbers[z])
        UpdateHost(14, TempBuffer)
    return (0)
Ejemplo n.º 6
0
def InitializeHostGPIO():
    global GPIOList

    SensorList = []
    SensorList.append(0)
    y = 0
    for x in AlarmActioned:
        SensorList.append(GPIOList[y])
        SensorList.append(AlarmActioned[y])
        y = y + 1
    SensorList[0] = y
    # Send the status of the pins to the server
    rt = UpdateHost(23, SensorList)
Ejemplo n.º 7
0
def NotifyHost():
    global temp
    global humidity

    TempBuffer = []
    rt = GetData()
    if rt == False:  #fail
        return (0)
    TempBuffer.append(globals.dht22_gpio)
    TempBuffer.append(temp)
    if globals.Farenheit:
        TempBuffer.append(1)
    else:
        TempBuffer.append(0)
    UpdateHost(37, TempBuffer)

    HumBuffer = []
    HumBuffer.append(globals.HUMPrefix + str(globals.dht22_gpio))
    HumBuffer.append(humidity)
    HumBuffer.append(2)
    UpdateHost(37, HumBuffer)

    return (0)
Ejemplo n.º 8
0
def NotifyHostTemperature():
    numtemp = len(globals.DallasSensorNumbers)
    rt2 = False
    for z in range(0, numtemp, 1):
        TempBuffer = []
        temperature_reading = GetTemperature(globals.Farenheit,
                                             globals.DallasSensorDirectory[0])
        TempBuffer.append(temperature_reading)
        if globals.Farenheit:
            TempBuffer.append(1)
        else:
            TempBuffer.append(0)
        TempBuffer.append(globals.DallasSensorNumbers[z])
        UpdateHost(14, TempBuffer)
    return (0)
Ejemplo n.º 9
0
def NotifyHost():
    global temp
    global humidity

    TempBuffer = []
    rt = GetData()
    if rt == False:  #fail
        return (0)
    TempBuffer.append(temp)
    if globals.Farenheit:
        TempBuffer.append(1)
    else:
        TempBuffer.append(0)
    TempBuffer.append(globals.dht22_pin_no)
    TempBuffer.append(humidity)
    UpdateHost(14, TempBuffer)
    return (0)
Ejemplo n.º 10
0
def ProcessMessage(value, value2, DevId, type):
    # Notify the host that there is new data from a sensor (e.g. door open)
    global numrf
    global RFList

    hostdata = []

    #Send switch sensor value to host
    if type == 1:
        button = value[1]
        value = value[2:]
        # If button B is pressed then we need to map the device ID to the button B sensor defined on the server
        if button == "B":
            tempId = int(DevId)
            DevId = 0
            for z in range(0, len(globals.ButtonBList)):
                if globals.ButtonBList[z] == tempId:
                    DevId = globals.ButtonBId[z]
        for z in range(0, numrf, 1):
            if RFList[z] == int(DevId):
                hostdata.append(RFList[z])
                if value == 'OF' or value == 'OFF':
                    hostdata.append(1)
                    rt = UpdateHost(26, hostdata)
                if value == 'ON':
                    hostdata.append(0)
                    rt = UpdateHost(26, hostdata)
    #Send battery level to host
    if type == 2:
        for z in range(0, numrf, 1):
            if RFList[z] == int(DevId):
                hostdata.append(DevId)
                hostdata.append(value)
                MaxVoltage = 3
                for z in range(0, len(globals.VoltageList)):
                    if globals.VoltageList[z] == int(DevId):
                        MaxVoltage = globals.MaxVoltage[z]
                hostdata.append(MaxVoltage)
                rt = UpdateHost(22, hostdata)

    #Send temperature to host
    if type == 3:
        for z in range(0, numrf, 1):
            if RFList[z] == int(DevId):
                if globals.Farenheit:
                    value = value * 1.8 + 32
                    value = round(value, 2)
                hostdata.append(value)
                if globals.Farenheit:
                    hostdata.append(1)
                else:
                    hostdata.append(0)
                hostdata.append(DevId)
                rt = UpdateHost(14, hostdata)

    #Send humidity to host
    if type == 4:
        for z in range(0, numrf, 1):
            if RFList[z] == int(DevId):
                if globals.Farenheit:
                    value = value * 1.8 + 32
                    value = round(value, 2)
                hostdata.append(value)
                if globals.Farenheit:
                    hostdata.append(1)
                else:
                    hostdata.append(0)
                hostdata.append(DevId)
                hostdata.append(value2)
                rt = UpdateHost(14, hostdata)
    return (0)