Built-in templates
The co2, temperature and humidity templates that every project can use without declaring them.
Senzor ships three templates: co2, temperature and humidity. Every project can use them by ID,
without a [[templates]] entry:
[[devices]]
id = "office"
template = "co2"
count = 2Overview
All three publish every 10 seconds with QoS 0 and no retain flag, and use the availability topic
senzor/{{ device_id }}/status with the payloads online and offline.
| Template | Message topic | Payload | Field |
|---|---|---|---|
co2 | senzor/{{ device_id }}/co2 | co2 rounded to a whole number, and ts | co2: random_walk from 600, between 400 and 2000, step 15 |
temperature | senzor/{{ device_id }}/temperature | temperature rounded to 1 decimal, and ts | temperature: sine around 21.5, amplitude 1.5, period 24 h, noise 0.1 |
humidity | senzor/{{ device_id }}/humidity | humidity rounded to 1 decimal, and ts | humidity: random_walk from 45, between 30 and 70, step 0.5 |
ts is the time of the tick in milliseconds since the Unix epoch (now_ms). The device above
publishes, among others:
senzor/office-0/status online
senzor/office-0/co2 {"co2": 600, "ts": 1760543594230}Definitions
This is the definition Senzor uses, taken from its source:
[[templates]]
id = "co2"
interval = "10s"
availability = { topic = "senzor/{{ device_id }}/status", online = "online", offline = "offline" }
messages = [
{ topic = "senzor/{{ device_id }}/co2", payload = '{"co2": {{ co2 | round | int }}, "ts": {{ now_ms }}}' },
]
fields.co2 = { generator = "random_walk", start = 600, min = 400, max = 2000, step = 15 }
[[templates]]
id = "temperature"
interval = "10s"
availability = { topic = "senzor/{{ device_id }}/status", online = "online", offline = "offline" }
messages = [
{ topic = "senzor/{{ device_id }}/temperature", payload = '{"temperature": {{ temperature | round(1) }}, "ts": {{ now_ms }}}' },
]
fields.temperature = { generator = "sine", center = 21.5, amplitude = 1.5, period = "24h", noise = 0.1 }
[[templates]]
id = "humidity"
interval = "10s"
availability = { topic = "senzor/{{ device_id }}/status", online = "online", offline = "offline" }
messages = [
{ topic = "senzor/{{ device_id }}/humidity", payload = '{"humidity": {{ humidity | round(1) }}, "ts": {{ now_ms }}}' },
]
fields.humidity = { generator = "random_walk", start = 45, min = 30, max = 70, step = 0.5 }
See Generators for the parameters and Template variables for the filters.
Changing a built-in template
Built-in templates cannot be edited, and a project template cannot use their IDs.
-
To change the values for one device, override its fields and interval in the device:
[[devices]] id = "server-room" template = "temperature" interval = "1m" fields.temperature = { center = 27, noise = 0.3 } -
To change topics or payloads, copy the template into your project under a new ID and edit the copy. In the GUI, a built-in template has a Copy into project… button for this; see Editing templates.