Dominevo
ReferenceHTTP API

deviceHistory

The deviceHistory router: 14 methods of the device-history capability, with tier, scope, input and output.

Capability device-history · scope system · mode singleton · source packages/types/src/capabilities/device-history.cap.ts:328.

Every method is called at /trpc/deviceHistory.<method> — queries with GET, mutations with POST. See How to call and Authorization.

MethodKindTierToken scopeViewer
listSeriesqueryprotectedviewno
listNodeSeriesqueryadminadmin onlyno
queryqueryprotectedviewno
queryNodequeryadminadmin onlyno
queryManyqueryadminadmin onlyno
declareSeriesmutationadminadmin onlyno
recordmutationadminadmin onlyno
recordBucketsmutationadminadmin onlyno
getDeviceEnabledqueryprotectedviewno
setDeviceEnabledmutationadminadmin onlyno
getStatusqueryadminadmin onlyno
listOrphanSeriesqueryadminadmin onlyno
deleteOrphanSeriesmutationadminadmin onlyno
deleteSeriesRangemutationadminadmin onlyno

deviceHistory.listSeries

  • Kind: query — GET /trpc/deviceHistory.listSeries
  • Tier: protected — any signed-in principal whose scopes cover the method
  • Token scope: view on capability device-history, or category system
  • Viewer: no
  • Try it: open /system/api-explorer?method=deviceHistory.listSeries on your hub

Input

{ deviceId: number }

Output

({ key: string; scope: string; kind: DeviceHistoryKindSchema; unit: string | null; displayName: string; source: "cap" | "addon" | "derived"; values: string[] | null; firstTs: number; lastTs: number })[]

Shapes: DeviceHistoryKindSchema

deviceHistory.listNodeSeries

  • Kind: query — GET /trpc/deviceHistory.listNodeSeries
  • Tier: admin — an administrator; a viewer only as the Viewer line says; never a scoped token
  • Token scope: none — the admin tier needs an administrator (a * token or an admin session)
  • Viewer: no
  • Try it: open /system/api-explorer?method=deviceHistory.listNodeSeries on your hub

Input

{ forNodeId: string }

Output

({ key: string; scope: string; kind: DeviceHistoryKindSchema; unit: string | null; displayName: string; source: "cap" | "addon" | "derived"; values: string[] | null; firstTs: number; lastTs: number })[]

Shapes: DeviceHistoryKindSchema

deviceHistory.query

  • Kind: query — GET /trpc/deviceHistory.query
  • Tier: protected — any signed-in principal whose scopes cover the method
  • Token scope: view on capability device-history, or category system
  • Viewer: no
  • Try it: open /system/api-explorer?method=deviceHistory.query on your hub

Input

{ deviceId: number; key: string; scope?: string; from: number; to: number; resolution?: DeviceHistoryResolutionSchema | "auto" = "auto"; maxPoints?: number = 1000 }

Output

{ resolution: DeviceHistoryResolutionSchema; series: ({ scope: string; before: { t: number; value: number | null; state: string | null } | null; points: ({ t: number; samples: number; mean: number | null; twMean: number | null; min: number; max: number; last: number | null; delta: number | null; state: string | null; states: Record<string, number> | null })[]; derivedFrom: string | null })[]; truncated: boolean }

Shapes: DeviceHistoryResolutionSchema

deviceHistory.queryNode

  • Kind: query — GET /trpc/deviceHistory.queryNode
  • Tier: admin — an administrator; a viewer only as the Viewer line says; never a scoped token
  • Token scope: none — the admin tier needs an administrator (a * token or an admin session)
  • Viewer: no
  • Try it: open /system/api-explorer?method=deviceHistory.queryNode on your hub

Input

{ forNodeId: string; key: string; scope?: string; from: number; to: number; resolution?: DeviceHistoryResolutionSchema | "auto" = "auto"; maxPoints?: number = 1000 }

Output

{ resolution: DeviceHistoryResolutionSchema; series: ({ scope: string; before: { t: number; value: number | null; state: string | null } | null; points: ({ t: number; samples: number; mean: number | null; twMean: number | null; min: number; max: number; last: number | null; delta: number | null; state: string | null; states: Record<string, number> | null })[]; derivedFrom: string | null })[]; truncated: boolean }

Shapes: DeviceHistoryResolutionSchema

deviceHistory.queryMany

  • Kind: query — GET /trpc/deviceHistory.queryMany
  • Tier: admin — an administrator; a viewer only as the Viewer line says; never a scoped token
  • Token scope: none — the admin tier needs an administrator (a * token or an admin session)
  • Viewer: no
  • Try it: open /system/api-explorer?method=deviceHistory.queryMany on your hub

Input

{ items: ({ deviceId: number; key: string; scope?: string } | { forNodeId: string; key: string; scope?: string })[]; from: number; to: number; resolution?: DeviceHistoryResolutionSchema | "auto" = "auto"; maxPoints?: number = 1000 }

Output

{ results: ({ ok: true; result: { resolution: DeviceHistoryResolutionSchema; series: ({ scope: string; before: {…} | null; points: {…}[]; derivedFrom: string | null })[]; truncated: boolean } } | { ok: false; error: string })[] }

Shapes: DeviceHistoryResolutionSchema

deviceHistory.declareSeries

  • Kind: mutation — POST /trpc/deviceHistory.declareSeries
  • Tier: admin — an administrator; a viewer only as the Viewer line says; never a scoped token
  • Token scope: none — the admin tier needs an administrator (a * token or an admin session)
  • Viewer: no
  • Try it: open /system/api-explorer?method=deviceHistory.declareSeries on your hub

Input

{ name: string; subjectKind: "device" | "node"; kind: DeviceHistoryProducerKindSchema; unit?: string; displayName: string; ingest: "points" | "buckets" }

Output

{ key: string }

Shapes: DeviceHistoryProducerKindSchema

deviceHistory.record

  • Kind: mutation — POST /trpc/deviceHistory.record
  • Tier: admin — an administrator; a viewer only as the Viewer line says; never a scoped token
  • Token scope: none — the admin tier needs an administrator (a * token or an admin session)
  • Viewer: no
  • Try it: open /system/api-explorer?method=deviceHistory.record on your hub

Input

{ points: ({ key: string; subject: DeviceHistorySubjectSchema; scope?: string = ""; ts: number; value: number })[] }

Output

{ accepted: number; refused: ({ key: string; reason: DeviceHistoryRefusalReasonSchema; count: number })[] }

Shapes: DeviceHistorySubjectSchema · DeviceHistoryRefusalReasonSchema

deviceHistory.recordBuckets

  • Kind: mutation — POST /trpc/deviceHistory.recordBuckets
  • Tier: admin — an administrator; a viewer only as the Viewer line says; never a scoped token
  • Token scope: none — the admin tier needs an administrator (a * token or an admin session)
  • Viewer: no
  • Try it: open /system/api-explorer?method=deviceHistory.recordBuckets on your hub

Input

{ buckets: ({ key: string; subject: DeviceHistorySubjectSchema; scope?: string = ""; bucketStart: number; samples: number; sum: number; min: number; max: number; last: number | null; lastTs: number | null })[] }

Output

{ accepted: number; refused: ({ key: string; reason: DeviceHistoryRefusalReasonSchema; count: number })[] }

Shapes: DeviceHistorySubjectSchema · DeviceHistoryRefusalReasonSchema

deviceHistory.getDeviceEnabled

  • Kind: query — GET /trpc/deviceHistory.getDeviceEnabled
  • Tier: protected — any signed-in principal whose scopes cover the method
  • Token scope: view on capability device-history, or category system
  • Viewer: no
  • Try it: open /system/api-explorer?method=deviceHistory.getDeviceEnabled on your hub

Input

{ deviceId: number }

Output

{ enabled: boolean }

deviceHistory.setDeviceEnabled

  • Kind: mutation — POST /trpc/deviceHistory.setDeviceEnabled
  • Tier: admin — an administrator; a viewer only as the Viewer line says; never a scoped token
  • Token scope: none — the admin tier needs an administrator (a * token or an admin session)
  • Viewer: no
  • Try it: open /system/api-explorer?method=deviceHistory.setDeviceEnabled on your hub

Input

{ deviceId: number; enabled: boolean }

Output

{ enabled: boolean }

deviceHistory.getStatus

  • Kind: query — GET /trpc/deviceHistory.getStatus
  • Tier: admin — an administrator; a viewer only as the Viewer line says; never a scoped token
  • Token scope: none — the admin tier needs an administrator (a * token or an admin session)
  • Viewer: no
  • Try it: open /system/api-explorer?method=deviceHistory.getStatus on your hub

Input

{}

Output

DeviceHistoryStatusSchema

Shapes: DeviceHistoryStatusSchema

deviceHistory.listOrphanSeries

  • Kind: query — GET /trpc/deviceHistory.listOrphanSeries
  • Tier: admin — an administrator; a viewer only as the Viewer line says; never a scoped token
  • Token scope: none — the admin tier needs an administrator (a * token or an admin session)
  • Viewer: no
  • Try it: open /system/api-explorer?method=deviceHistory.listOrphanSeries on your hub

Input

{}

Output

{ series: ({ seriesId: number; deviceId: number; key: string; scope: string; displayName: string | null; reason: DeviceHistoryOrphanReasonSchema; missingSince: number | null; firstTs: number; lastTs: number; rows: { raw: number; 5m: number; 1h: number; 1d: number } })[]; truncated: boolean }

Shapes: DeviceHistoryOrphanReasonSchema

deviceHistory.deleteOrphanSeries

  • Kind: mutation — POST /trpc/deviceHistory.deleteOrphanSeries
  • Tier: admin — an administrator; a viewer only as the Viewer line says; never a scoped token
  • Token scope: none — the admin tier needs an administrator (a * token or an admin session)
  • Viewer: no
  • Try it: open /system/api-explorer?method=deviceHistory.deleteOrphanSeries on your hub

Input

{ seriesIds: number[] }

Output

{ results: ({ seriesId: number; ok: true; deleted: { raw: number; 5m: number; 1h: number; 1d: number } } | { seriesId: number; ok: false; reason: DeviceHistoryOrphanDeleteRefusalSchema })[] }

Shapes: DeviceHistoryOrphanDeleteRefusalSchema

deviceHistory.deleteSeriesRange

  • Kind: mutation — POST /trpc/deviceHistory.deleteSeriesRange
  • Tier: admin — an administrator; a viewer only as the Viewer line says; never a scoped token
  • Token scope: none — the admin tier needs an administrator (a * token or an admin session)
  • Viewer: no
  • Try it: open /system/api-explorer?method=deviceHistory.deleteSeriesRange on your hub

Input

{ deviceId: number; key: string; scope: string; fromMs: number; toMs: number; dryRun: boolean }

Output

{ ok: true; dryRun: boolean; seriesId: number; rows: { raw: number; 5m: number; 1h: number; 1d: number }; rewritten: { 5m: number; 1h: number; 1d: number } | null } | { ok: false; reason: DeviceHistoryRangeDeleteRefusalSchema }

Shapes: DeviceHistoryRangeDeleteRefusalSchema