Skip to content

zWay JS Extension

Andreas Drollinger edited this page Nov 8, 2019 · 4 revisions

z-Way extension for THC

The file thc_zWay.js of the module thc_zWay implements some functions for the z-Way server that are used by THC. The defined functions are accessible via the z-Way HTTP interface.

This file is automatically loaded to the z-Way server by the thc_zWay module.


Function: Get_Virtual

Returns the virtual device state

Parameters

Parameters Description
NI Virtual device identifier

Returns

Virtual device status

Examples

 http://192.168.1.21:8083/JS/Run/Get_Virtual("DummyDevice_bn_5")
 -> 1

See also

Set_Virtual


Function: Set_Virtual

Sets the virtual device state

Parameters

Parameters Description
NI Virtual device identifier
state New state

Returns

Virtual device status

Examples

 http://192.168.1.21:8083/JS/Run/Set_Virtual("DummyDevice_bn_5",1)
 -> 1

See also

Get_Control


Function: Configure_TagReader

Configures audible notification for tag reader. This function binds the alarm notification to a binary switch Set(1) function which will issue an audible notification on a tag reader each time a valid code has been entered.

Configure_TagReader defines the following bindings (for device 22)

 http://192.168.1.21:8083/JS/Run/zway.devices[22].Alarm.data[6][5].status.bind( function() {zway.devices[22].SwitchBinary.Set(true); });
 http://192.168.1.21:8083/JS/Run/zway.devices[22].Alarm.data[6][6].status.bind( function() {zway.devices[22].SwitchBinary.Set(true); });

Parameters

Parameters Description
NI device identifier

Returns

-

Examples

 http://192.168.1.21:8083/JS/Run/Configure_TagReader(22)
 -> null

Function: TagReader_LearnLastCode

Learn the tag reader the last entered code. The tag reader will afterwards accept the new code as a valid one.

The following code learning sequence should be applied :

  • Using the 'Home' or 'Away' button, enter a new code or use a new unknown RFID tag.
  • Run the TagReader_LearnLastCode command. Provide a new UserId (=code storage location).
  • Wakeup the tag reader. This can happen by entering a valid or invalid code. The tag reader will receive from the controller the command to learn the new code.
  • Try now using the new code or the new RFID tag. The tag reader will recognize it as valid.

Parameters

Parameters Description
NI Device identifier
UserId User identifier (code storage location)

Returns

Information string if the code learning was successful or not

Examples

 http://192.168.1.21:8083/JS/Run/TagReader_LearnLastCode(22, 2)
 -> OK, registered code 52,52,52,52,52,52,0,0,0,0

See also

Configure_TagReader, TagReader_ResetCode


Function: TagReader_ResetCode

Reset one or all codes a tag reader knows. If no UserId is defined all codes are reset, otherwise only the code assigned to the UserId. After running this command the tag reader needs to be waked up to receive the command to perform the reset.

Parameters

Parameters Description
NI Device identifier
UserId User identifier (code storage location, optional)

Returns

-

Examples

 http://192.168.1.21:8083/JS/Run/TagReader_ResetCode(22) -> resets all codes
 http://192.168.1.21:8083/JS/Run/TagReader_ResetCode(22,3) -> resets the UserId specific code

See also

Configure_TagReader, TagReader_LearnLastCode


Function: Get

Get status from devices

Parameters

Parameters Description
DeviceList List of devices organized in an array. Each array element represents a device. A device is itself described by an array composed by the zWave command class, and the device identifier. The device identifier is provided by the zWay configuration utility. The identifier is composed by the device number, the instance number, and the data record. All numbers are separated by a dot (.).

Returns

Device statuses

Examples

 http://192.168.1.21:8083/JS/Run/Get([["Control","Surveillance"],["SwitchBinary",7.1],["SensorBinary",2],["TagReader",22],["Battery",22],["SensorMultilevel","5.0.1"]])
 -> [0,0,1,[1407694169,"unlock"],33,17.7]
 http://192.168.1.21:8083/JS/Run/Get([["Virtual","DummyDevice_bn_5"]])
 -> [0]
 http://192.168.1.21:8083/JS/Run/Get([["Control","Surveillance"],["Control","Alarm"],["SwitchBinary",20.1]])
 -> [0,0,0]

See also

Set


Function: Set

Set status for devices

Parameters

Parameters Description
DeviceList List of devices organized in an array. Each array element represents a device. A device is itself described by an array composed by the zWave command class, and the device identifier. The device identifier is provided by the zWay configuration utility. The identifier is composed by the device number, the instance number, and the data record. All numbers are separated by a dot (.).
State Device status, usually 0 or 1

Returns

Device state

Examples

 http://192.168.1.21:8083/JS/Run/Set([["Control","Surveillance"]],1)
 -> [1]
 http://192.168.1.21:8083/JS/Run/Set([["Virtual","DummyDevice_bn_5"]],1)
 -> [1]
 http://192.168.1.21:8083/JS/Run/Set([["SwitchBinary",20.1]],1)
 -> [1]

See also

Get