DocsClientsCapabilities, state and readings

Capabilities, state and readings

A client tells WBSKT what it is and which commands it takes, and reports what it is doing. WBSKT shows the latest values on the client's page and keeps the numbers as readings you can chart and export.

Capabilities

Every time a client connects, the first thing it sends is its capabilities: the library and version it runs, the platform, the version of your own code, and the commands it takes, each with its parameters. The libraries send this for you from the commands you declare in code.

The console uses them to build the Send command form: one field per parameter, typed as text, number, on/off or JSON, with required ones marked. A client that declares nothing still takes commands; you write them as JSON.

Capabilities also say which optional platform features the client supports. Today that is one: firmware updates.

State

State is what a client is doing right now: heater is on, temp is 21.5. The client reports the variables that changed, and the console's State panel shows each one's latest value, its type and how long ago it changed, updating live.

  • A variable keeps the value of the newest report by the time the client made it. A report that was buffered while the board was offline doesn't overwrite a newer value when it finally arrives.
  • Values can be numbers, text, true or false, lists or objects. A client can have up to 200 variables; new ones past that are ignored. A report over 8,192 characters is ignored whole, and only its first 50 variables are read.
  • State survives the client disconnecting. It goes when the client is deleted.

Readings and charts

Every number in a state report is also kept as a reading, at the time the client took it. For now, the console's chart shows only the values received since you opened the page, and reading history is in the API only (below).

Readings are kept as sent for a while, then rolled up into one row per hour (count, minimum, average and maximum), which is kept much longer. Charts over long ranges use the hourly roll-ups, so counts and averages stay exact even after the raw readings are gone.

PlanEvery readingHourly roll-ups
Free3 days30 days
Maker7 days1 year
Pro, Team7 days2 years
Business90 days2 years

Text, true or false and other values stay as the latest state but aren't kept as readings. To chart something on or off, report it as 1 or 0.

Export

Export CSV on the State panel saves the latest value of each variable. The readings export holds every reading as sent, for as far back as they are kept, or one row per variable and hour; it holds up to 100,000 rows, so choose a shorter range for more.

For nowThe readings export is in the API only (below).

Message types

WBSKT keeps a list of the message types each client has sent: how many, when first and last, and the latest payload as an example. It's the quickest way to find the exact type to put in a Client message trigger. Up to 100 types are kept per client. The list is available through the API for now.

What happens when…

A sensor fails and returns NaN
The libraries refuse to send a message or report holding NaN or infinity, rather than sending an empty value that looks like a real one. Leave the field out when a reading fails.
A board reconnects and sends an hour of buffered reports
Each reading lands at the time it was taken and is marked late. The latest state stays the newest value, whatever order the reports arrive in.
I move to a plan that keeps readings for less time
Nothing is deleted at once. For 30 days readings are kept as long as the old plan kept them.
A client's firmware adds a command
The new firmware sends its capabilities when it connects, and the form shows the new command from then on.
In depth

Rules and API

Messages

capabilities, sent first on every connection:

capabilities
{
  "agent": "wbskt-python", "version": "1.0.0", "os": "Linux armv7l",
  "capabilities": [
    { "command": "relay.set", "description": "Switch the relay",
      "parameters": [ { "name": "on", "dataType": "boolean", "isRequired": true } ] }
  ],
  "system": [ "ota" ],
  "firmwareVersion": "2.4.1"
}

state.report, whenever something changes: { "heater": "on", "temp": 21.5 }.

Endpoints

Under /api/v1/workspaces/{workspaceRef}/clients/{clientRef}, all with clients.read.

CallDoes
GET stateThe latest value of each state variable.
GET readings?name=One variable over from/to (default the last day, at most 740 days) as { start, count, min, avg, max } per bucket. bucket is seconds or 30s, 5m, 1h, 1d; left out, it is picked for about 500 buckets. Only buckets holding a reading are listed.
GET readings/csvOne variable or all. resolution=raw (default): name,sentAt,receivedAt,value,late. resolution=hourly: name,hourStart,count,min,avg,max.
GET message-typestype, count, firstSeenAt, lastSeenAt, isPlatform, samplePayload (when 4,000 characters or less).

Errors

CodeStatusWhen
READINGS_NAME_REQUIRED, READINGS_NAME_INVALID400No variable named, or a name that can't be one.
READINGS_BUCKET_INVALID400A bucket the grammar above doesn't allow.
READINGS_TOO_MANY_BUCKETS400A bucket so small for the range that the answer would be too long.
READINGS_RESOLUTION_INVALID400A CSV resolution other than raw or hourly.
READINGS_RANGE_TOO_LARGE400An export over 100,000 rows.
RATE_LIMITED429More than 10 exports a minute in the workspace, shared with the audit log's export.

Rules worth knowing

  • A capabilities message over 32 KB is ignored. firmwareVersion is cut to 50 characters.
  • Property names in capabilities are read ignoring case. dataType is string, number, boolean or object.
  • A reading's time is its report's sentAt, never later than when it arrived. One more than 30 seconds old on arrival is late.
  • Hourly roll-ups use the hour of the client's own time, and keep count, minimum, maximum and sum, so averages over any range are exact.
  • Message type counts are approximate: a batch delivered twice is counted twice. Types compare ignoring case.