SensorBridge device definitions
SensorBridge turns the wireless sensors rtl_433 hears into HomeSeer devices. What it knows about each kind of sensor - what its readings are called, their units, which Dashboard card it gets and how that card is colored - lives in definitions: small JSON files anyone can write. This page explains how.
How definitions are used
SensorBridge carries its own built-in definitions. On top of them it lays, in this order:
- The SensorBridge catalog - definitions published on this site. Downloaded only if you switch it on (Setup, under Device definitions), checked once a day. Every catalog file is signed by the publisher and checked before use.
- Your own files - any
.jsonfile inData\SensorBridge\definitionsinside the HomeSeer folder. Laid on last, so yours always win.
The Definitions page in SensorBridge shows the folder, what each file changes, and exactly what is wrong with any file it could not use. A definition is data, never code: it can only name readings, choose and color cards, and set limits - it cannot make SensorBridge do anything else.
Your first definition
Say you have a tank sensor rtl_433 reports as {"model": "Some-Tank", "depth_cm": 55.2}. SensorBridge already shows
Depth cm 55.2; this file names it properly and gives it a card of its own:
{
"id": "my-sensors",
"version": 1,
"title": "My own sensors",
"fields": {
"known": { "depth_cm": { "label": "Water depth", "unit": "cm", "decimals": 1 } }
},
"cards": [
{ "kind": "tank", "title": "Water tank", "rank": 4, "layout": "single", "hero": "f:depth_cm",
"scale": "tank", "has": { "first": [ "depth_cm" ] } }
],
"scales": {
"tank": { "unit": "cm", "bands": [ [ 20, "#e03131", "Nearly empty" ], [ 60, "#e67700", "Low" ], [ 1e9, "#2f9e44", "OK" ] ] }
}
}
Save it as my-sensors.json in the definitions folder, open SensorBridge's Definitions page and press
Reload definitions. The page says in use and lists what it changed - or, if something is wrong, exactly what and where.
The file
| Setting | Meaning |
|---|---|
id | Required. A short name for the definition, e.g. "acme-tank". |
version | Required, 1 or more. Raise it when you change the file. |
title, description | Words shown on the Definitions page. |
fields, cards, scales, guides, calibration | What it changes - each below. |
"heros" - makes the whole file refused, so a typo
can never be silently ignored.fields - naming readings
Field names are rtl_433's, exactly as they appear on the sensor's card on SensorBridge's Sensors page (or in rtl_433's JSON
output). SensorBridge already reads units from rtl_433's naming conventions (_F, _C, _mi_h,
_inHg, _pct, _lux...), so a definition is needed only to do better.
fields.known
"fields": { "known": { "depth_cm": { "label": "Water depth", "unit": "cm", "decimals": 1 } } }
| Setting | Meaning |
|---|---|
label | What the reading is called - the HomeSeer feature's name for newly made features. |
unit | Shown after the value, e.g. "cm", "°F", "%", "" for none. |
decimals | 0 to 6. |
kind | measurement (the usual), counter (a running total), battery, or text. |
scale | A number to multiply by, above 0: e.g. seconds to days is 0.0000115740740740741. |
fields.hidden
Fields that are not readings - a message counter, a checksum: "hidden": [ "sequence" ]. Their features are removed
the next time you run Repair on the Support page (never automatically: an event might use one).
cards - the Dashboard
Each sensor gets one card on SensorBridge's Dashboard: the first card whose rules fit it (your cards and the catalog's are tried before the built-in ones), unless a card is chosen for that sensor on the Sensors page.
| Setting | Meaning |
|---|---|
kind | Required. A short name. The same kind as a built-in card replaces it. |
title | Required. How the card is offered on the Sensors page, e.g. "Water tank". |
layout | single (one reading made big, with its range and 12-hour line), meter (a utility meter's use),
weather (a weather station), or generic (every reading as a small tile). |
hero | The reading made big, as f: + the field name (the start is enough: f:temperature
matches temperature_F). Required for single and meter. |
scale or guide | What colors the hero reading - one or the other (below). Without either, a temperature uses the temperature colors. |
rank | Its place when the Dashboard is sorted by type: 0 weather, 1 thermometers, 2 fridges, 3 freezers, 4 everything else. |
hide | Readings to leave off the card, by the start of their key, e.g. [ "f:consumption" ]. |
note | A sentence shown under the card's heading. |
Which sensors a card is for
| Setting | The card fits a sensor when... |
|---|---|
has | ...it reports a field matching this selector (below). |
lacks | ...it does NOT report a field matching this selector. |
models | ...its rtl_433 model starts with one of these, ignoring case: [ "Acurite-515" ]. |
channelEndsWith | ...its channel ends with this, e.g. "F". |
All the given rules must hold. A card with none would fit every sensor and hide every card after it, so it is refused.
Selectors
| Selector | Matches |
|---|---|
{ "first": [ "depth_cm", "depth_in" ] } | a sensor reporting any of these exact fields |
{ "prefix": "pressure", "notContains": "tire" } | a field starting with this (optionally without that inside it) |
{ "any": [ selector, selector ] } | either |
{ "all": [ selector, selector ] } | both |
{ "role": "consumption" } | a built-in role (list below) |
A person can also pick any card for a sensor on the Sensors page, from those it has the reading for - which is how a probe the rules cannot recognise becomes a fridge.
scales - color bands
"scales": {
"tank": { "unit": "cm", "bands": [ [ 20, "#e03131", "Nearly empty" ], [ 60, "#e67700", "Low" ], [ 1e9, "#2f9e44", "OK" ] ] }
}
Each band is [ up to, "#rrggbb", "words" ]; the edges must rise, and the last is 1e9 ("and above"). A reading
gets the first band it is at or below. unit is the unit the edges are written in: "°F" and "mph" are
converted from a sensor reporting °C or km/h; anything else is compared as it comes. The words always show beside the color,
so nothing depends on color alone. A scale with the name of a built-in one replaces it, and on the Sensors page a person can move
a scale's edges for one sensor.
guides - a limit to keep below
Like the built-in fridge and freezer guides (FDA: 40 °F, 0 °F): a dashed limit line, and words for how far from it the reading is.
"guides": {
"wine": {
"limit": { "°F": 65, "°C": 18.3 }, "limitLabel": "Cellar: 65 °F or below",
"above": [ [ 70, "#e03131", "Too warm" ], [ 65, "#e67700", "Warm" ] ],
"below": [ [ 45, "#1c7ed6", "Too cold" ] ],
"inRange": [ "#2f9e44", "Good (45 to 65 °F)" ]
}
}
above is checked from the warmest down (the reading is above the number), below from the coldest up,
otherwise inRange. Numbers are °F; the limit is given in both units.
calibration
The largest offset SensorBridge accepts when someone calibrates a reading, per unit - enough for any real error, not for a
typo: "calibration": { "limits": { "cm": 5 } }.
The checks every file must pass
A file is used only if everything in it is right; otherwise none of it is, and the Definitions page says what and where (cards[0] - layout "radar" is not one the page draws). Among the checks:
- valid JSON, with
idandversion; only the settings on this page; - each card: a kind used once, a title, a known layout, a hero for single and meter cards, an existing scale or guide (not both);
- no card that fits every sensor;
- colors as
#rrggbb; scale edges rising; guide steps in order; both units on a guide's limit; - decimals 0-6, scales and calibration limits above 0.
Laid over the built-in definitions, the result must still pass every check the built-in ones pass.
Built-in names you can use
| Kind | Names |
|---|---|
| Cards | weather, freezer, fridge, soil, pool, temperature,
meter, barometer, gridstream, other |
| Scales | uv, wind, dew, humidity, strike, soil, pool |
| Guides | fridge, freezer |
| Roles | temperature, humidity, wind, gustField, pressure, uv,
strikes, strikeDistance, battery, lightBands, consumption, weatherStation |
Sharing a definition
If your definition makes a sensor better for you, it will for others too. Send the file - with the sensor's make and model and, if you can, a few lines of what rtl_433 prints for it - to plugins@cyberlogix.net, with SensorBridge definition in the subject. Good ones are added to the catalog, so everyone with the catalog switched on gets them.
The catalog's own files are at definitions/. SensorBridge reads rtl_433's output and does not include it; rtl_433 is free software by Benjamin Larsson and contributors, licensed under the GNU GPL v2.