--- title: Total.js IoT Platform project: IoT Platform version: 1.0 section: guides language: en license: Total.js Enterprise url: https://totaljs.es/docs/iot/1-0/guides/introduction/ updated: 2026-11-20T06:56:24.247Z --- # Total.js IoT Platform > What Total.js IoT Platform does, how its two apps work together and what to read next. > **Note:** Total.js IoT Platform is available only with a [Total.js Enterprise](https://www.totaljs.com/enterprise/) subscription. See the [IoT Platform page](https://www.totaljs.com/iot/) on totaljs.com. Total.js IoT Platform collects the readings of your sensors, keeps their history and shows them on a map. You draw zones on the map, such as a park, a school or a crossroads, and every zone shows the latest values of the sensors you pick for it. ![The map with two zones and the latest values of their sensors](/files/JaszS63v060f.webp) ## How it works The platform is made of two apps that share one PostgreSQL database: - **Admin** is the app you work in. Here you install drivers, register devices, draw zones, combine sensors into data views and build reports and panels. - **Stream** receives the data that your devices send. It runs the drivers, turns each message into sensor values and writes them to the database. A **driver** is a small script that knows one kind of device: which values it measures, which address it receives data on and how to read its messages. When you create a device, you choose its driver, and the platform creates one **sensor** for each value the driver measures. ## What you can do - See every sensor with its last value, its online status and its history. See [Sensors](../sensors/). - Draw zones on the map and show selected sensors in them. See [Zones](../zones/) and [The map](../map/). - Combine several sensors into one value, such as an average temperature. See [Data views](../data-views/). - Build reports from SQL queries and download them. See [Reports](../reports/). - Show live content on small web pages, for example on a display at an entrance. See [Panels](../panels/). - Publish the values of devices, sensors, zones, data views and reports as JSON. See [Open data API](../../reference/open-data-api/). - Replay recorded data to test a driver. See [Simulations](../simulations/). - Write your own drivers. See [Drivers for developers](../../development/introduction/). ## What to read next 1. [Installation](../installation/) installs both apps and connects them to the database. 2. [First steps](../first-steps/) takes you from the first sign-in to the first values on the map. --- title: Installation project: IoT Platform version: 1.0 section: guides language: en license: Total.js Enterprise url: https://totaljs.es/docs/iot/1-0/guides/installation/ updated: 2026-11-20T06:56:23.519Z --- # Installation > Install the Admin and Stream apps, connect them to PostgreSQL and start them. > **Note:** Total.js IoT Platform is available only with a [Total.js Enterprise](https://www.totaljs.com/enterprise/) subscription. See the [IoT Platform page](https://www.totaljs.com/iot/) on totaljs.com. Total.js IoT Platform runs on your own server. You receive the source code from Total.js with your Enterprise license. The package has three folders: - `admin`: the app you work in. - `stream`: the app that receives the data of your devices. - `drivers`: example drivers that you can install or use as a starting point. ## Requirements - Node.js 18 or newer. - PostgreSQL 15 or newer. ## Create the database Create an empty PostgreSQL database for the platform, for example `iot`. Both apps use this one database. Admin creates its tables the first time it starts. ## Install Admin 1. Open a terminal in the `admin` folder and install the dependencies: ```bash npm install ``` 2. Open the `config` file and set the connection to your database and the address where people will open the app: ```text database : postgresql://user:password@127.0.0.1:5432/iot url : https://iot.example.com ``` 3. Start the app: ```bash npm start ``` Admin listens on port `8000`. Open `http://127.0.0.1:8000/` in your browser and continue with [First steps](../first-steps/). ## Install Stream 1. Open a terminal in the `stream` folder and install the dependencies: ```bash npm install ``` 2. Open the `config` file and set the same database and the public address of the stream. Your devices send their data to this address. ```text database : postgresql://user:password@127.0.0.1:5432/iot url : https://stream.example.com ``` 3. Open `index.js` and choose a port for the stream, different from the port of Admin. Remove the `//` in front of the `options.port` line and write the number: ```js options.port = 8001; ``` 4. Start the stream: ```bash node index.js ``` Open `http://127.0.0.1:8001/` to see the [status page of the stream](../stream/). ## Run in production Start each app in release mode, which is faster and does not watch the files for changes: ```bash node index.js --release ``` Keep both apps running with the process manager of your server and put them behind a web server with HTTPS. Devices must be able to reach the address of the stream. Admin only needs to be reachable by the people who use it, and by anyone who reads its [open data](../../reference/open-data-api/). All settings of both apps are described in [Configuration files](../../reference/configuration/). --- title: First steps project: IoT Platform version: 1.0 section: guides language: en license: Total.js Enterprise url: https://totaljs.es/docs/iot/1-0/guides/first-steps/ updated: 2026-11-20T06:56:23.519Z --- # First steps > Sign in for the first time and go from an empty platform to the first values on the map. This page takes you through the first sign-in and the order in which the parts of the platform depend on each other. ## Sign in for the first time When Admin starts for the first time, it creates an administrator account with a random user name and password. Until somebody signs in, the sign-in page shows this **Default account**. 1. Open the address of Admin in your browser. 2. Select **Fill in the form** in the **Default account** box, or type the user name and password yourself. 3. Select **Sign in**. After the first sign-in, the box disappears and the sign-in page shows only the form: ![The sign-in page with User name and Password](/files/JaszRz3q061f.webp) Sign in right after you install the platform, so that nobody else sees the default account. Then choose your own name, user name and password, as described in [Your account](../account/). ## The main menu The menu on the left opens every part of the app: **Map**, **Alerts**, **Sensors**, **Data views**, **Devices**, **Panels**, **Reports**, **Simulations**, **Zones**, **Drivers**, **Dictionary**, **Files** and **Settings**. A red number next to **Sensors** counts the sensors that are offline. ## From an empty platform to the map The parts of the platform build on each other. Follow this order: 1. **Settings.** Set the name of the app and the place where the map opens. See [Settings](../settings/). 2. **Drivers.** Install a driver for each kind of device you have. See [Drivers](../drivers/). 3. **Devices.** Create a device for each piece of hardware and give it its identifier. The platform creates its sensors. See [Devices](../devices/). 4. **Data.** Your devices send data to the stream, and the values appear in [Sensors](../sensors/). To try it without hardware, use [Simulations](../simulations/). 5. **Zones.** Draw zones and add the sensors that belong to them. See [Zones](../zones/). 6. **Map.** Open the [map](../map/) and zoom in to see the values in each zone. --- title: Drivers project: IoT Platform version: 1.0 section: guides language: en license: Total.js Enterprise url: https://totaljs.es/docs/iot/1-0/guides/drivers/ updated: 2026-11-20T06:56:18.114Z --- # Drivers > Install, configure, read and remove the drivers that describe your devices. A driver describes one kind of device: its name and manufacturer, the values it measures, the settings each device needs and the address where the stream receives its data. You need a driver before you can create a device of that kind. ![The Drivers screen with drivers and extensions](/files/JaszQ02I061f.webp) The **Drivers** screen groups the installed drivers in two lists: - **Drivers** describe devices. You choose one of them when you create a device. - **Extensions** run once for the whole platform. An extension usually receives data for many devices at one address and passes each reading to the right device. ## Install a driver A driver is a single file. The `drivers` folder of the installation package contains examples, and the developers of your devices or your own team can write new ones (see [Drivers for developers](../../development/introduction/)). 1. Open **Drivers** and select **Create**. An editor opens with a template. 2. Replace the whole template with the content of the driver file. 3. Select **SUBMIT**. ![The editor with the source code of a driver](/files/JaszQ42J060f.webp) The driver appears in the list. If the code has an error, the editor shows it and keeps the driver unsaved. The stream starts to use a new or changed driver within three minutes. ## The driver menu Select **...** on a driver to open its menu: ![The menu of a driver with Settings, Read me, Edit source-code and Remove](/files/JaszQ52K061f.webp) - **Settings** opens the options of the driver, for example a token that devices must send. The options apply to every device of this driver. - **Read me** shows the description that the author wrote, usually with the format of the data the driver accepts. - **Edit source-code** opens the editor. When you save a new version, the platform keeps the values you set in **Settings**. - **Remove** deletes the driver. ![The Read me of a driver](/files/JaszQ72L060f.webp) ## Set the options of a driver 1. Select **...** on the driver and then **Settings**. 2. Fill in the options. 3. Select **APPLY**. ![The settings of a driver with a Token field](/files/JaszQ92M061f.webp) The stream uses the new values within three minutes. --- title: Devices project: IoT Platform version: 1.0 section: guides language: en license: Total.js Enterprise url: https://totaljs.es/docs/iot/1-0/guides/devices/ updated: 2026-11-20T06:56:18.114Z --- # Devices > Create devices, give them their identifiers, configure them and send them commands. A device is one piece of hardware, such as a weather station in a park. Each device uses one driver, and the platform creates one sensor for every value the driver measures. ![The Devices screen with two weather stations](/files/JaszPg26061f.webp) The **Devices** screen lists all devices with their driver, name, serial number, reference, locality, position and online status. Use the **Filter** row under the column names to search. ## Create a device 1. Open **Devices** and select **Create**. 2. Select the driver of the device. The platform creates the device right away and opens its form. ![Select a driver: the list of installed drivers](/files/JaszPi27060f.webp) 3. Fill in the form and select **SUBMIT**. ![The device form with Name, Device identifier and the locality](/files/JaszPl28061f.webp) The most important field is **Device identifier**. It is the serial number or another code that the device sends with its data, and the driver uses it to find the device that a reading belongs to. Write it exactly as the device sends it. The other fields: - **Name**: the name people see everywhere in the app. - **Temporarily disabled**: the stream ignores the device until you clear the box. - **Publish a value to an API endpoint**: makes the device and its sensors available as JSON. See [Open data API](../../reference/open-data-api/). - **Note** and **Custom attributes**: your own information. Custom attributes are key and value pairs that also appear in the open data. - **Reference**, **Color** and **Icon**: your own reference code and the look of the device. - **Place**, **Latitude** and **Longitude**: where the device is. The map uses the position when it shows devices. The stream starts to accept data for a new device within three minutes. ## The device detail Select a device in the list to open its detail. It shows the basic information, the locality, the driver and the list of sensors with their status, last value and time. ![The detail of a device with three online sensors](/files/JaszPo29060f.webp) The buttons at the top: - **Refresh** reloads the values. - **Commands** sends a command to the device. It is available when the driver defines commands. - **Options** opens **Readme**, **Edit**, **Configure** and **Remove**. ![The Options menu of a device](/files/JaszPp2A061f.webp) ## Change the sensors of one device Select the cog icon of a sensor in the device detail: - **Rename** gives the sensor another name for this device. - **Hide sensor** hides a sensor that the device does not use. - **Enable timeline** keeps every received value, not only the statistics. The sensor gets an orange background. - **Publish to API endpoint** makes the sensor available as JSON. The address appears under the sensor. - **Stats** chooses how often the history is summarised: **Minutely stats**, **Hourly stats** or **Daily stats**. You can also select the stats name next to the value. ## Configure a device Some drivers have settings for each device, for example a correction for a temperature sensor. Select **Options** and **Configure**, change the values and select **APPLY**. ![The settings of one device with a temperature correction](/files/JaszPr2B060f.webp) The stream uses the new configuration within three minutes. ## Send a command When the driver defines commands, for example to change how often the device measures: 1. Open the device and select **Commands**. 2. Choose the command. 3. Fill in its form and select **SUBMIT**. ![The form of the Change interval command](/files/JaszPs2C061f.webp) The app confirms that the command is sent. The stream picks up new commands every five seconds and passes them to the driver. --- title: Sensors project: IoT Platform version: 1.0 section: guides language: en license: Total.js Enterprise url: https://totaljs.es/docs/iot/1-0/guides/sensors/ updated: 2026-11-20T06:56:27.243Z --- # Sensors > Follow the last value of every sensor and browse, filter and export its history. The **Sensors** screen lists every sensor of every device with its driver, device, locality, last value, number of alerts, the time of the last value, the serial number of the device and its online status. ![The Sensors screen with six sensors of two weather stations](/files/JaszSY4D060f.webp) A sensor is **online** when it received a value within the time its driver allows, for example two hours. When that time passes, the sensor turns **offline**, and the red number next to **Sensors** in the menu counts it. An **API** badge marks a sensor that is published as open data. ## The history of a sensor Select a sensor to open its history. Each row shows the date, the value and how long ago it was. ![The history of a temperature sensor, one row a minute](/files/JaszSa4E061f.webp) By default the history shows the statistics that the sensor keeps: the last hour for minutely stats, the last 24 hours for hourly stats, the last 7 days for daily stats. ## Filter the history Select **Filter** and set: - **From** and **To**: the period. - **Output**: **MIN**, **MAX** or **AVG** of each interval. - **Stats**: the interval, from **Minutely** to **Yearly**, **Last data** for the last value, or **Timeline** for every value when the timeline of the sensor is on (see [Devices](../devices/)). ## Export the history Select **Export CSV** to save the listed rows as a CSV file with the columns `ts` and `value`. --- title: Alerts project: IoT Platform version: 1.0 section: guides language: en license: Total.js Enterprise url: https://totaljs.es/docs/iot/1-0/guides/alerts/ updated: 2026-11-20T06:56:18.114Z --- # Alerts > See the warnings and errors that drivers report about your devices. The **Alerts** screen collects the messages that drivers report, such as a low battery, and the errors that happen while a driver processes data. Each alert shows its message, the device, the sensor and its type when the driver gives them, and the date and time. ![An alert about a low battery of a weather station](/files/JaszP81s061f.webp) New alerts are unread. Opening the **Alerts** screen marks the listed alerts as read. To delete alerts, select them and then **Remove**. Only administrators can remove alerts. The alerts come from the drivers, so what a device reports depends on its driver. A developer adds alerts to a driver as described in [Alerts and debugging](../../development/alerts-and-debugging/). --- title: The stream project: IoT Platform version: 1.0 section: guides language: en license: Total.js Enterprise url: https://totaljs.es/docs/iot/1-0/guides/stream/ updated: 2026-11-20T06:56:28.789Z --- # The stream > What the Stream app does, how devices send data to it and how to read its status page. The Stream app receives the data of your devices. It loads the installed drivers and the devices from the database, runs each driver and writes the values to the database, where Admin shows them. ## Where devices send data Each driver decides the address it listens on. The **Read me** of a driver usually tells you the address and the format, for example `POST /demoweather/` with a JSON body. The full address is the public address of your stream followed by that path: ```text https://stream.example.com/demoweather/ ``` If a driver has a token in its **Settings**, the device must send it, usually in a header. The **Read me** of the driver says which one. ## Changes reach the stream within three minutes The stream reads the drivers, the devices and their configuration from the database every three minutes. A new device, a changed driver, new driver options and a changed device configuration take effect at the next reload. Restarting the stream applies them at once. ## The status page Open the address of the stream in a browser to see its status page: ![The status page of the stream](/files/JaszSp4P060f.webp) The first lines show the memory the stream uses and the number of messages it has processed. Then each line shows one running item: its id, its driver and its counters. The ids are the ids of your devices, as shown in the device detail, and the ids of the extensions. Two items are always there: `database`, which writes the values, and `debugger`, which writes the debug messages of the drivers. When a device does not appear on the status page three minutes after you created it, check that it is not **Temporarily disabled** and that its driver is installed. --- title: Zones project: IoT Platform version: 1.0 section: guides language: en license: Total.js Enterprise url: https://totaljs.es/docs/iot/1-0/guides/zones/ updated: 2026-11-20T06:56:29.450Z --- # Zones > Draw zones on the map, sort them into categories and choose the sensors they show. A zone is an area on the map, such as a park, a school or a crossroads. Each zone shows the latest values of the sensors and data views you add to it. ![The Zones screen with a zone in the Parks category](/files/JaszSt4S061f.webp) The **Zones** screen groups the zones by category and shows a picture of each zone. ## Create a zone 1. Open **Zones** and select **Create**. 2. Fill in the **Name** and choose a **Category**. 3. Select **Draw zone**, draw the area on the map and select **APPLY**. 4. Select **Add sensor** and add the sensors or data views that belong to the zone. 5. Select **SUBMIT**. ![The zone form with its sensors, position and picture](/files/JaszSw4T060f.webp) The fields of the form: - **Show on map**: shows the zone on the [map](../map/). - **Zone is inactive**: turns the zone off. An inactive zone is not available as open data. - **Publish a value to an API endpoint**: makes the zone and its values available as JSON. See [Open data API](../../reference/open-data-api/). - **Note** and **Custom attributes**: your own information. Custom attributes also appear in the open data. ## The sensors of a zone Each sensor in the list shows its last value and these controls: - The arrows change the order on the map. - The eye (**Show on the map**) shows or hides the sensor in the panel of the zone on the map. - The funnel sets the statistics of the sensor in this zone: the **Type of stats**, the **Interval** (for example `24` intervals means 24 hours in hourly stats) and the **Operation**, such as **Average value** or **Maximal value**. - The bin removes the sensor from the zone. ## Categories Select **Categories** to create, change and remove categories. Each category has a **Name**, an **Icon** and a **Color**. The map can show the zones of selected categories only. ## Update or remove a zone Select the cog icon of a zone and choose **Update** or **Remove**. A published zone also has **Copy API endpoint**. --- title: The map project: IoT Platform version: 1.0 section: guides language: en license: Total.js Enterprise url: https://totaljs.es/docs/iot/1-0/guides/map/ updated: 2026-11-20T06:56:24.661Z --- # The map > Read the latest values of each zone on the map and open the history of its sensors. The **Map** opens at the position set in [Settings](../settings/) and shows every zone marked **Show on map**. ## Read the values From afar, each zone shows a circle with a number. Zoom in with **+** or the mouse wheel, and each zone shows a panel with its name and the latest values of its sensors. ![The map with the panels of two zones](/files/JaszS63v060f.webp) ## Open the history of a zone Select the panel of a zone. A window opens with a chart for each sensor, with its value, the time it was measured and the statistics it shows. ![Charts of temperature and humidity in a zone](/files/JaszSA3y061f.webp) Select the statistics next to **Display** to choose the **Type** of value (maximal, minimal, average or sum) and the **Period**, from 60 minutes to 12 months. ## Filter and find - **Categories** shows only the zones of the categories you choose. - **Find** lists the zones and moves the map to the one you select. - **Refresh** reloads the zones and their values. ## Show devices instead of zones When **Show devices only** is on in [Settings](../settings/), the map shows your devices at their latitude and longitude instead of the zones. --- title: Data views project: IoT Platform version: 1.0 section: guides language: en license: Total.js Enterprise url: https://totaljs.es/docs/iot/1-0/guides/data-views/ updated: 2026-11-20T06:56:18.114Z --- # Data views > Combine several sensors into one value with an operation, a format and decimals. A data view combines the values of several sensors into one value. Use it for the average temperature of a city, the highest noise level of a district or the total consumption of a building. ![The Data views screen with an average temperature](/files/JaszPa22061f.webp) ## Create a data view 1. Open **Data views** and select **Create**. 2. Fill in the **Name**. 3. Choose the **Operation**: **Min**, **Max**, **Avg** or **Sum**. 4. Set the **Format**, where `{0}` stands for the value, for example `{0} °C`, and the number of **Decimals**. 5. Choose the default **Stats** for its charts. 6. Select **Add sensor** and add the sensors to combine. 7. Select **SUBMIT**. ![The data view form with two temperature sensors](/files/JaszPc23060f.webp) The list shows the result next to the name, and the form shows the current value of each sensor. **Publish a value to an API endpoint** makes the data view available as JSON with its value and the values of its sensors. See [Open data API](../../reference/open-data-api/). **Note** and **Custom attributes** hold your own information. A data view can be added to a zone like a sensor. See [Zones](../zones/). --- title: Reports project: IoT Platform version: 1.0 section: guides language: en license: Total.js Enterprise url: https://totaljs.es/docs/iot/1-0/guides/reports/ updated: 2026-11-20T06:56:26.603Z --- # Reports > Build tables from SQL queries, preview them, download them and publish them. A report is a table built from an SQL query on the database of the platform. You can preview it, copy it, download it and publish it as JSON. ![The Reports screen with two reports in the Weather category](/files/JaszSN47060f.webp) ## Create a report 1. Open **Reports** and select **Create**. 2. Fill in the **Name**. 3. Write the SQL query in the editor. Only queries that read data are accepted. 4. Select **Preview data from SQL command** to check the result. 5. In **Map fields**, give the columns readable names, separated by commas: `column=Label, column=Label`. 6. Set the **Icon**, **Color**, **Category** and **Note** if you like. 7. Select **SUBMIT**. ![The report form with an SQL query and mapped fields](/files/JaszSP48061f.webp) - **Convert date and time to local time** shows the dates in the time of the browser. Without it, dates are in UTC. - **Publish a value to an API endpoint** makes the report available as JSON. See [Open data API](../../reference/open-data-api/). A simple query to start with lists the last value of every sensor: ```sql SELECT device, sensor, value, dtvalue FROM view_sensor ORDER BY device, sensor ``` ## Open a report Select a report to open its data. From there you can copy the data to the clipboard or download it as CSV or XLSX. ![A report with the last value of each sensor](/files/JaszSS49060f.webp) ## The report menu Select **...** on a report: ![The report menu](/files/JaszSU4A061f.webp) - **Preview** opens the data. - **Copy API endpoint** copies the address of the published report. - **Update** changes the report, **Clone** creates a copy and **Remove** deletes it. --- title: Panels project: IoT Platform version: 1.0 section: guides language: en license: Total.js Enterprise url: https://totaljs.es/docs/iot/1-0/guides/panels/ updated: 2026-11-20T06:56:25.582Z --- # Panels > Create small live web pages, for example for a display, and send them new content. A panel is a small web page with a fixed size, made for a display at an entrance, in a hall or on a wall. Its content is HTML that another program sends to the panel, for example a Flow that formats the latest value of a sensor. Every open panel page updates at once when new content arrives. ![The Panels screen with a panel for a park entrance](/files/JaszSE41060f.webp) ## Create a panel 1. Open **Panels** and select **Create**. 2. Fill in the **Name** and the **Width** and **Height** in pixels. Design the content for this size. 3. Optionally choose a **Category**, write the **Location**, a **Note**, an **Icon**, a **Color** and the position. 4. Select **SUBMIT**. ![The panel form with name, size and location](/files/JaszSG42061f.webp) **Panel is inactive** stops the panel from accepting new content. ## The panel menu Select **...** on a panel: ![The panel menu with the two addresses](/files/JaszSI43060f.webp) - **Copy panel URL address** copies the address of the page to open on the display. - **Copy Flow URL address** copies the address that accepts new content. It contains the access token of the panel, so keep it private. - **Update** and **Remove** change or delete the panel. ## Send content to a panel Send a `POST` request with a JSON body that has an `html` field to the Flow URL address of the panel. From a terminal: ```bash curl -X POST 'https://iot.example.com/panels//?token=' \ -H 'Content-Type: application/json' \ -d '{"html":"
20.4 °C
"}' ``` The answer is `{"success":true}`, and every open page of the panel shows the new content: ![A panel showing the temperature of the City park](/files/JaszSJ44061f.webp) The platform keeps the last content, so a display that opens the panel later shows it too. See [Show a live value on a panel](../../recipes/live-value-on-a-panel/) for a complete example. --- title: Simulations project: IoT Platform version: 1.0 section: guides language: en license: Total.js Enterprise url: https://totaljs.es/docs/iot/1-0/guides/simulations/ updated: 2026-11-20T06:56:28.339Z --- # Simulations > Replay readings from a CSV file to an endpoint to test drivers and devices without hardware. A simulation sends the rows of a CSV file to an address, one row at a time, at a frequency you choose. Use it to test a driver, a device or a zone before the hardware is installed. ![The Simulations screen with a running simulation](/files/JaszSh4K061f.webp) ## Add an endpoint An endpoint is the address the simulation sends to, usually the address of a driver on your stream. 1. Open **Simulations** and select **Endpoints**. 2. Select **Add endpoint**. 3. Fill in the **Name** and the **URL**, for example `https://stream.example.com/demoweather/`. 4. If the driver expects a token, fill in **Token**. The simulation sends it in the `x-token` header. 5. Select **SUBMIT**. ![The list of endpoints](/files/JaszSj4L060f.webp) ## Prepare the CSV file The first line holds the names of the fields of the JSON that the simulation sends. Put `+` in front of a name to send the value as a number. Each next line is one message. ```text sn,+temperature,+humidity,+battery WS-0002,16.2,61,60 WS-0002,16.0,62,60 WS-0002,15.8,63,59 ``` The first data line becomes this message: ```json { "sn": "WS-0002", "temperature": 16.2, "humidity": 61, "battery": 60 } ``` ## Create a simulation 1. Select **Create**. 2. Select the **File** field and choose the CSV file. The name of the file becomes the name of the simulation. 3. Choose the **Endpoint**. 4. Set the **Frequency** in minutes, for example `1` sends one row every minute. 5. Check **Launch** to start right away. Check **Data circulation** to start again from the first row after the last one. 6. Select **SUBMIT**. ![The Create simulation form](/files/JaszSl4M061f.webp) Without **Data circulation**, the simulation stops after the last row and **Launched** turns off. To run it again, open it, check **Launch** and submit. --- title: Settings project: IoT Platform version: 1.0 section: guides language: en license: Total.js Enterprise url: https://totaljs.es/docs/iot/1-0/guides/settings/ updated: 2026-11-20T06:56:27.628Z --- # Settings > Set the name of the app and where the map and the zone editor open. Open **Settings** to change the general settings of the platform. Select **SUBMIT** to save them. ![The Settings screen](/files/JaszSe4H060f.webp) ## Configuration - **App name**: the name in the header of the app and on the sign-in page. - **Enable OpenPlatform integration**: connects the platform to Total.js OpenPlatform, so that its users sign in with their OpenPlatform account. ## Map - **A default map position**: the latitude and longitude where the [map](../map/) opens, for example `48.7378, 19.1492`. - **Show devices only**: shows the devices at their position instead of the zones. ## Zones - **A default zone position**: the latitude and longitude where the map opens when you draw a zone. --- title: Dictionary project: IoT Platform version: 1.0 section: guides language: en license: Total.js Enterprise url: https://totaljs.es/docs/iot/1-0/guides/dictionary/ updated: 2026-11-20T06:56:18.114Z --- # Dictionary > Rename the names of drivers, sensors and sensor categories in one place. The **Dictionary** lists the names that drivers bring into the platform: the names of the drivers, of their sensors and of the sensor categories. Rename them here, for example to translate them for the people who use the platform. ![The Dictionary with categories, sensors and drivers](/files/JaszPx2F060f.webp) 1. Open **Dictionary**. 2. Select a name in the **Name** column and type the new name. 3. Select **Save**. A new name replaces the old name everywhere it is used. To rename a sensor of one device only, use **Rename** in the device detail. See [Devices](../devices/). --- title: Files project: IoT Platform version: 1.0 section: guides language: en license: Total.js Enterprise url: https://totaljs.es/docs/iot/1-0/guides/files/ updated: 2026-11-20T06:56:23.172Z --- # Files > Upload and manage the images and files that the platform uses. The **Files** screen keeps the files that you upload, such as pictures for zones. It lists each file with its name, extension, dimension, size and upload time. ![The Files screen with two pictures](/files/JaszRv3n060f.webp) - **Upload** adds one or more files from your computer. - **Options** on a file renames, shows, downloads or removes it. - **Options** in the toolbar removes the selected files or clears all files. Files are available at their address without signing in, so do not upload private documents. --- title: Your account project: IoT Platform version: 1.0 section: guides language: en license: Total.js Enterprise url: https://totaljs.es/docs/iot/1-0/guides/account/ updated: 2026-11-20T06:56:18.114Z --- # Your account > Change your name, user name and password, and sign out. Select the user icon in the top right corner to open the account menu. ![The account menu with Change credentials and Logout](/files/JaszPV1x060f.webp) ## Change your credentials 1. Select **Change credentials**. 2. Change the **Name**, the **Login** or both. 3. To change the password, type the new one in **Password**. Leave it empty to keep the current password. 4. Select **SUBMIT**. Changing the credentials signs out every other open session. Your own session stays open. ## Sign out Select **Logout**. --- title: Configuration files project: IoT Platform version: 1.0 section: reference language: en license: Total.js Enterprise url: https://totaljs.es/docs/iot/1-0/reference/configuration/ updated: 2026-11-20T06:56:29.450Z --- # Configuration files > The keys of the config files of Admin and Stream, and the start options in index.js. Each app has a `config` file in its folder. Every line is a key, a colon and a value. Change a value and restart the app. ## Admin | Key | What it does | Example | |---|---|---| | `name` | The name of the app until you set **App name** in [Settings](../../guides/settings/). | `IoT Platform` | | `database` | The connection to the PostgreSQL database. | `postgresql://user:password@127.0.0.1:5432/iot` | | `url` | The public address of Admin. | `https://iot.example.com` | Keep the other keys of the shipped file as they are. ## Stream | Key | What it does | Example | |---|---|---| | `name` | The name of the stream. | `IoT Stream` | | `database` | The connection to the same PostgreSQL database as Admin. | `postgresql://user:password@127.0.0.1:5432/iot` | | `url` | The public address of the stream, where devices send their data. | `https://stream.example.com` | ## Start options in index.js Both apps start from `index.js`. The lines that begin with `//` are switched off. Remove the `//` to use one: ```js options.ip = '127.0.0.1'; options.port = 8001; ``` - `options.ip` limits the app to one network address, for example `127.0.0.1` when a web server on the same machine forwards the requests. - `options.port` sets the port. Admin uses `8000` when you start it with `npm start`. Start an app with `--release` for production: ```bash node index.js --release ``` --- title: Open data API project: IoT Platform version: 1.0 section: reference language: en license: Total.js Enterprise url: https://totaljs.es/docs/iot/1-0/reference/open-data-api/ updated: 2026-11-20T06:56:29.450Z --- # Open data API > The public JSON addresses of published devices, sensors, zones, data views and reports, and the panel page. Admin publishes the data you mark with **Publish a value to an API endpoint** (or **Publish to API endpoint** for a sensor) at public addresses. They need no sign-in and answer with JSON. An item that is not published answers `404`. All addresses start with the address of Admin, for example `https://iot.example.com`. Times are in UTC. ## Devices ```text GET /opendata/devices/?id= ``` The device id is shown in the device detail. The answer has the device, its driver, its position, its custom attributes and configuration, and `items` with each sensor: ```json { "id": "JasoWV1cL61f", "driverid": "demoweather", "driver": "Demo weather station", "sn": "WS-0001", "lat": 48.7363, "lng": 19.1462, "locality": "City park", "attrs": {}, "items": [ { "id": "demoweather_temperature", "name": "Temperature", "format": "{0} °C", "decimals": 1, "value": 19.9, "type": "number", "isonline": true, "stats": "minutely", "dtvalue": "2026-11-20T06:10:58.000Z", "raw": "19.9" } ] } ``` ## Sensors ```text GET /opendata/sensors/?id= ``` The full address of a published sensor is shown under the sensor in the device detail. The answer has the sensor, its device and driver, its last `value`, the `raw` text of the value, `isonline` and `dtvalue`, the time of the value. ## Zones ```text GET /opendata/zones/?id= ``` The answer has the zone with its `area` (the points of the polygon), its position, picture and custom attributes, and `items` with the sensors of the zone and their last values. Inactive zones are not available. ## Data views ```text GET /opendata/dataviews/?id= ``` The answer has the result in `value`, the `operation`, `format` and `decimals`, and `items` with the value of each sensor: ```json { "id": "JassHN1c261f", "name": "Average temperature", "format": "{0} °C", "operation": "avg", "decimals": 1, "value": 19.75, "items": [ { "driverid": "demoweather", "deviceid": "JasoWV1cL61f", "sensorid": "demoweather_temperature", "value": 19.5, "dtvalue": "2026-11-20T06:10:18.000Z" } ] } ``` ## Reports ```text GET /opendata/reports/?id= ``` The answer has the report with its `fields` and the rows of its query in `items`. Copy the address with **Copy API endpoint** in the report menu. ## Panels ```text GET /opendata/panels/?id= ``` This address is the web page of a panel, not JSON. It shows the last content and updates when new content arrives. See [Panels](../../guides/panels/). --- title: Data for reports project: IoT Platform version: 1.0 section: reference language: en license: Total.js Enterprise url: https://totaljs.es/docs/iot/1-0/reference/report-data/ updated: 2026-11-20T06:56:29.450Z --- # Data for reports > The views and tables to use in the SQL queries of reports. Reports read the PostgreSQL database of the platform. These views and tables hold what you usually need. Times are in UTC. ## view_sensor One row for each sensor of each device, with its last value. | Column | Content | |---|---| | `device` | The name of the device. | | `sensor` | The name of the sensor. | | `label` | Locality, device and sensor in one text. | | `deviceid`, `sensorid` | The ids of the device and the sensor. | | `sn` | The device identifier. | | `locality` | The place of the device. | | `value` | The last value, as text. | | `dtvalue` | The time of the last value. | | `format`, `decimals` | How the value is shown. | | `isonline` | `true` when the sensor is online. | | `stats` | The statistics the sensor keeps. | ## view_device One row for each device with `name`, `sn`, `locality`, `lat`, `lng`, `reference`, `driver_name`, `isdisabled` and `isonline`. ## History tables The statistics are in one table for each interval: `tbl_data_minutely`, `tbl_data_hourly`, `tbl_data_daily`, `tbl_data_monthly` and `tbl_data_yearly`. Each row is one interval of one sensor: | Column | Content | |---|---| | `deviceid`, `sensorid` | The device and the sensor. | | `ts` | The start of the interval. | | `min`, `max` | The lowest and the highest value in the interval. | | `count` | The number of values in the interval. | Sensors with the timeline on also keep every value in `tbl_data_timeline` with `ts`, `deviceid`, `sensorid` and `value`. Join the history with `view_sensor` to get readable names: ```sql SELECT b.device, b.sensor, a.ts, a.min, a.max, a.count FROM tbl_data_hourly a INNER JOIN view_sensor b ON b.deviceid = a.deviceid AND b.sensorid = a.sensorid ORDER BY a.ts DESC ``` ## Driver storage Drivers can keep their own tables in the `storage` schema. See [Storage](../../development/storage/). --- title: Test a device without hardware project: IoT Platform version: 1.0 section: recipes language: en license: Total.js Enterprise url: https://totaljs.es/docs/iot/1-0/recipes/test-a-device-without-hardware/ updated: 2026-11-20T06:56:29.450Z --- # Test a device without hardware > Send readings to a new device with a simulation and check them in Sensors and on the map. Before a device is installed, you can check the whole chain, from the driver to the map, with readings from a CSV file. 1. Install the driver of the device in **Drivers**. See [Drivers](../../guides/drivers/). 2. Create the device and fill in its **Device identifier**, for example `WS-0002`. See [Devices](../../guides/devices/). 3. Wait three minutes, or restart the stream, until the device appears on the [status page of the stream](../../guides/stream/). 4. Open the **Read me** of the driver and note the address and the fields it expects. 5. Write a CSV file with those fields. Put `+` in front of the fields that are numbers: ```text sn,+temperature,+humidity,+battery WS-0002,16.2,61,60 WS-0002,16.0,62,60 WS-0002,15.8,63,59 ``` 6. In **Simulations**, select **Endpoints** and add the address of the driver on your stream, with its token if it has one. 7. Select **Create**, choose the CSV file and the endpoint, set **Frequency** to `1`, check **Launch** and select **SUBMIT**. 8. Open **Sensors**. Every minute one row arrives, and the values of the device change. 9. Add the sensors to a zone and open the **Map** to see them there. When all rows are sent, the simulation stops. See [Simulations](../../guides/simulations/) for all the options. --- title: Show a live value on a panel project: IoT Platform version: 1.0 section: recipes language: en license: Total.js Enterprise url: https://totaljs.es/docs/iot/1-0/recipes/live-value-on-a-panel/ updated: 2026-11-20T06:56:29.450Z --- # Show a live value on a panel > Read the last value of a published sensor and show it on a panel every minute with a small script. This recipe shows the temperature of a park on a display at its entrance. A small script on any computer reads the published sensor and sends the panel new HTML. ## Prepare the platform 1. Publish the sensor: open the device, select the cog icon of the sensor and **Publish to API endpoint**. Copy the address shown under the sensor. 2. Create a panel with **Width** `480` and **Height** `240`. See [Panels](../../guides/panels/). 3. Select **...** on the panel, then **Copy Flow URL address**. 4. Open the address from **Copy panel URL address** on the display. ## The script Save this as `panel.sh`, put in the two addresses you copied and run it every minute, for example from cron: ```bash #!/bin/sh SENSOR='https://iot.example.com/opendata/sensors/?id=' PANEL='https://iot.example.com/panels//?token=' VALUE=$(curl -s "$SENSOR" | sed -E 's/.*"value":([0-9.-]+).*/\1/') curl -s -X POST "$PANEL" -H 'Content-Type: application/json' \ -d "{\"html\":\"
City park
$VALUE °C
\"}" ``` Each run answers `{"success":true}`, and the display shows the new value at once, without reloading. A Flow can do the same: read the address of the sensor, build the HTML and post it to the Flow URL address of the panel. --- title: Keep every reading of a device in a report project: IoT Platform version: 1.0 section: recipes language: en license: Total.js Enterprise url: https://totaljs.es/docs/iot/1-0/recipes/keep-raw-readings/ updated: 2026-11-20T06:56:29.450Z --- # Keep every reading of a device in a report > Store each message of a driver in its own table and list it in a report. The statistics of a sensor keep the minimum, maximum and count of each interval. When you need every single reading, for example to check a device, let the driver write it to its own storage table and read the table in a report. 1. Ask the author of the driver to add a storage table and to insert each reading into it, as described in [Storage](../../development/storage/). For example, a table `readings` with the columns `sn` and `temperature`. 2. Install the new version with **Edit source-code**. The platform creates the table. 3. Find the name of the table with a report preview. Open **Reports**, select **Create**, write this query and select **Preview data from SQL command**: ```sql SELECT table_name FROM information_schema.tables WHERE table_schema = 'storage' ``` 4. Replace the query with one that reads the table, using the name you found: ```sql SELECT sn, temperature, dtcreated FROM storage.db1yr6f1treadings ORDER BY dtcreated DESC ``` 5. Set **Map fields** to `sn=Serial number, temperature=Temperature, dtcreated=Received`, give the report a name and select **SUBMIT**. The report lists every reading with the time it arrived. Download it as CSV or XLSX from the report. --- title: Devices and data project: IoT Platform version: 1.0 section: faq language: en license: Total.js Enterprise url: https://totaljs.es/docs/iot/1-0/faq/devices-and-data/ updated: 2026-11-20T06:56:18.114Z --- # Devices and data > Answers about devices that show no data, offline sensors, times and names. ## I created a device, but its values do not change - Wait three minutes. The stream loads new devices at that interval. Restart the stream to load them at once. - Open the [status page of the stream](../../guides/stream/). The id of the device must be there. - Check that the **Device identifier** is exactly the one the device sends. - Check that the device sends to the address of its driver, with the token if the driver has one. The **Read me** of the driver describes both. - Check that the device is not **Temporarily disabled**. ## Why is a sensor offline? It received no value within the time its driver allows, for example two hours. It turns online again with the next value. ## In which time zone are the times? The database stores times in UTC. The app shows them in the time of your browser. Reports show UTC unless **Convert date and time to local time** is on, and the open data answers in UTC. ## How do I rename a sensor? For one device, open the device, select the cog icon of the sensor and **Rename**. For every device of a driver, rename it in the [Dictionary](../../guides/dictionary/). ## Can I keep every value, not only statistics? Yes. Open the device, select the cog icon of the sensor and **Enable timeline**. The history of the sensor can then show **Timeline** in its filter. ## How do I find the id of a device? Open the device. The id is shown under its name. The same id is on the status page of the stream. --- title: Installation and access project: IoT Platform version: 1.0 section: faq language: en license: Total.js Enterprise url: https://totaljs.es/docs/iot/1-0/faq/installation-and-access/ updated: 2026-11-20T06:56:18.114Z --- # Installation and access > Answers about ports, the database, the first account and who can open what. ## Do Admin and Stream need two databases? No. Both use the same PostgreSQL database. Admin creates the tables the first time it starts. ## Which ports do the apps use? Admin uses `8000` when you start it with `npm start`. Choose another port for the stream in its `index.js`. See [Configuration files](../../reference/configuration/). ## Where do I find the first user name and password? On the sign-in page, in the **Default account** box, until somebody signs in for the first time. See [First steps](../../guides/first-steps/). ## What can people see without signing in? The sign-in page, the open data you publish, the pages of panels and the uploaded files. Everything else needs an account. See [Open data API](../../reference/open-data-api/). ## Must the stream be public? Your devices must reach it. Put it behind HTTPS and give each driver a token when your devices can send one. --- title: Drivers for developers project: IoT Platform version: 1.0 section: development language: en license: Total.js Enterprise url: https://totaljs.es/docs/iot/1-0/development/introduction/ updated: 2026-11-20T06:56:18.114Z --- # Drivers for developers > What a driver is, where it runs and how a reading travels from a device to a sensor. A driver connects one kind of device to Total.js IoT Platform. It is a single file that you install in **Drivers** (see [Drivers](../../guides/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. ## What to read next - [Your first driver](../first-driver/) builds and tests a complete driver. - [The driver file](../driver-file/) explains the parts of the file. - [Driver reference](../driver-api/) and [Instance reference](../instance-api/) list every property and function. --- title: Your first driver project: IoT Platform version: 1.0 section: development language: en license: Total.js Enterprise url: https://totaljs.es/docs/iot/1-0/development/first-driver/ updated: 2026-11-20T06:56:18.114Z --- # Your first driver > Write a driver for a weather station, install it, create a device and send it test data. This page builds a driver for a weather station that measures temperature, humidity and battery level. The station posts JSON like this to the stream: ```json { "sn": "WS-0001", "temperature": 21.4, "humidity": 48, "battery": 87 } ``` ## The driver Save this as `demoweather.html`: ```html
Temperature correction (°C)
Demo weather station. Send readings to `POST /demoweather/` on the stream. When the driver has a token, send it in the `x-token` header. ```json { "sn": "WS-0001", "temperature": 21.4, "humidity": 48, "battery": 87 } ``` ``` The parts in short: - `exports.id`, `name`, `manufacturer`, `icon`, `color`, `author` and `version` describe the driver in the app. - `exports.outputs` creates three sensors for every device: temperature, humidity and battery. - `exports.config` and the `` form give each device a temperature correction. See [Settings and options](../settings-and-options/). - `exports.options` gives the driver a token, set in **Drivers > ... > Settings**. - `exports.install` creates the route `POST /demoweather/` on the stream. It checks the token and the data, finds the device by its serial number and passes the data on. See [Receiving data](../receiving-data/). - `exports.make` sends each value to its output, keeps every temperature in a storage table, reports a low battery as an alert and handles a command. ## Install it 1. In Admin, open **Drivers** and select **Create**. 2. Replace the template with the content of the file and select **SUBMIT**. ## Create a device 1. Open **Devices** and select **Create**. 2. Select **Demo weather station**. 3. Fill in **Name** and set **Device identifier** to `WS-0001`. Select **SUBMIT**. 4. Wait three minutes, or restart the stream, until the id of the device appears on the status page of the stream. ## Send test data Post a reading from a terminal on a computer that reaches the stream. If you set a token in the driver settings, send it in the `x-token` header: ```bash curl -X POST https://stream.example.com/demoweather/ \ -H 'Content-Type: application/json' \ -H 'x-token: your-token' \ -d '{"sn":"WS-0001","temperature":21.4,"humidity":48,"battery":87}' ``` The stream answers with the number of devices that received the reading: ```json {"count":1} ``` An answer of `{"count":0}` means that no device has this serial number, or that the stream has not loaded the device yet. A wrong token answers `401`, and invalid data answers with the error of the field: ```json [{"name":"sn","error":"The field \"sn\" is invalid","path":"sn"}] ``` ## Check the result Open **Sensors** or the device detail. The three sensors are online and show `21.4 °C`, `48 %` and `87 %`. Send a few more readings with other values and open the history of a sensor. To send many readings without typing them, use [Simulations](../../guides/simulations/). --- title: The driver file project: IoT Platform version: 1.0 section: development language: en license: Total.js Enterprise url: https://totaljs.es/docs/iot/1-0/development/driver-file/ updated: 2026-11-20T06:56:18.114Z --- # The driver file > The parts of a driver file: the server script, the settings form and the read me. A driver is one HTML-like file with up to three parts. Only the first one is required. ```html The description shown in Read me, in Markdown. ``` ## The server script The code in ` Receives batches of readings on `POST /demohub/` and passes each reading to the device with the same serial number. ``` ```bash curl -X POST https://stream.example.com/demohub/ \ -H 'Content-Type: application/json' \ -d '[{"sn":"WS-0001","temperature":20.8},{"sn":"WS-0002","humidity":57}]' ``` The answer is `{"count":2}`. Each device processes its reading in its own `instance.message`. The **Extensions** list in **Drivers** shows the installed extensions. ## The notify address Without a route of its own, a driver can receive data at the notify address of the stream, one address for each device: ```text POST https://stream.example.com/notify/stream-/ ``` The stream calls `instance.notify` of that device with the request: ```js instance.notify = function(req) { if (req.method === 'POST') instance.message(instance.newmessage(req.body)); }; ``` The stream answers `{"success":true}`. The address has no token check of its own: check `req.headers` in `instance.notify` when the data must come from a known sender. --- title: Outputs and history project: IoT Platform version: 1.0 section: development language: en license: Total.js Enterprise url: https://totaljs.es/docs/iot/1-0/development/outputs-and-history/ updated: 2026-11-20T06:56:18.114Z --- # Outputs and history > Define the values a device measures, how they are shown and how their history is kept. Each item of `exports.outputs` becomes a sensor of every device of the driver: ```js exports.outputs = [ { id: 'temperature', type: 'number', name: 'Temperature', format: '{0} °C', decimals: 1, stats: 'hourly' }, { id: 'humidity', type: 'number', name: 'Humidity', format: '{0} %', decimals: 0, stats: 'hourly' }, { id: 'battery', type: 'number', name: 'Battery', format: '{0} %', decimals: 0, stats: 'daily' } ]; exports.offline = '2 hours'; ``` ## The properties of an output - `id`: identifies the output in the driver. Send values to it by this id. - `name`: the name of the sensor. People can rename it in the [Dictionary](../../guides/dictionary/) or for one device. - `type`: `number`, `string`, `boolean` or `date`. - `format`: how the value is shown. `{0}` is the value. A key of the device configuration in braces, such as `{unit}`, is replaced by its value. - `decimals`: the number of decimals shown for numbers. - `stats`: how the history is summarised: `none`, `minutely`, `hourly`, `daily`, `monthly` or `yearly`. - `offline`: how long the sensor stays online without a new value, for example `'2 hours'`. Without it, the output uses `exports.offline`. - `category`: the category of the sensor. Without it, the category is the id of the output. Categories appear in the [Dictionary](../../guides/dictionary/). ## Statistics For every value, the stream keeps the minimum, the maximum and the number of values of the interval in `stats` and of every longer interval. An output with `stats: 'minutely'` fills the minutely, hourly, daily, monthly and yearly history; `hourly` starts at hours. The interval can be changed for each device in the device detail. When the timeline of a sensor is on, the stream also keeps every single value. ## Send a value ```js instance.newmessage(21.4).send('temperature'); ``` ## Write a value without statistics `instance.lastvalue(output, value)` sets the last value of a sensor without adding it to the statistics: ```js instance.lastvalue('battery', 85); ``` ## Read the last value `instance.readvalue(output)` returns a promise with the last stored value of a sensor of this device, its previous value and the time: ```js instance.message = async function($) { var last = await instance.readvalue('counter'); // last = { value: 5, prev: null, ts: Date } or undefined var difference = last ? $.data.counter - last.value : 0; instance.newmessage($.data.counter).send('counter'); $.destroy(); }; ``` Numbers come back as numbers and booleans as booleans. --- title: Settings and options project: IoT Platform version: 1.0 section: development language: en license: Total.js Enterprise url: https://totaljs.es/docs/iot/1-0/development/settings-and-options/ updated: 2026-11-20T06:56:18.114Z --- # Settings and options > Give each device its own configuration and the whole driver its own options. A driver has two kinds of settings: - The **configuration** belongs to one device. People change it with **Options > Configure** in the device detail. - The **options** belong to the driver and apply to all its devices. People change them with **Drivers > ... > Settings**. ## Configuration of a device Set the default values in `exports.config` and add a `` form with a field for each key: ```html
Temperature correction (°C)
``` A new device starts with a copy of `exports.config`. The `config` argument of `exports.make` holds the configuration of the device, and the stream applies a changed configuration within three minutes. `config.sn` holds the **Device identifier** too. Without a `` part, the device menu has no **Configure** item. ## Options of the driver `exports.options` lists the options with their default values: ```js exports.options = [{ id: 'token', type: 'string', name: 'Token', value: '' }]; ``` The **Settings** dialog of the driver shows one field for each option. In the code, the values are in `com.options` in `exports.install`, and in `instance.module.options` in `exports.make`: ```js exports.make = function(instance, config) { instance.message = function($) { var token = instance.module.options.token; // ... }; }; ``` Saving a new version of the driver keeps the values people set. The stream applies changed options within three minutes. --- title: Commands project: IoT Platform version: 1.0 section: development language: en license: Total.js Enterprise url: https://totaljs.es/docs/iot/1-0/development/commands/ updated: 2026-11-20T06:56:13.114Z --- # Commands > Let people send commands to a device from its detail and handle them in the driver. A command is an input of the driver with a small form. People send it with **Commands** in the device detail, and the driver receives it in `instance.message`. ## Define a command Add an input with an `html` property. The HTML is the form of the command, and each field writes to one key of the payload: ```js exports.inputs = [ { id: 'input', name: 'Input' }, { id: 'interval', name: 'Change interval', html: 'Minutes between readings' } ]; ``` Inputs without `html` are not commands. The **Commands** button is available only when the driver has at least one command. ## Handle a command `$.input` is the id of the input, and `$.data` is the payload of the form: ```js instance.message = function($) { if ($.input === 'interval') { instance.debug('Interval changed to', $.data.minutes, 'minutes'); // Send the new interval to the device here $.destroy(); return; } // ... readings $.destroy(); }; ``` The stream checks for new commands every five seconds and delivers each command once. How the command reaches the device, for example through an API of the device, is up to the driver. --- title: Storage project: IoT Platform version: 1.0 section: development language: en license: Total.js Enterprise url: https://totaljs.es/docs/iot/1-0/development/storage/ updated: 2026-11-20T06:56:18.114Z --- # Storage > Keep your own data of a driver in database tables and read it in reports. A driver can keep its own tables in the PostgreSQL database, for example every raw reading or the state of a parking lot. Declare the tables in `exports.storage`, and the platform creates them when you save the driver. ## Declare a table ```js exports.storage = [{ id: 'readings', name: 'Readings', columns: [ { id: 'sn', name: 'Serial number', type: 'string' }, { id: 'temperature', name: 'Temperature', type: 'number' } ] }]; ``` The column types are `string`, `number`, `boolean`, `date` (date and time), `date2` (date only), `smallint` and `integer`. Every table also gets an `id` and a `dtcreated` column with the time of the insert. When you change the columns and save the driver again, the platform adds, changes and removes the columns. Removing a table from `exports.storage`, or removing the driver, deletes the table and its data. ## Insert a row ```js instance.storage.insert('readings', { sn: data.sn, temperature: temperature }); ``` Only the declared columns are written. The `id` and `dtcreated` are filled in automatically. ## Read the data The tables are in the `storage` schema. Their names start with `db`, followed by a code made from the id of the driver and the id of the table. List them with this query in a report preview: ```sql SELECT table_name FROM information_schema.tables WHERE table_schema = 'storage' ``` Then read a table in a report: ```sql SELECT sn, temperature, dtcreated FROM storage.db1yr6f1treadings ORDER BY dtcreated DESC ``` See [Keep every reading of a device in a report](../../recipes/keep-raw-readings/). --- title: Alerts and debugging project: IoT Platform version: 1.0 section: development language: en license: Total.js Enterprise url: https://totaljs.es/docs/iot/1-0/development/alerts-and-debugging/ updated: 2026-11-20T06:56:13.114Z --- # Alerts and debugging > Report problems of a device as alerts and write debug messages to the log of the stream. ## Report an alert `instance.throw(message)` creates an alert for the device. It appears on the **Alerts** screen with the name of the device: ```js if (data.battery < 10) instance.throw('Battery low: ' + data.battery + ' %'); ``` ![An alert about a low battery](/files/JaszP81s061f.webp) Report what the people who look after the devices must act on. See [Alerts](../../guides/alerts/). ## Write debug messages `instance.debug()` writes a line to `logs/debugger.log` in the folder of the stream. It takes up to four values: ```js instance.debug('Interval changed to', $.data.minutes, 'minutes'); ``` The stream writes the collected lines once a minute. Each line has the time in UTC, the name of the driver and the id of the device: ```text 2026-11-20 05:49:44 Demo weather station (JasoWV1cL61f) Interval changed to 15 minutes ``` ## Check what the stream runs The [status page of the stream](../../guides/stream/) lists every device and extension with its counters. When a device is missing, the stream has not loaded it yet or the device is disabled. ## Test with real data Replay recorded readings with [Simulations](../../guides/simulations/), or post them with `curl` as in [Your first driver](../first-driver/). --- title: Driver reference project: IoT Platform version: 1.0 section: development language: en license: Total.js Enterprise url: https://totaljs.es/docs/iot/1-0/development/driver-api/ updated: 2026-11-20T06:56:13.114Z --- # Driver reference > Every property and function a driver sets on exports. A driver sets these properties and functions on `exports` in its `