[Example] Using SiPass Cardholder Properties in a Script

On a management platform that integrates SiPass access control, you want to write a script that automatically performs certain actions (for example, unlocks the door, turns on the lights, or activates the fan coil) when a specified person badges through. Requires Scripts extension and license.

  • System Manager is in Engineering mode.
  1. In System Browser, select Application View.
  1. Select Applications > Logics > Scripts.
  • The Script Editor tab displays.
  1. In the Editor expander, enter or modify the script code to achieve the desired automations based on the cardholder properties.
  • You can copy and paste code into this area: Refer to the code sample provided below, and modify it as needed.
  • You can also drag objects from System Browser into the Script Editor tab.
  • The Error List expander displays any detected syntax errors as you type.
  1. Fix any errors reported in the Error List expander. You can use the following controls to help you examine the code:
  • Click Expand names to expand a block of text to modify.
  • Click Display line numbers to display line numbers.
  • Use CTRL+F to jump to a specific line number.
  1. Click Save As .
  1. In the Save Object As dialog box, select the main Scripts folder or any subfolder under it as the destination where you want to save the new script:
    a. Enter a name and description.
    b. Click OK.
  • The new script objects is available in System Browser, and is enabled by default.

Related Topics

For more detailed instructions on writing and configuring scripts search for Scripts.

Code Sample for SiPass Access Control

What: When on Eri Reader 1 there is a cardholder transaction of this badge: Number_ID xx with first name yy and Last name aa, pass on the ERI reader 2 will be unlocked.

// Strict mode makes it easier to write "secure" code, introducing better error-checking

'use strict';

/*

* Press CTRL+Space for suggestion on the commands you can use.

*/

var properties = ["CardholderIDReader1","CardholderFirstNameReader1","CardholderLastNameReader1"];

//Subscribe to Eri1 Door

subscribeValues("System1.ManagementView:ManagementView.FieldNetworks.SipassNet1.SS69.ACDevices.Device_1.ACDoors.Door_1_5", properties,OnValueChange, true, false);

function OnValueChange(object, values)

{

    var CardholderIDReader1 = values["CardholderIDReader1"].value.value;

    var CardholderFirstNameReader1 = values["CardholderFirstNameReader1"].value.value;

    var CardholderLastNameReader1 = values["CardholderLastNameReader1"].value.value;

    console ("Values CardholderId: [" + CardholderIDReader1 + "]\nFirst Name: [" + CardholderFirstNameReader1 + "]\nLast Name: ["+ CardholderLastNameReader1 + "]");

    if(CardholderIDReader1 == 3708748863 ||

CardholderFirstNameReader1 == "Riccardo" &&

CardholderLastNameReader1 == "Colombo")

    {

        console("Executing the command");

        var result = executePropertyCommand("System1.ManagementView:ManagementView.FieldNetworks.SipassNet1.SS69.ACDevices.Device_1.ACDoors.Door_2_5", "Latch_State", "Unlock");

        console("Result: " + result);

    }

}