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:

  1. 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.
  2. Your own files - any .json file in Data\SensorBridge\definitions inside 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

SettingMeaning
idRequired. A short name for the definition, e.g. "acme-tank".
versionRequired, 1 or more. Raise it when you change the file.
title, descriptionWords shown on the Definitions page.
fields, cards, scales, guides, calibrationWhat it changes - each below.
Anything else - including a misspelt setting such as "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 } } }
SettingMeaning
labelWhat the reading is called - the HomeSeer feature's name for newly made features.
unitShown after the value, e.g. "cm", "°F", "%", "" for none.
decimals0 to 6.
kindmeasurement (the usual), counter (a running total), battery, or text.
scaleA 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.

SettingMeaning
kindRequired. A short name. The same kind as a built-in card replaces it.
titleRequired. How the card is offered on the Sensors page, e.g. "Water tank".
layoutsingle (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).
heroThe reading made big, as f: + the field name (the start is enough: f:temperature matches temperature_F). Required for single and meter.
scale or guideWhat colors the hero reading - one or the other (below). Without either, a temperature uses the temperature colors.
rankIts place when the Dashboard is sorted by type: 0 weather, 1 thermometers, 2 fridges, 3 freezers, 4 everything else.
hideReadings to leave off the card, by the start of their key, e.g. [ "f:consumption" ].
noteA sentence shown under the card's heading.

Which sensors a card is for

SettingThe 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

SelectorMatches
{ "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:

Laid over the built-in definitions, the result must still pass every check the built-in ones pass.

Built-in names you can use

KindNames
Cardsweather, freezer, fridge, soil, pool, temperature, meter, barometer, gridstream, other
Scalesuv, wind, dew, humidity, strike, soil, pool
Guidesfridge, freezer
Rolestemperature, 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.