LooT Manuals
Deutsch

Recipes

Twelve tasks from start to finish with complete command sequences – from CSV import and nightly backups to scripts as components.

Each recipe is a self-contained command sequence that you can adapt and copy. The examples use the tenant Brewery and the node Brewery/Plant.Line1.Temperature; set server, tenant, path and user with the gear icon at the top. The messages of the loot program are currently in German. Where a recipe needs special rights, this is stated right at the start.

Recipe 1: Load historical data from a CSV file#

Goal: Take measurements of the last months from a table into a node.

Prerequisite: You are signed in (loot login) and may write to the target.

First create the node with a value type and unit, if it does not exist yet:

console
$ loot node create Brewery/Plant.Line1.Temperature --type double --unit "°C" --description "Temperature line 1"
Node 'Brewery/Plant.Line1.Temperature' angelegt (Id 4712).

The CSV file has two columns, zeitstempel (timestamp) and wert (value), with or without a header line. Timestamps without an offset always count as UTC; with an offset (Z, +01:00) they keep it:

csv
zeitstempel,wert
2026-10-01T00:00:00Z,17.4
2026-10-01T00:05:00Z,17.6
2026-10-01T00:10:00Z,17.9

Import the file with a fixed path:

console
$ loot import temperature-october.csv --path Brewery/Plant.Line1.Temperature
3 Werte angenommen, 0 abgelehnt.

The import is "all or nothing": if the file contains errors, loot sends nothing and names the faulty lines. For several nodes in one file use the three columns pfad,zeitstempel,wert (path, timestamp, value) and omit --path; give a semicolon as the separator with --separator ";". To check, query the values:

console
$ loot query Brewery/Plant.Line1.Temperature --from 2026-10-01 --limit 3

More in Writing and importing values and Queries and live values.

Recipe 2: Automate with a service account#

Goal: A script or a cron job writes values without anyone having to sign in through a browser.

Prerequisite: The operator has created a confidential client in the sign-in administration and given you its id and secret. The service account needs membership in the tenant and write rights on the nodes, just like a user (Permissions).

Put the secret into a file that only the executing account can read:

console
$ install -m 600 /dev/null /etc/loot/feeder.secret
$ printf '%s' 'SECRET-FROM-THE-OPERATOR' > /etc/loot/feeder.secret

Sign the account in with a configuration folder of its own so that it does not overwrite your personal sign-in (Configuration):

console
$ export LOOT_CONFIG_DIR=/var/lib/loot-feeder
$ loot login --server loot.example.org --client-id loot-feeder --client-secret-file /etc/loot/feeder.secret

loot stores only the client id and the path of the file; every call fetches a fresh token, so the sign-in never expires. A cron entry is then enough:

text
*/5 * * * * LOOT_CONFIG_DIR=/var/lib/loot-feeder loot write Brewery/Plant.Line1.Temperature "$(cat /run/sensors/line1-temp)"

Check the exit code (0 = success) in your script to notice failed writes (Exit codes).

Recipe 3: Nightly backup with Exchange jobs#

Goal: The plant is backed up every night, and the last seven backups are kept.

Prerequisite: A system admin creates the target (once); you create the job yourself with Read and Manage on the root node.

Create the target (system admin):

console
$ loot exchange target add nightly --kind local --location Brewery
Ziel 3 angelegt: nightly (lokal, Brewery)

Create the job. The interval 1d with --at means: daily at a fixed time of day in UTC:

console
$ loot exchange job create "Plant nightly" --node Brewery/Plant --target nightly --every 1d --at 02:30 --keep 7 --keep-days 30
Exchange-Job 12: Plant nightly (eingeschaltet)
Wurzel: Node 4711, Ziel 3, alle 1440 Minuten um 02:30 UTC
Aufbewahrung: 7 Snapshots, 30 Tage; Werte: ja, Rechte: nein, Abhängigkeiten: ja
Nächster Lauf: 2026-12-01T03:30:00.000000+01:00

Test the job right away and check the result:

console
$ loot exchange run 12
Exchange-Job 12 ist fällig; Läufe: loot exchange runs 12
$ loot exchange runs 12
88  erfolgreich     2026-11-30T14:02:11.114000+01:00  71230411 Bytes
$ loot exchange snapshots 12
42  2026-11-30T14:02:11.114000+01:00  71230411 Bytes  voll

Details are in Exchange.

Recipe 4: Restore a subtree from a backup#

Goal: A subtree was changed by mistake; you bring back yesterday's state.

Prerequisite: You are a tenant admin or system admin.

Find the matching snapshot and first check in a dry run what would happen:

console
$ loot exchange snapshots 12
42  2026-12-01T03:30:02.114000+01:00  1920348 Bytes  inkrementell
41  2026-11-30T03:30:01.870000+01:00  71230411 Bytes  voll
$ loot exchange restore --snapshot 41 --into Brewery --overwrite --dry-run

The report names conflicts and the number of nodes that would be created, aligned or deleted. If everything fits, run the command without --dry-run:

console
$ loot exchange restore --snapshot 41 --into Brewery --overwrite

Without --overwrite the command only creates missing nodes; with --prune it also deletes children that the snapshot does not know. If you would rather see the old state next to the current one, import it as a copy: loot exchange import --snapshot 41 --under Brewery --as "Plant (state of 30 Nov)".

Recipe 5: Export values as CSV for a spreadsheet#

Goal: Hourly averages of one month for all nodes below Plant.Line1 in a CSV file.

console
$ loot values export Brewery/Plant.Line1 --from 2026-11-01 --to 2026-12-01 --bucket 1h --functions avg,min,max -o line1-november.csv
Export 5 gestartet: 3 Nodes von 'Brewery/Plant.Line1'.
Ergebnis gespeichert: line1-november.csv (412.3 KiB).

--from and --to are required (--to excludes the instant). Without --bucket and --functions you get the raw values. With --unit K you convert to another unit, with --exclude you leave nodes out, with --include you pick individual nodes with their descendants. The export runs on the server; loot waits and downloads the result. For very large exports start with --no-wait and fetch the result later with loot values export-show <number> -o file.csv; a running export can be cancelled with loot values export-cancel <number>. For programs, --format ndjson is a good fit. Further options, including password protection, are described in Exporting values.

Recipe 6: Follow live values#

Goal: During commissioning you see new values in the terminal immediately.

console
$ loot live Brewery/Plant.Line1.Temperature Brewery/Plant.Line1.Pressure
Warte auf Werte von 2 Node(s) … (Strg+C beendet)

Every new value appears on a line with timestamp, path, value and unit, for example 2026-11-30T14:05:12.331000+01:00 Brewery/Plant.Line1.Temperature = 18.2 °C. Ctrl+C ends the display. With --unit you show other units, one per quantity, separated by commas (--unit °F,bar). If your read right on a node is withdrawn, you get the message "Das Leserecht wurde entzogen" and the display for that node ends. To test, write a value in a second terminal:

console
$ loot write Brewery/Plant.Line1.Temperature 18.2
Wert geschrieben: Brewery/Plant.Line1.Temperature = 18.2 (2026-11-30T14:05:12.331000+01:00).

See Queries and live values.

Recipe 7: Clone a plant from a template#

Goal: Line 2 should be built exactly like line 1.

The quickest way is cloning. It copies the subtree with links and connections, but without values and permissions:

console
$ loot node clone Brewery/Plant.Line1 Brewery/Plant --name Line2 --wait

If the structure is to serve as a lasting blueprint, create a template and produce any number of nodes from it:

console
$ loot template create Brewery/Plant.Line1 --name "Filling line"
$ loot template list Brewery
$ loot node create Brewery/Plant.Line3 --template "Filling line"
Node 'Brewery/Plant.Line3' aus Template 'Filling line' (Version 1) angelegt (Id 4801); 0 Defaultwert(e) geschrieben.

If the template changes later, switch existing nodes to the new version with loot node migrate-template, without losing values. See Nodes.

Recipe 8: Give a team read access#

Goal: The group Operators should be able to view the plant but not change it.

Prerequisite: You are a tenant admin or hold Manage on the nodes; the group exists in the tenant.

console
$ loot permission grant --tenant Brewery --group Operators --rights read --node Brewery/Plant

The entry applies to the node and – by inheritance – to everything below it. Give several targets by repeating the options, also mixed:

console
$ loot permission grant --tenant Brewery --group Operators --rights read --chart "Daily overview" --dashboard "*" --skip-missing

Address a single user with --user alice (display name or e-mail address) instead of --group. With --deny you forbid instead of allow. The right to write values is called write; separate several rights with commas (--rights read,write). See Permissions.

Recipe 9: Monitor a threshold with a script#

Goal: A script sets the node Plant.Line1.TemperatureAlarm to "true" as soon as the temperature reaches 80 °C.

Prerequisite: You hold the rights to create scripts and components in the tenant (create-scripts, create-components).

Save the script as threshold.py. The comment lines at the start describe mode, inputs and outputs:

python
# loot:mode reactive
# loot:description Alarm when a threshold is exceeded
# loot:input value float required nullable -- Measured value
# loot:input threshold float default=80
# loot:output alarm bool nullable

def run(ctx):
    for item in ctx.inputs.follow("value"):
        if item.value is None:
            ctx.outputs.write("alarm", None, item.timestamp)
        else:
            ctx.outputs.write("alarm", item.value >= ctx.inputs.get("threshold"), item.timestamp)

Create the script, provide the output node, make a component from it, bind and start it:

console
$ loot script create --tenant Brewery --name threshold --file threshold.py
$ loot node create Brewery/Plant.Line1.TemperatureAlarm --type bool
$ loot component create --tenant Brewery --name Overheat --entry Skript/threshold -i threshold=80
$ loot component bind --tenant Brewery --component Overheat --port value --input --node Brewery/Plant.Line1.Temperature
$ loot component bind --tenant Brewery --component Overheat --port alarm --output --node Brewery/Plant.Line1.TemperatureAlarm
$ loot component start --tenant Brewery Overheat

Check the state and watch the alarm:

console
$ loot component get Overheat --tenant Brewery --log
$ loot live Brewery/Plant.Line1.TemperatureAlarm

A reactive script runs until you stop it with loot component stop --tenant Brewery Overheat. Save a new version of the script as a new version with loot script update threshold --tenant Brewery --file threshold.py and switch the component over with loot component set-version Overheat --tenant Brewery --version <x.y.z> (--check verifies beforehand). See Scripts and components.

Recipe 10: Run a ready-made component from the library once#

Goal: Start a catalog entry once, wait for the end and read the result.

console
$ loot library list
$ loot library run <classification/name> --tenant Brewery -i <input>=<value> -o <output>=Brewery/Plant.Line1.Result --wait

loot library list shows the available entries with their inputs and outputs; replace the details in angle brackets with those from your list. -i sets an input, -o routes an output into a node (the node must have direction IN and you need Write). With --wait the command ends only when the run has ended; the exit code is 0 only on success. loot run get <number> later shows the run with log and outputs, using the run number from the output; loot run stop <number> stops a running run.

Recipe 11: Move a plant to another tenant or installation#

Goal: The plant Plant with its values from 2026 on appears as a copy in another tenant.

Check the size, save and verify the file:

console
$ loot exchange preview Brewery/Plant
$ loot exchange export Brewery/Plant -o plant.loot-exchange.zip --from 2026-01-01
$ loot exchange verify plant.loot-exchange.zip

Sign in to the destination installation (with a LOOT_CONFIG_DIR of its own if needed, see Configuration) and import in a dry run first:

console
$ loot exchange import plant.loot-exchange.zip --under Partner --dry-run
$ loot exchange import plant.loot-exchange.zip --under Partner

The report of the dry run names conflicts, such as an alias that is already taken (then --no-aliases) or users and groups that do not exist in the target tenant (--with-rights --map). See Exchange.

Recipe 12: Roll out a stack revision#

Goal: As operator, you roll out the current revision to all machines.

Prerequisite: You are a system admin. You saved the revision beforehand on the System page of the workbench.

console
$ loot stack revisions
$ loot stack status
$ loot stack rollout

loot stack rollout rolls the core out first and shows every change per machine; the exit code is 0 only if all machines succeeded. Afterwards loot stack status checks the target/actual comparison. See Stack.

A product of Rheinwert Datentechnik · rheinwert.deVersion: LooT 0.9.10