Tertiush / ParadoxIP150v2

Python-based IP150 'middle-ware' that uses the IP module's software port for monitoring and control of the alarm via an MQTT Broker.
Eclipse Public License 1.0
73 stars 35 forks source link

Request - Command for zone bypass #39

Open johnym30 opened 5 years ago

johnym30 commented 5 years ago

Is there a command to issue a zone bypass?

Tertiush commented 5 years ago

Hi,

No not yet. But if someone wants to add that functionality here's the code Alarmin uses to do just that (in NodeJS).

     // alarmType = 0: non-EVO; =1: EVO. toggleBypass = Zone

function toggleBypass(toggleBypass, onOff /*on=1, off=0*/) {
    if (alarmType == 0) {
        header = new Uint8Array([0xaa, 0x25, 0x00, 0x04, 0x08, 0x00, 0x00, 0x14, 0xee, 0xee, 0xee, 0xee, 0xee, 0xee, 0xee, 0xee]);
        message = new Uint8Array([0x40, 0x00, 0x10, toggleBypass]);
        messageToSend = format37ByteMessage(message)
        packet = joinUint8Arrays(header, messageToSend)

        sendData(packet, 1)
        })
    }
    else if (alarmType == 1) {

        header = new Uint8Array([0xaa, 0x27, 0x00, 0x04, 0x08, 0x00, 0x00, 0x14, 0xee, 0xee, 0xee, 0xee, 0xee, 0xee, 0xee, 0xee]);

        if (onOff == 1)
            var onOffByte = 0x08    //to bypass
        else if (onOff == 0)
            var onOffByte = 0x00    //to un-bypass

        message = new Uint8Array([0xd0, 0x27, 0x08, onOffByte, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 ])    //0x40, 0x00, 0x10, toggleBypass])

        var byteVal = Math.pow(2, (toggleBypass - 8 * (~~(toggleBypass / 8))))  // => pow(2, index - 8*(index div 8)

        var byteLoc = (Math.floor(toggleBypass / 8)) + 6

        message[byteLoc] = byteVal

        messageToSend = format39ByteMessage(message)
        packet = joinUint8Arrays(header, messageToSend)

        sendData(packet, 1)
}

`