Spanish Total.js
Slovenčina
Dokumentácia Pre AI agentov
Obsah

Driver reference

Every property and function a driver sets on exports.

.md Web

Táto stránka ešte nie je preložená. Čítaš originál.

Na tejto stránke

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.

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.

A new device gets this name until people change it.

property

exports.manufacturer = 'Example Ltd.';

The maker of the device.
property

exports.icon = 'ti ti-temperature';

The icon of the driver, a Tabler icon class.
property

exports.color = '#3B82F6';

The color of the driver in the app.
property

exports.author = 'Jane Doe';

The author, shown in the device detail.
property

exports.version = '1';

The version of the driver, shown when people choose a driver.
property

exports.extension = true;

Makes the driver an extension that runs once for the whole stream.

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.

See Outputs and history for the properties.

Temperature in degrees
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.

The default for outputs without their own offline.

property

exports.inputs = [{ id, name, html }];

The inputs of the driver. Inputs with html are commands.
A command with one field
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.

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.

People set them with Drivers > ... > Settings. Read them in com.options or instance.module.options.

A token
exports.options = [{ id: 'token', type: 'string', name: 'Token', value: '' }];
property

exports.storage = [{ id, name, columns: [{ id, name, type }] }];

The database tables of the driver.

See Storage.

event

exports.install = function(com) {}

Runs when the stream loads the driver and when a changed driver is loaded again.
ParameterTypPopis
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.

Create a route
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.
ParameterTypPopis
com Object The driver in the stream.

Remove what exports.install created.

Remove the route
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.
ParameterTypPopis
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.

Vyrobené v Európe