Driver reference
Every property and function a driver sets on exports.
Cette page n’est pas encore traduite. Tu lis l’original.
Sur cette page
A driver sets these properties and functions on exports in its <script total> part. Entries of type property are values you set, entries of type event are functions you define and the stream calls.
API
property
exports.id = 'demoweather';
The identifier of the driver.
exports.id = 'demoweather';Lower-case letters and digits only. A driver saved with an existing id replaces that driver. The id is also the start of the sensor ids, such as demoweather_temperature.
property
exports.name = 'Demo weather station';
The name of the driver, shown in Drivers and when people create a device.
exports.name = 'Demo weather station';A new device gets this name until people change it.
property
exports.manufacturer = 'Example Ltd.';
The maker of the device.
exports.manufacturer = 'Example Ltd.';
property
exports.icon = 'ti ti-temperature';
The icon of the driver, a Tabler icon class.
exports.icon = 'ti ti-temperature';
property
exports.color = '#3B82F6';
The color of the driver in the app.
exports.color = '#3B82F6';
property
exports.author = 'Jane Doe';
The author, shown in the device detail.
exports.author = 'Jane Doe';
property
exports.version = '1';
The version of the driver, shown when people choose a driver.
exports.version = '1';
property
exports.extension = true;
Makes the driver an extension that runs once for the whole stream.
exports.extension = true;Extensions are listed under Extensions and are not offered when people create a device. See Receiving data.
property
exports.outputs = [{ id, name, type, format, decimals, stats, offline, category }];
The values the device measures. Each output becomes a sensor of every device.
exports.outputs = [{ id, name, type, format, decimals, stats, offline, category }];See Outputs and history for the properties.
exports.outputs = [{ id: 'temperature', type: 'number', name: 'Temperature', format: '{0} °C', decimals: 1, stats: 'hourly' }];
property
exports.offline = '2 hours';
How long a sensor stays online without a new value.
exports.offline = '2 hours';The default for outputs without their own offline.
property
exports.inputs = [{ id, name, html }];
The inputs of the driver. Inputs with html are commands.
exports.inputs = [{ id, name, html }];See Commands.
exports.inputs = [{ id: 'input', name: 'Input' }, { id: 'interval', name: 'Change interval', html: '<ui-component name="input" path="?.minutes" config="type:number">Minutes</ui-component>' }];
property
exports.config = { offset: 0 };
The default configuration of a new device.
exports.config = { offset: 0 };People change it with Configure when the driver has a <settings> part. See Settings and options.
property
exports.options = [{ id, type, name, value }];
The options of the whole driver, with their default values.
exports.options = [{ id, type, name, value }];People set them with Drivers > ... > Settings. Read them in com.options or instance.module.options.
exports.options = [{ id: 'token', type: 'string', name: 'Token', value: '' }];
property
exports.storage = [{ id, name, columns: [{ id, name, type }] }];
The database tables of the driver.
exports.storage = [{ id, name, columns: [{ id, name, type }] }];See Storage.
event
exports.install = function(com) {}
Runs when the stream loads the driver and when a changed driver is loaded again.
exports.install = function(com) {}| Paramètre | Type | Description |
|---|---|---|
com |
Object |
The driver in the stream. com.id is its id, com.options its options and com.main.meta.flow all running instances. |
Create routes here and keep them on com so that exports.uninstall can remove them.
exports.install = function(com) {
com.route = ROUTE('POST /demoweather/', function($) {
$.success();
});
};
event
exports.uninstall = function(com) {}
Runs before a changed driver is loaded again and when the driver is removed.
exports.uninstall = function(com) {}| Paramètre | Type | Description |
|---|---|---|
com |
Object |
The driver in the stream. |
Remove what exports.install created.
exports.uninstall = function(com) {
com.route && com.route.remove();
};
event
exports.make = function(instance, config) {}
Runs for each device of the driver and defines how it processes data.
exports.make = function(instance, config) {}| Paramètre | Type | Description |
|---|---|---|
instance |
Object |
The device in the stream. |
config |
Object |
The configuration of the device, including sn. |
For an extension it runs once. Define instance.message here. See Instance reference.