Activity Trail: get_activity / get_activity_detail
An audit log of register writes — who changed what, on which device, to
what value, whether it succeeded, and (on the detail view) the raw protocol
round trip — and of device changes made with
update_device (kind: "device_update",
see Device changes below). Writes the
app made over BLE, without the server, are added when the app uploads them
with sync_ble_activity; every
entry's channel says which path it took. See
Messaging for
how a write turns into one of these rows in the first place.
filter: "reads" is accepted and wired end-to-end, but returns an empty page
today, since nothing publishes a read-kind entry yet.
Only writes that actually reached the device are recorded — success or
failure. (For BLE writes that is the app's word; see below.) A write rejected before any Modbus frame was sent (wrong owner,
device offline, unknown or non-writable register, a value that can't be
encoded, another write already in progress) leaves no Activity Trail entry;
its write_result is the only record. Entries are recorded asynchronously,
so one can appear a moment after its write_result.
Listing: get_activity
// → client — first page, every device this user owns
{"type": "get_activity", "userId": "17833b2e-a851-4a17-a764-62524d667959"}
// ← server
{"type": "activity_list", "ok": true, "hasMore": true,
"nextCursor": "eyJ0IjoiMjAyNi0wOS0yMlQwNjoxODoyNi4yNzlaIiwiaWQiOiJlYmEyNGI5Ny0uLi4ifQ",
"failedCount": 2,
"activities": [
{
"id": "eba24b97-096a-42eb-8501-08e09cada4c3",
"deviceKey": "3f2504e0-4f89-41d3-9a0c-0305e82c3301",
"loggerId": "i30000252760985713",
"model": "Nexus",
"kind": "write",
"category": "Battery Set",
"status": "success",
"title": "Equalizing Charge Current",
"previousValue": 60,
"requestedValue": 80,
"readbackValue": 80,
"unit": "A",
"durationMs": 677,
"timestamp": "2026-09-22T06:18:26.279Z",
"channel": "tcp"
}
]}
deviceKeyandloggerId: every entry is stored under the device's id (deviceKey), so a device's trail continues unbroken across a logger swap.loggerIdis the logger the entry was recorded through — a snapshot that a later swap does not rewrite.channelis how the write reached the device:"tcp"(through the server, withwrite) or"ble"(the app over Bluetooth, uploaded later withsync_ble_activity). Always present, on list rows and on the detail. Show an icon from it. Every entry recorded before this field existed, and everydevice_updateentry, is"tcp".- Scope: pass
deviceKeyfor one device's activity, or omit it entirely for the "all devices" view — every deviceuserIdowns, merged and ordered newest-first. With a ticket,deviceKeymay also name a device your grants give devicesVIEWon, andplantIdadds every device now in a plant they cover. Entries for devices you reach only through a grant are redacted as the grant says: no logger ids underserials, noprotocolTraceunderengineering. plantId(optional) narrows the list to one plant: the writes of the devices that are in that plant now (a device's write history moves with it), plus thedevice_updateentries recorded for that plant (so a plant still shows a device that left it).failedCountis narrowed the same way. Omit it, or send"all", for every plant. It combines withdeviceKey.- Pagination is fixed: 15 rows on the first page (no
cursor), then 10 per page (since 2026-11-24; before, every page was 10) — there is nolimitparameter to request more. Keep paging whilehasMoreistrue, passing the previous response'snextCursorback verbatim with the samedeviceKey/plantId/filter; on the last page bothhasMoreandnextCursorare absent. Never infer "last page" from getting fewer than 10 rows back. The cursor is opaque: don't parse it, just echo it back. An empty page has noactivitiesfield at all. failedCount(the count for a "Failed" filter tab/badge) is present only on a first page (a request with nocursor) — it's the same number regardless of which page is showing, so it isn't recomputed on every scroll-triggered page fetch. Request a fresh first page (nocursor) to refresh it. It can also be absent from a first page if counting failed; the list itself is still valid.filter:"all"(default),"writes","reads"(see above — empty today), or"failed". Anything else is rejected withunknown filter "…".device_updateentries appear under"all"only.categoryis the register's UI group (the same group namesget_registersuses — see Grouped replies); it is an empty string for a model without UI groups.titleis the register'sdisplayLabel. Values are in engineering units, likewrite.- Errors (
ok: false):userId is required;unknown filter "…";invalid cursor: …(a cursor that wasn't echoed back verbatim); and, whendeviceKeyis given, the samedevice not found/not authorized to control this deviceanswerswritegives. AuserIdthat owns nothing getsok: trueand an empty page. - List rows are summary-only — no protocol trace, error message or
initiatedSource; fetchget_activity_detailfor those. Since 2026-12-02 each row carries the initiator'suserIdand, for Crown staff acting through platform access, anactorobject, masked exactly as inget_activity_detail(see Crown staff below): a reader who is not Crown staff gets"actor": {"displayName": "Crown Support", "viaPlatform": true}and nouserId. Any other initiator gets"actor": {"sub": "…", "displayName": "…", "viaPlatform": false}in list rows and inget_activity_detail;displayNamecomes from the HTTP server'suser.profile.v1and is left out until it arrives. - A register whose unit is
/(dimensionless: an on/off switch, a mode code) is sent with nounit, in list rows and inget_activity_detail. - One
get_activitymay be in flight per connection, separately fromget_activity_detail's own slot — a list scroll firing several requests in quick succession doesn't contend with a detail-screen open on the same connection.
Device changes: kind: "device_update"
Written when an update_device change is
applied: a device moving to another plant, or its logger being replaced. A
move writes two entries, one for each plant:
{
"id": "0b6d2c1e-6f1a-4c7e-9a43-5d3f8a7c2e10",
"deviceKey": "3f2504e0-4f89-41d3-9a0c-0305e82c3301",
"loggerId": "i30000252760985713",
"model": "Nexus",
"kind": "device_update",
"category": "Device",
"status": "success",
"title": "Device added to this plant",
"plantId": "01JZYXWVTSRQPNMKJHGFEDCBA9",
"details": {"action": "moved_in",
"fromPlantId": "01JABCDEFGHJKMNPQRSTVWXYZ0",
"toPlantId": "01JZYXWVTSRQPNMKJHGFEDCBA9"},
"timestamp": "2026-10-09T10:02:11.418Z"
}
details.action | plantId | title |
|---|---|---|
moved_out | the plant the device left | "Device moved to another plant" |
moved_in | the plant the device joined | "Device added to this plant" |
logger_replaced | the device's plant | "Logger replaced" — written when the new logger connects and the swap completes; details carries fromLoggerId and toLoggerId instead of plant ids |
rated_power_changed | the device's plant | "Rated power changed" — the nameplate rating was set, changed or cleared (update_device, or the console's set_device_rated_power); details carries fromRatedPowerKw and toRatedPowerKw, each absent for "none set" |
battery_added, battery_updated, battery_removed | the device's plant | "Battery added" / "Battery updated" / "Battery removed": a battery on the device was added, edited or removed; details carries batteryId. A battery is always on a device (2026-11-20). Batteries deleted with their device record nothing more: the device's own trail is erased with it |
These entries have no requestedValue, previousValue, readbackValue,
unit or durationMs. On get_activity_detail their register,
registerAddress, functionCode and requestedValue are ""/0; ignore
them for any kind other than "write". plantId and details appear only
on device_update entries. They are written in the same database
transaction as the change itself: a plant move's entries are there as soon
as update_device_result arrives, and a logger_replaced entry as soon as
the new logger has connected and the swap has completed.
Uploading BLE writes: sync_ble_activity
A write the app makes over BLE
never passes through the server. The app keeps each one in a local cache and,
when it is online, uploads the cache in batches. Each accepted entry appears
in the trail with channel: "ble", at the time the app says the write
happened.
// → client
{"type": "sync_ble_activity", "userId": "17833b2e-a851-4a17-a764-62524d667959",
"activities": [
{"id": "3b1d2c9e-6a7f-4e1b-9c0d-2f4a5b6c7d8e",
"deviceKey": "3f2504e0-4f89-41d3-9a0c-0305e82c3301",
"plantId": "01JZYXWVTSRQPNMKJHGFEDCBA9",
"performedAt": "2026-10-27T09:14:03.120Z",
"register": "equalizing_charge_current",
"requestedValue": 80,
"previousValue": 60,
"readbackValue": 80,
"status": "success",
"durationMs": 412,
"protocolTrace": {"attempts": 1, "requestHex": "01 06 04 49 15 18 57 b6", "responseHex": "01 06 04 49 15 18 57 b6"}}
]}
| Field | Required | Rule |
|---|---|---|
userId | yes | The caller, for the whole batch. Every entry is checked against it. |
activities | yes | 1 to 100 entries. Send a larger cache in several requests, one at a time. |
id | yes | A UUID the app generates when the write happens, stored with the cached entry and sent unchanged on every retry. It becomes the entry's id, so uploading it twice stores it once. |
deviceKey, plantId | yes | The device and the plant it is in. plantId: "all" is refused. |
performedAt | yes | RFC3339 from the phone's clock. Refused if more than 5 minutes in the future, or older than the 730-day retention. |
register | yes | A writable register of the device's model, by catalog name. |
requestedValue | yes | Engineering units, as for write. |
status | yes | "success" or "failed". |
previousValue, readbackValue, errorMessage (≤256 chars), durationMs, protocolTrace (hex strings ≤512 chars each) | no | As on a TCP entry. |
The server fills in title, category, unit, registerAddress and
functionCode from the register catalog, the same way it does for a TCP
write, and the loggerId snapshot from the logger fitted when the entry is
stored. Don't send them.
// ← server
{"type": "sync_ble_activity_result", "ok": true,
"accepted": ["3b1d2c9e-6a7f-4e1b-9c0d-2f4a5b6c7d8e"],
"discarded": [{"id": "77aa0c2e-…", "reason": "device_not_registered"}],
"retry": [{"id": "88bb41f0-…", "reason": "device_model_unknown",
"detail": "the device has not connected to the server yet"}]}
What the app does with the reply:
ok: true: remove every id inacceptedanddiscardedfrom the cache. An accepted entry is stored (or was already). A discarded one can never be stored, so sending it again is pointless. Keep the ids inretryand send them again later. Each list is absent when empty.ok: false, witherror: nothing was settled. Keep the whole batch and send it again with exponential backoff and jitter (for example 5 s doubling to 5 minutes). This covers a database or storage outage, a malformed request, and a secondsync_ble_activitysent before the first was answered (one in flight per connection).
reason | List | Meaning |
|---|---|---|
device_not_registered | discarded | No device with that deviceKey is owned by userId and in plantId (or it has been revoked). Missing, someone else's and in another plant all get this same reason, deliberately. A deactivated device is accepted. |
invalid_entry | discarded | A field broke a rule above; detail says which. |
timestamp_out_of_range | discarded | performedAt is too far in the future or past retention. |
unknown_register | discarded | The register is not a writable register of the device's model. |
device_model_unknown | retry | The device was registered but has never connected, so the server does not know its model yet. It will once the device comes online. |
Accepted entries are stored asynchronously, like TCP writes: they can take a
moment to appear in get_activity. An entry backfilled into the past lands
at its own time, so a list already scrolled past that point shows it after a
refresh.
:::caution A BLE entry is the app's claim
The server did not see a BLE write happen. It checks only that the device,
plant and owner line up, and that userId is the same unverified claim as
everywhere else (see Known gaps). The
channel icon is how the user can tell such an entry apart.
:::
Detail: get_activity_detail
// → client
{"type": "get_activity_detail", "userId": "17833b2e-a851-4a17-a764-62524d667959",
"activityId": "eba24b97-096a-42eb-8501-08e09cada4c3"}
// ← server
{"type": "activity_detail", "ok": true, "activity": {
"id": "eba24b97-096a-42eb-8501-08e09cada4c3",
"deviceKey": "3f2504e0-4f89-41d3-9a0c-0305e82c3301",
"loggerId": "i30000252760985713",
"model": "Nexus",
"kind": "write",
"category": "Battery Set",
"status": "success",
"title": "Equalizing Charge Current",
"register": "equalizing_charge_current",
"registerAddress": 1097,
"functionCode": 6,
"previousValue": 60,
"requestedValue": 80,
"readbackValue": 80,
"unit": "A",
"userId": "17833b2e-a851-4a17-a764-62524d667959",
"initiatedSource": "mobile_app",
"durationMs": 677,
"protocolTrace": {"attempts": 1, "requestHex": "01 06 04 49 15 18 57 b6", "responseHex": "01 06 04 49 15 18 57 b6"},
"initiatedAt": "2026-09-22T06:18:26.279Z",
"channel": "tcp"
}}
:::caution The detail's timestamp field is initiatedAt, not timestamp
A list row's time is timestamp; the same moment on the detail object is
named initiatedAt. Read the right one per message type.
:::
A failed write additionally carries errorMessage. protocolTrace holds the
raw Modbus frames as space-separated hex; attempts is more than 1 when the
write was retried after a transient error, and responseHex is absent when
the device never answered. previousValue/readbackValue are absent when
the register couldn't be read before/after the write (write-only register,
or the read failed) — that doesn't mean the write failed; status says
that.
Crown staff (since 2026-11-26, RBAC-S3): an entry made by Crown
(platform org) staff acting on a Business's device through platform access
carries "viaPlatform": true and an actor object. A reader who is not
Crown staff (the device's owner, a Business or installer ticket) gets no
userId and "actor": {"displayName": "Crown Support", "viaPlatform": true}.
Show "Crown Support". A Crown reader keeps userId and gets
"actor": {"sub": "…", "viaPlatform": true}. initiatedSource names the
client, not the person, and is unchanged. Entries written before
migration 0156 carry no flag until the one-off backfill
scripts/sql/2026-11-26_oplog_actor_via_platform_backfill.sql is run. The
console's operation log and device event log follow the same rule; see
Web console devices.
Ownership: activityId alone is not enough — the row's device must be
owned by the given userId (checked the same way write's ownership gate
is, including the same case-insensitivity handling, and the same "unverified
claim" caveat — see Known gaps). A wrong owner and a
nonexistent activityId get back the identical "activity not found"
error, deliberately — so a client can't use this endpoint to enumerate valid
activity ids it doesn't have access to. A malformed activityId (not even a
valid UUID) gets the same error too, not a raw database error. The only
other errors are userId is required, activityId is required, and a
generic query failure when the database itself is unavailable.