Spanish Total.js
Italiano
Documentazione Per agenti IA
Indice

The driver file

The parts of a driver file: the server script, the settings form and the read me.

.md Sito web

Questa pagina non è ancora tradotta. Stai leggendo l’originale.

In questa pagina

A driver is one HTML-like file with up to three parts. Only the first one is required.

<script total>
    // The server script: exports.id, exports.outputs, exports.make, ...
</script>

<settings>
    <!-- The form for the configuration of one device -->
</settings>

<readme>
The description shown in Read me, in Markdown.
</readme>

The server script

The code in <script total> runs on the stream. It sets properties and functions on exports. When you select SUBMIT in the editor, Admin runs the script once to read these properties. A syntax error stops the save and shows the error, for example SyntaxError: Unexpected token ';'.

exports.id identifies the driver. Use only lower-case letters and digits, for example demoweather. When you save a file with an id that already exists, it replaces that driver. Every property is listed in Driver reference.

The settings form

The <settings> part is the form that opens with Options > Configure in the device detail. Each field writes to one key of the configuration of the device, with ?. in front of the key:

<settings>
    <div class="padding">
        <div class="grid-4">
            <div class="m">
                <ui-component name="input" path="?.offset" config="type:number">Temperature correction (°C)</ui-component>
            </div>
        </div>
    </div>
</settings>

See Settings and options.

The read me

The <readme> part is Markdown. People read it with Read me in Drivers and in the device detail. Describe the address the driver listens on, the data it expects and whether it needs a token.

Fatto in Europa