Senzorv1.0.1

Validation errors

Every problem Senzor reports when it loads a project, what it means and how to fix it.

Senzor checks a project whenever it loads it: senzor-cli validate and senzor-cli run check it before they do anything else, and the GUI checks it after every edit and lists the problems in the Problems tab. This page lists every message. In the messages, <name> stands for a part that Senzor fills in.

Reading a problem

A problem reads <location>: <message>. senzor-cli puts the path of the project file in front:

project.toml: device `office`: unknown template `co-2`
LocationRefers to
line <L>, column <C>A TOML syntax or schema error at that position.
project fileA TOML error the parser cannot place.
brokerThe [broker] table.
template `<id>`The [[templates]] entry with this id.
device `<id>`The [[devices]] entry with this id.

How problems are reported, and what they block:

  • A TOML error stops loading, so it is the only problem reported. Fix it and validate again to see the rest.
  • Otherwise every problem is reported at once: broker problems first, then template problems in file order, then device problems in file order.
  • A broker problem blocks every device.
  • A template problem blocks every device that uses the template. Those devices get no message of their own.
  • A device problem blocks that device.
  • Senzor checks a device's other settings only when its template exists and has no problems, and checks its instance IDs and renders its templates only when those settings are valid, so fixing one problem can reveal the next.

senzor-cli validate and senzor-cli run run nothing while there is any problem, and exit with code 2. senzor-cli mcp prints the problems as warnings and serves the project anyway. The GUI runs the devices that are not blocked; see Editing while running.

File syntax and schema

These come from the TOML parser and carry a line and column. The most common ones:

ExampleMeaning and fix
unknown field `prot`, expected one of `host`, `port`, …A key that this table does not have. Fix the spelling; the message lists the valid keys.
missing field `template`A required key is missing. Add it.
invalid type: string "x", expected u16The value has the wrong type, here a string where a number belongs.
invalid value: integer `70000`, expected u16The number is out of range; a port is at most 65535.
invalid value: integer `-1`, expected u64The number must not be negative, as for seed.
invalid value: string "30", expected a durationA duration without a unit. Write "30s".
invalid type: integer `30`, expected a durationA duration written as a number. Write it as a string with a unit, "30s".
unknown variant `linear`, expected one of `constant`, `random_walk`, `sine`, `uniform`, `sequence`, `script`An unknown generator name.
unknown variant `4`, expected `5` or `3.1.1`mqtt_version is not "5" or "3.1.1".
wanted string or tableOften mqtt_version = 5 without quotes. Write mqtt_version = "5".
missing field `generator`A field table without a generator key.
invalid type: sequence, expected a number, a boolean or a stringA param or value that is a list, such as [1, 2]. A table gives the same message with map.
unclosed table, expected `]`A TOML syntax error.

See Project file reference for every key and its type.

Broker

MessageMeaning and fix
host must not be emptyhost is empty or only spaces.
port must not be 0Use the broker's port, 1 to 65535.
keep_alive must be at least 1sSet keep_alive to "1s" or more.
keep_alive must be whole seconds, got <duration>Write keep_alive in whole seconds, such as "30s".
keep_alive must be at most 65535 seconds (18h 12m 15s)MQTT sends the keep-alive as a 16-bit number of seconds. Use a shorter duration.
session_expiry must be at most 4294967295 secondsMQTT counts it in a 32-bit number of seconds (about 136 years). Use a shorter duration.
path `<path>` must start with /With transport = "websocket", write the WebSocket path with its leading slash, such as "/mqtt".
use either password or password_env, not bothRemove one of them.
environment variable `<name>` (password_env) is not setSet the variable before you start Senzor or run senzor-cli.
a password requires a usernameAdd username, or remove the password.
cannot read tls.<key> `<path>`: <reason>A TLS file (ca_file, client_cert or client_key) cannot be read. Relative paths start at the folder of the project file.
tls.client_cert and tls.client_key must be set togetherSet both, or neither.
tls.client_cert requires tls.ca_fileAdd ca_file when you use a client certificate.
tls.ca_file `<path>` holds no PEM certificateThe CA file is not a PEM certificate (-----BEGIN CERTIFICATE-----). The same message names tls.client_cert for the client certificate.
tls.client_key `<path>` holds no PEM private keyThe client key file is not a PEM private key.
tls.client_key: <reason>The client certificate and key cannot be used together, for example because the key does not belong to the certificate.
no trusted certificates found on this system; set tls.ca_fileTLS without ca_file uses the system's trusted certificates, and none were found.
session_expiry must be whole seconds, got <duration>Write session_expiry in whole seconds, such as "60s".
session_expiry needs MQTT 5; the broker settings use MQTT 3.1.1Set session_expiry to "0s" (or remove it), or switch mqtt_version to "5".

Templates

MessageMeaning and fix
`<id>` is a built-in template id; choose another idco2, temperature and humidity are taken by the built-in templates. Rename the template. Devices that use the ID keep using the built-in one.
duplicate template idTwo templates have the same id. Rename one.
at least one message is requiredmessages is empty.
at least one field is requiredfields is empty.
qos must be 0, 1 or 2, got <n>Set qos to 0, 1 or 2.
interval must be greater than 0interval is "0s".
field `<name>` uses a reserved nameRename the field; see reserved names.
field `<name>`: <problem>The field's generator breaks a rule, or its unit or name is empty; see Field problems.
syntax error: <details> (in <template>:<line>)A topic, payload or user property is not valid Jinja. <template> is messages[<n>].topic, messages[<n>].payload, messages[<n>].user_properties.<name>, availability.topic or subscriptions[<n>].topic, with messages and subscriptions counted from 1.
messages[<n>].message_expiry must be whole seconds, got <duration>Write the expiry in whole seconds, such as "60s".
messages[<n>].message_expiry must be at least 1sRemove message_expiry for no expiry, or set "1s" or more.
messages[<n>].content_type must not be emptyRemove content_type, or give it a value such as "application/json".
<key> needs MQTT 5; the broker settings use MQTT 3.1.1<key> is messages[<n>].message_expiry, messages[<n>].content_type, messages[<n>].user_properties or availability.will_delay. Remove it, or switch mqtt_version to "5".
<key> must be at most 4294967295 seconds<key> is messages[<n>].message_expiry or availability.will_delay. Use a shorter duration.
message <n>: encoding protobuf needs a proto fileMessage <n> (counted from 1) has encoding = "protobuf" but no proto. Give the .proto file that defines its message type. See Binary payloads.
message <n>: encoding protobuf needs a message typeMessage <n> has encoding = "protobuf" but no message. Give the fully qualified type, such as "sensors.v1.Reading".
message <n>: proto is used only with encoding protobufMessage <n> sets proto with another encoding. Remove proto, or set encoding = "protobuf".
message <n>: message is used only with encoding protobufMessage <n> sets message with another encoding. Remove message, or set encoding = "protobuf".
message <n>: cannot read proto `<path>`: <reason>The .proto file cannot be read, for example No such file or directory (os error 2). A relative path starts at the folder of the project file.
message <n>: proto `<path>`: <file>:<line>:<column>: <error>The .proto file, or a file it imports, does not compile, for example proto `proto/sensor.proto`: sensor.proto:4:1: expected ';' or '[', but found '}' or sensor.proto:2:1: import 'units.proto' not found. Imports are looked up in the folder of the .proto file, then among protobuf's well-known types.
message <n>: proto `<path>` has no message type `<type>`The file defines no message type of that name. When the name is a message's short name, the problem ends with ; did you mean `<package>.<type>`?: message takes the fully qualified name.
availability.will_delay must be whole seconds, got <duration>Write the delay in whole seconds, such as "30s".
availability.will_delay <delay> is longer than the broker's session_expiry <expiry>; set session_expiry to at least <delay>MQTT 5 brokers may send the Last Will when the session ends, before the delay passes. Raise session_expiry in [broker].
subscription <n>: qos must be 0, 1 or 2, got <q>Set the qos of subscription <n> (counted from 1) to 0, 1 or 2.
subscription <n>: script is emptySubscription <n> has an empty script. Write the script that runs for each message.
subscription <n>: script does not compile: <reason>The script of subscription <n> is not valid Rhai. <reason> names the line and position, such as Expecting ';' to terminate this statement (line 2, position 1). See Scripts and commands.

A syntax error is reported for the first broken template string only. For example, a payload {{ v without the closing braces gives syntax error: unexpected end of input, expected end of variable block (in messages[1].payload:1).

Field problems

Reported as field `<name>`: <problem> in a template, and as field `<name>` override: <problem> in a device. See Generators for the parameters and Fields for unit and name. A field can have one generator problem, and an empty unit or name and a script problem on top of it.

ProblemMeaning and fix
unit must not be emptyThe field has unit = "". Remove unit, or give it a value such as "ppm".
name must not be emptyThe field has name = "". Remove name, or give it a value such as "CO2".
numbers must be finiteA parameter or value is nan, inf or -inf.
noise must be greater than 0Remove noise or make it positive.
noise requires numeric valuesnoise on a constant or sequence whose values are not all numbers.
min must be less than maxrandom_walk or uniform with min equal to or above max.
start must be between min and maxMove start inside the bounds of the random_walk.
step must be greater than 0Give the random_walk a positive step.
period must be greater than 0Give the sine a period longer than "0s".
values must not be emptyGive the sequence at least one value.
script is emptyA script field has an empty script.
script does not compile: <reason>The field's script is not valid Rhai. <reason> names the line and position, such as Script is incomplete (line 1, position 8). See Scripts and commands.

Devices

MessageMeaning and fix
unknown template `<id>`No template in the file or among the built-ins has this ID. Check the spelling.
duplicate device idSeveral devices have this id. It is reported once and blocks all of them. Rename all but one.
count must be at least 1count is 0.
interval must be greater than 0The device's interval is "0s".
param `<name>` uses a reserved nameRename the param; see reserved names.
param `<name>` has the same name as a fieldThe template has a field with this name. Rename the param.

Rendering problems

Senzor renders each device's templates once while it validates, for the first instance and with sample values (see Template variables), and the topics of its subscriptions for every instance. It reports the first failure.

MessageMeaning and fix
undefined value: `<name>` is undefined (in <template>:<line>)A template uses a variable that does not exist here: a typo, a param this device does not set, or a variable this template string cannot see. For a user property the message starts with messages[<n>].user_properties.<name>: . A subscription topic, subscriptions[<n>].topic, sees the variables of the availability topic.
availability topic: topic is emptyThe availability topic renders to nothing.
availability topic: topic `<topic>` contains a wildcard (+ or #)The rendered availability topic contains + or #, maybe from a param.
message <n> topic: topic is emptyMessage <n> (counted from 1) has a topic that renders to nothing.
message <n> topic: topic `<topic>` contains a wildcard (+ or #)The rendered topic of message <n> contains + or #.
subscription <n> topic is emptySubscription <n> (counted from 1) has a topic that renders to nothing.
subscription <n> topic `<topic>`: `#` must be the whole last level, as in `a/#`The rendered filter has # before its last level, or next to other characters in a level, such as a/#/b or a#.
subscription <n> topic `<topic>`: `+` must be a whole level, as in `a/+/b`The rendered filter has + next to other characters in a level, such as a+.
message <n> payload as hex: odd number of hex digits (<count>)With encoding = "hex", the payload renders to an odd number of hex digits. Each byte takes two; the byte filters always write whole bytes.
message <n> payload as hex: `<character>` is not a hex digitThe payload renders to something other than hex digits and whitespace.
message <n> payload as base64: `<character>` is not a base64 characterWith encoding = "base64", the payload is not standard base64. URL-safe base64 (- and _) is not accepted.
message <n> payload as base64: base64 needs padding (=) to a multiple of 4 charactersThe base64 text lacks its = padding, or has it in the wrong place. Other base64 problems: the length does not fit base64; a character is missing or one too many and the last character `<c>` leaves bits over; the text is cut short or changed.
message <n> payload as CBOR: not JSON: <reason>With encoding = "cbor", the payload must render to JSON, such as {"co2": 600}. <reason> names the line and column.
message <n> payload as protobuf: <reason>With encoding = "protobuf", the payload does not render to JSON in protobuf's JSON mapping for the message type: invalid JSON, a key the message does not have, or a value of the wrong type, such as unrecognized field name 'pressure' at line 1 column 11.
<filter>: <value> is out of range (<min> to <max>)An integer byte filter, such as u8, gets a value its type cannot hold, after rounding: u8: 256 is out of range (0 to 255). Scale or clamp the value, or use a wider type.
<filter>: expected a number, got <kind>A byte filter gets a string or a boolean.
<filter>: <value> is out of range for a 32-bit floatf32be or f32le gets a number larger than a 32-bit float holds. Use f64be or f64le.
Other MiniJinja errors, e.g. unknown filter: filter <name> is unknown (in <template>:<line>)A filter or operation fails on the sample values.

Field overrides

MessageMeaning and fix
override of unknown field `<name>`The device overrides a field its template does not have. Check the field name.
field `<name>` override: <problem>The field after the override is not valid. <problem> is one of the field problems or a schema error such as missing field `max` (an override with generator replaces the whole generator, so it needs every parameter) or unknown field `stepp`, expected one of `start`, `min`, `max`, `step`, `noise`.

See Field overrides for how overrides merge.

Instance IDs

MessageMeaning and fix
instance_id: syntax error: <details> (in <string>:1)instance_id is not valid Jinja.
instance_id: undefined value: `<name>` is undefined (in <string>:1)instance_id uses a variable it cannot see. It can use id, index and the device's params.
instance_id renders to an empty stringinstance_id produces an empty ID.
instance id `<id>` repeats; include {{ index }} in instance_idTwo instances of the device get the same ID. With count above 1, put {{ index }} in instance_id.
instance id `<id>` is already used by device `<device>`An instance ID of this device is also an instance ID of an earlier device that has no problems. Change instance_id or the device id.

(in <string>:1) is literal text: it is how MiniJinja names the instance_id template.

On this page