new Configurator(optsopt, adapter)
- Source:
Plugin to manage setting device configuration values.
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
opts |
Object |
<optional> |
General settings for Configurator |
adapter |
Adapter | Adapter for which this is a plugin |
Members
(static) constants
- Source:
Properties:
| Name | Type | Description |
|---|---|---|
constants |
Object |
adapter :Adapter
- Source:
The adapter instance
Type:
Methods
(async) close()
- Source:
Tear down method for all configurator listeners
(async) configureDevice(device, configCommandsListopt) → {Promise}
- Source:
Set configuration for this device and checks whether configuration was set correctly. Bridge must have already been populated with this device.
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
device |
Device | The device to configure |
|
configCommandsList |
Array.<Object> |
<optional> |
Specific config commands to call |
Returns:
Resolves to true if configuration was set correctly
- Type
- Promise
extractConfigCommands(device) → {Array}
- Source:
Obtain the set of configuration commands for a given device
Parameters:
| Name | Type | Description |
|---|---|---|
device |
Device | The device to configure |
Throws:
Returns:
The set of configuration commands
- Type
- Array
findConfigParamsByProp(propName, device) → {Array}
- Source:
Given a K4Model property that overrides a config parameter argument, determine the configuration parameter(s) which make use of that K4Model property
Parameters:
| Name | Type | Description |
|---|---|---|
propName |
String | Name of the property node on K4Model |
device |
Device | The device to configure |
Returns:
- Type
- Array
generateConfigCommandQueue(device, configCommands, retryOptions) → {Array.<function(): Promise>}
- Source:
Creates the list of functions that will be invoked to issue the configuration for a device.
Parameters:
| Name | Type | Description |
|---|---|---|
device |
Device | |
configCommands |
Array.<Object> | |
retryOptions |
Object |
Returns:
An Array of Functions that return Promises
- Type
- Array.<function(): Promise>
(async) init()
- Source:
This method should be named as 'init' because Adapter instance calls the 'init' methods (if they exist) for all Adapter plugins
obtainConfigArgVal(argName, device, configParam) → {any}
- Source:
Determine the value to set for a specific configuration parameter argument, giving primacy to K4Model property overrides
Parameters:
| Name | Type | Description |
|---|---|---|
argName |
String | Name of the argument belonging to a config parameter |
device |
Device | The device to configure |
configParam |
Object | The configuration parameter itself |
Returns:
The appropriate value the argument should be set to
- Type
- any
obtainConfigPropOverrideForArgVal(argName, device, configParam) → {any}
- Source:
Determine, if available, the K4Model property override value for a configuration argument overrides
Parameters:
| Name | Type | Description |
|---|---|---|
argName |
String | Name of the argument belonging to a config parameter |
device |
Device | The device to configure |
configParam |
Object | The configuration parameter itself |
Returns:
The appropriate value the argument should be set to
- Type
- any
(async) onConfigResponseReceived(response, device)
- Source:
The real-time handler for configuration related responses. Will update configuration sync statuses, and attempt to reconfigure if necessary.
Parameters:
| Name | Type | Description |
|---|---|---|
response |
Response | The pre-initialized response object |
device |
Device | The device associated with the response |
onMappingChanged(devicesWithChangedMappings)
- Source:
Update configuration if the device mapping has changed. Assumes this is an existing device whose mapping has been modified. Also, device should have been configured at least once before.
Parameters:
| Name | Type | Description |
|---|---|---|
devicesWithChangedMappings |
Array.<Object> |
onModelChanged(deviceNodesThatChanged)
- Source:
Handler/wrapper for tasks on device nodes changes. Currently triggers re-configure if the commands, properties, events, or variable field names change.
Parameters:
| Name | Type | Description |
|---|---|---|
deviceNodesThatChanged |
Array.<Object> | The device to configure |
(async) setupDeviceConfig(device) → {Promise}
- Source:
This is the entry point for a consumer of configurator services. It is only run once, because listeners are set up and are able to self-manage from then onwards.
Parameters:
| Name | Type | Description |
|---|---|---|
device |
Device | The device to configure |
Returns:
If configuration succeeds, resolves to true
- Type
- Promise
signalReceived(response, device)
- Source:
Acts as beacon; on a response, adapter will call this, which will then notify other configurator listeners
Parameters:
| Name | Type | Description |
|---|---|---|
response |
Response | The pre-initialized response object |
device |
Device | The device associated with the response |
validateConfigParamValue(device, configParam, actualValue) → {Object}
- Source:
Checks that the specified configuration parameter value is correct, as defined by the mapping and model settings
Parameters:
| Name | Type | Description |
|---|---|---|
device |
Device | |
configParam |
Object | |
actualValue |
any |
Returns:
- Type
- Object
verifyConfigResponse(response, device, relevantConfigParamsopt) → {Object}
- Source:
Helper function to check latest configuration against the K4Model
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
response |
The pre-initialized response object |
||
device |
The device associated with the response |
||
relevantConfigParams |
Array |
<optional> |
The specific config parameters to inspect. Will default to all config parameters for this device. |
Returns:
Contains the Boolean checked status of whether the actual and expected config values matched, and a list of Objects containing the raw expected and actual config values.
- Type
- Object