---
title: Outputs and history
project: IoT Platform
version: 1.0
section: development
language: en
translation: missing
license: Total.js Enterprise
url: https://totaljs.es/docs/fr/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.
