Spanish Total.js
Deutsch
Dokumentation Für KI-Agenten
Inhalt

Drivers for developers

What a driver is, where it runs and how a reading travels from a device to a sensor.

.md Website

Diese Seite ist noch nicht übersetzt. Du liest das Original.

Auf dieser Seite

A driver connects one kind of device to Total.js IoT Platform. It is a single file that you install in Drivers (see Drivers). This section explains how to write one.

What a driver does

  • It describes the device: name, manufacturer, icon and the values it measures. Each value is an output, and every device of the driver gets one sensor for each output.
  • It receives data. Usually it creates an HTTP address on the stream where the devices post their readings.
  • It processes each message and sends the values to its outputs. The platform stores them, keeps the statistics and shows them in the app.
  • Optionally it has settings for each device, options for the whole driver, commands, its own database tables and alerts.

Where a driver runs

Admin stores the driver in the database. The Stream app loads every driver and every device from the database and runs them in a FlowStream: each driver is a component, and each device is an instance of that component. The stream reloads drivers and devices every three minutes, so a new or changed driver works within three minutes of saving it, without a restart.

The path of a reading

  1. A device posts JSON to the address of its driver on the stream, for example POST /demoweather/.
  2. The route of the driver checks the data and finds the instance of the device by its identifier.
  3. The route passes the data to instance.message of that device.
  4. instance.message sends each value to an output with instance.newmessage(value).send('temperature').
  5. The stream writes the last value and the statistics to the database. The value appears in Sensors and on the map.
Hergestellt in Europa