new ZiBase(ipAddr, deviceId, token, callback)
Parameters:
Name | Type | Description |
---|---|---|
ipAddr |
string | IP address of the zibase |
deviceId |
string | Device ID of the zibase |
token |
string | Token of the zibase |
callback |
function | Callback to call when the connection to the zibase is established. |
Extends
- events.EventEmitter
Methods
-
deregisterListener()
-
Asks the Zibase to unregister the caller client
-
getDescriptor(id)
-
retrieves the descriptor with a given id
Parameters:
Name Type Description id
string ID of the descriptor to retrieve
-
getSensorInfo(idSensor, callback)
-
retrieves the information about a given sensor
Parameters:
Name Type Description idSensor
string ID of the sensor
callback
function Callback to be called when the info is retrieved
-
getState(adress, callback)
-
Gets the state of an activator from the Zibase
Parameters:
Name Type Description adress
string X10 formatted address of the activator
callback
function Callback to be called when the state is received
-
getVariable(numVar, callback)
-
Get the value of a Vx variable of the Zibase
Parameters:
Name Type Description numVar
int number of the variable (0 to 31)
callback
function Callback to be called when the value is retrieved
-
loadDescriptors(cb)
-
Loads the descriptors of declared devices and scenarios
Parameters:
Name Type Description cb
function Callback to be called when the descriptors are loaded
-
on(event [, id], callback)
-
listens to events
Parameters:
Name Type Argument Description event
string Event to be listened to
id
string <optional>
The ID of the device that triggers the event. Don't specify any when the event is triggered by the zibase
callback
function Callback to be called when the event is triggered. The parameters of the callback depend on the event
-
once(event [, id], callback)
-
same as method on but only for one event
Parameters:
Name Type Argument Description event
string Event to be listened to
id
string <optional>
The ID of the device that triggers the event. Don't specify any when the event is triggered by the zibase
callback
function Callback to be called when the event is triggered. The parameters of the callback depend on the event
-
processZiBaseData(response)
-
process the information messages sent by the zibase.
Emits events depending on the content of the response.Parameters:
Name Type Description response
Response A response to process, as sent by the zibase
-
registerListener(port)
-
Asks the Zibase to register the caller client as a listener.
After this call, the Zibase will send its activity log to the caller, on the given port.Parameters:
Name Type Description port
int The port to listen in order to receive the messages
-
runScenario(scenario)
-
Asks the zibase to run the scenario specified by its number
Parameters:
Name Type Description scenario
int | string the scenario number or name
Returns:
false if scenario doesn't resolve to a scenario number
- Type
- boolean
-
sendCommand(address, action, protocol, dimLevel, nbBurst)
-
Ask the zibase to send a command to an activator specified by its ID and protocol
Parameters:
Name Type Description address
string Address of the activator in X10 format (e.g. B5)
action
ZbAction Action to execute
protocol
ZbProtocol Protocol RF to be used
dimLevel
int Not supported by the Zibase for now
nbBurst
int Number of RF emissions
-
sendRequest(request, withResponse, callback)
-
Sends a request to the zibase
Parameters:
Name Type Description request
ZbRequest Request to be sent
withResponse
boolean Indicates if a response is to be expected
callback
function Callback to be called when the response is received
-
setEvent(action, address)
-
Positions a Zibase alert to the state ON or OFF, or simulates a sensor ID message in the activity log of the Zibase
Parameters:
Name Type Description action
int The action: 0 - deactivate an alert, 1 - activate an alert, 2 - simulate a sensor ID message (can trigger the execution of a scenario)
address
string Address of the activator in X10 format (e.g. B5 or ZA14)