This object is the JavaScript interface to a CommandFusion CFMini device. It inherits the functions and properties of CFLink.Device. If the object was built from a predefined structure (not by discovery) we may not have the description string at end, therefore can't extract the serial#, firmware and cflink version. This is not an issue when using the CFMini. To create a CFLink.CFMini object, you should use the CFLink.getDevices function as per the example below.
Example
// Obtain a CFMini object. We'll be talking to it through the external system named "CFLink".
// The CFMini device has CFLink ID 12.
var mini = CFLink.getDevice("CFLINK", CFLink.model.CFMini, "12");

// Now we can start using CFMini. For example, close relay number 1
mini.setRelayState(1, 1);
Members

<static, constant> CONFIGURATION_CHANGE :String

Event fired when the configuration of a CFMini was updated
Methods
configureInputOutputs ( enabled , reportOnChange , reportInterval )
Parameters:
Name Type Description
enabled Boolean pass 1 or true to enable I/O ports
reportOnChange Number pass 1 or true if I/O ports should report changes. Changes are reported on the CFLink bus through 'CHA' messages. You can catch I/O port value changes by watching the CFLink.IOPort.VALUE_CHANGE event, or using the CFLink.CFMini.watchIOPorts function.
reportInterval Number If reportOnChange enables change reporting, you can request that changes be reported at regular intervals, in 0.1s increments. Pass 0 to get change reports only when an actuall change occurs. Pass a positive value to have regular value reports posted on the bus. Note tat the CFLink.IOPort.VALUE_CHANGE event and the CFLink.CFMini.watchIOPorts function will trigger only when an actual change is seen (but the messages still flow on the bus, so they can be used to trigger automated actions by the use of Rules in other devices).
Configure CFMini behavior for I/O ports: enable or disable them altogether, determine whether they should report state change, and if yes, if they should send regular state change messages through the `reportInterval' parameter.
configureIOPort ( index , mode , minChange , powerOnState )
Parameters:
Name Type Description
index Number, Array the I/O port index (1-4) or an array of I/O port indices
mode CFLink.IOPort.Mode the mode to set for this I/O port
minChange Number for I/O ports that are set to digital input mode, the minimum expected change (voltage or resistance) to trigger a state change. Pass 0 to disable change reporting for this port altogether (remember that you can enable and disable change reporting globally using CFLink.CFMini.configureInputOutputs).
powerOnState
Configure an I/O port to set its operating mode, as well as minimum change value and power-on state (when applicable, depends on the chosen mode). Note that the command is being sent to the device, but the known values of the JavaScript representation of the port will stay the same until we receive the acknowledge from the device.

You can pass a single port number, or an array of port numbers to configure multiple I/O ports at once.
getIOPort ( index )
Parameters:
Name Type Description
index number index of the IO port (1-4)
Returns
an IOPort object
Type
CFLink.IOPort
Obtain the underlying CFLink.IOPort object associated with one of CFMini's IO ports (1-4) You should seldom need to call this function.
getRelayPort ( index )
Parameters:
Name Type Description
index number index of the Relay port (1-4)
Returns
an IOPort object. Use at your own risk, don't modify it.
Type
CFLink.IOPort
Obtain the underlying CFLink.IOPort object associated with one of CFMini's Relay ports (1-4) You should seldom need to call this function.
getRelayState ( index )
Parameters:
Name Description
index
Returns
0 if the relay is open, 1 if it is closed.
Type
Number
Obtain the actual state of one of the relay ports of this CFMini. The state this function returns is the last known state, as received on the CFLink bus. We don't requery the device (this would require an asynchronous callback).
pulseRelayState ( index , duration )
Parameters:
Name Type Description
index Number,Array the relay index (1-4) or an array of relay indices
duration
Pulse one of the relay ports of this CFMini (close it for the specified duration then open) If the relay was already closed, it will open at the end of the pulse duration

You can pass a single port number, or an array of port numbers to set to the same state (for example, to open or close multiple relays at once)
setIOPortValue ( index , value )
Parameters:
Name Type Description
index Number, Array the I/O port index (1-4) or an array of I/O port indices
value Number the new value of the output port (0 or 1)
For IO ports configured as external relay control output or LED output, set the value (0 = open for relays, off for LEDs - 1 = closed for relays, on for LEDs)

You can pass a single port number, or an array of port numbers to set the value of multiple I/O ports at once.
setRelayState ( index , state )
Parameters:
Name Type Description
index Number,Array the relay index (1-4) or an array of relay indices
state Number the new state (0=open, 1=closed)
Set the state of one of the relay ports of this CFMini.

You can pass a single port number, or an array of port numbers to set to the same state (for example, to open or close multiple relays at once)
toggleIOPortValue ( index )
Parameters:
Name Type Description
index Number, Array the I/O port index (1-4) or an array of I/O port indices
For IO ports configured as external relay control output or LED output, toggle (invert) the current state. This command is invalid when the I/O port is not in relay control output or LED output mode.

You can pass a single port number, or an array of port numbers to set the value of multiple I/O ports at once.
toggleRelayState ( index )
Parameters:
Name Type Description
index Number,Array the relay index (1-4) or an array of relay indices
Toggle the state of one of the relay ports of this CFMini.

You can pass a single port number, or an array of port numbers to set to the same state (for example, to open or close multiple relays at once)
unwatch ( watcherID )
Parameters:
Name Type Description
watcherID Number the watcher ID that was returned by CFLink.CFMini.watchIOPorts or CFLink.CFMini.watchRelays
Stop watching the changes you asked to be notified for in CFLink.CFMini.watchIOPorts and CFLink.CFMini.watchRelays. You could as well call CFLink.unwatch which does the same thing.
watchIOPorts ( portNumbers , callback , me )
Parameters:
Name Type Description
portNumbers Array an array of the port numbers to watch. Pass `null' to watch all ports
callback Function your callback function, of the form callback(cfmini_object, portNumber, value)
me Object the object to set as `this' when calling your callback function
Returns
a watcherID you can use to unwatch with CFLink.unwatch or CFLink.CFMini.unwatch (both are equivalent)
Type
Number
Setup a callback function that is called when the state of the selected IO port(s) change This is a simple helper that watches the CFLink.IOPort.VALUE_CHANGE event and only calls you back when one of the I/O ports you want to watch changes state. Your callback function should be of the form: myCallback(cfminiObject, portNumber, previousValue, newValue) Where `cfminiObject' is the CFLink.CFMini device object, `portNumber' is the I/O port number that changed state, `previousValue' is the previous value of this I/O port, and `newValue' is its new value. Note that when we get the initial value of the I/O port (at initialization time), the `previousValue' parameter will be -1.
watchRelays ( portNumbers , callback , me )
Parameters:
Name Type Description
portNumbers Array an array of the relay port numbers to watch (relays are numbered from 1 to 4). Pass `null' to watch all relays. Passing a single port number is also accepted.
callback Function your callback function, of the form callback(cfmini_object, portNumber, value)
me Object the object to set as `this' when calling your callback function
Returns
a watcherID you can use to unwatch with CFLink.CFMini.unwatch
Type
Number
Setup a callback function that is called when the state of the selected Relay port(s) change This is a simple helper that watches the CFLink.IOPort.VALUE_CHANGE event and only calls you back when one of the Relay ports you want to watch changes state. Your callback function should be of the form: myCallback(cfminiObject, portNumber, previousValue, newValue) Where `cfminiObject' is the CFLink.CFMini device object, `portNumber' is the Relay port number that changed state, `previousValue' is the previous value of this Relay port (0 or 1), and `newValue' is its new value. Note that when we get the initial value of the relay (at initialization time), the `previousValue' parameter will be -1.