Skip to content

@camera.ui/sdk / sensor / defineMeasurement

Function: defineMeasurement() ​

defineMeasurement<T, K>(type, assignmentKey, definition): object

Defined in: sensor/measurement.ts:106

Declares the metadata of a measurement type: one current reading with a unit and the range the quantity can have.

Type Parameters ​

T ​

T extends SensorType

K ​

K extends string

Parameters ​

type ​

T

The sensor type.

assignmentKey ​

K

Key under which a camera stores its assignment for the type.

definition ​

MeasurementDefinition

Unit, device class, starting value and range of the reading.

Returns ​

object

The metadata, with type and assignmentKey preserved as literal types.

assignmentKey ​

assignmentKey: K

category ​

readonly category: Info = SensorCategory.Info

isDetectionType ​

readonly isDetectionType: false = false

multiProvider ​

readonly multiProvider: true = true

properties ​

readonly properties: object

properties.current ​

readonly current: object

properties.current.max? ​

optional max?: number

properties.current.min? ​

optional min?: number

properties.current.type ​

readonly type: "number" = 'number'

properties.current.unit ​

unit: string

properties.current.writable ​

readonly writable: true = true

semantics ​

readonly semantics: object

semantics.commandProperty ​

readonly commandProperty: "current" = 'current'

semantics.deviceClass ​

deviceClass: string

semantics.domain ​

readonly domain: Measurement = SensorDomain.Measurement

semantics.stateProperty ​

readonly stateProperty: "current" = 'current'

semantics.unit ​

unit: string

shortcutable ​

readonly shortcutable: true = true

type ​

type: T

virtual ​

readonly virtual: object

virtual.properties ​

readonly properties: object

virtual.properties.current ​

readonly current: number = initial

Example ​

ts
export const humidityMeta = defineMeasurement(SensorType.Humidity, 'humidity', {
  unit: '%',
  deviceClass: 'humidity',
  initial: 50,
  min: 0,
  max: 100,
});