Skip to main content

Types

Types of field values and metrics. All types are exported by @modbros/dashboard-core, except where noted, and should be imported as types:

import type {ChannelValue, ValueMetricConfig} from '@modbros/dashboard-core'

The field value types are also used by the JSON schemas of the configuration files, e.g. for defaultValues.

Field Values

ValueColor

The value of a color field.

PropertyTypeDescription
hexstringThe color as hex value, e.g. #ff0000.
alphanumberThe opacity between 0 and 1.

All properties are optional.

ValueFile

A file of a file field. Also exported by @modbros/dashboard-sdk.

PropertyTypeDescription
filenamestringThe name of the file.
srcstringThe URL of the file, relative to MoBro. Use it to display the file.
localSrcstringThe absolute URL of the file on the PC running MoBro.

All properties are optional.

ValueOptions

The options of a select or radio field: an array of objects with the following properties.

PropertyTypeRestrictionsDescription
labelstringRequiredThe label shown to users.
valuestringRequiredThe value returned when it's selected.

ValueMetricConfig

The value of a metric field: the selected metric.

PropertyTypeDescription
idstringThe id of the metric.
pluginstringThe name of the plugin providing the metric.
categoriesstring[]The ids of the categories the user navigated through to select the metric.
optionsValueMetricOptionsThe unit conversion and value source selected by the user.

All properties are optional.

ValueMetricOptions

PropertyTypeRestrictionsDescription
conversionUnitstringRequiredThe abbreviation of the unit to convert the value to.
sourcestring-The value the widget receives: value (default), min, max or avg.

ValueActionConfig

The value of an action field: the selected action.

PropertyTypeDescription
idstringThe id of the action.
pluginstringThe name of the plugin providing the action.
categoriesstring[]The ids of the categories the user navigated through to select the action.
settingsRecord<string, unknown>The settings passed to the plugin when executing the action.

All properties are optional.

FilterMetricConfig

The filters of a metric field.

PropertyTypeDescription
valueTypesstring[]Only metrics whose type has one of these value types.
typesstring[]Only metrics of these metric types, by id.
groupsstring[]Only metrics in these groups, by id.
staticbooleanOnly static metrics (true), or only non-static metrics (false).
hasValuebooleanOnly metrics that currently have a value.

FilterActionConfig

The filters of an action field.

PropertyTypeDescription
groupsstring[]Only actions in these groups, by id.

Metrics

ChannelValue

The value of a metric as received by a widget, e.g. from useMetricField. It combines the metric's value with the metric, its type and its unit. See In-depth: Metrics.

PropertyTypeDescription
metricMetricThe metric.
typeMetricTypeThe type of the metric.
unitMetricUnitThe unit the value is provided in, after the conversion selected by the user.
valueMetricValueThe value of the metric.

The actual value is accessed as channelValue.value.value.

MetricValue

The value of a metric, as provided by a plugin. See Plugins: MetricValue.

PropertyTypeDescription
idstringThe id of the metric.
valueMetricValueTypeThe value.
valueUpdatedstring | nullWhen the value was last updated, as ISO date.
valueChangedstring | nullWhen the value last changed, as ISO date.
statisticsMetricStatisticsStatistics about the values of the metric.
timeseriesMetricTimeseriesPrevious values of the metric. Optional, may not be present.

MetricValueType

type MetricValueType = number | string | null

MetricStatistics

Statistics MoBro collects about the values of a metric.

PropertyTypeDescription
minnumber | nullThe smallest value.
maxnumber | nullThe largest value.
avgnumber | nullThe average value.
countnumberThe number of values.
startedstringWhen MoBro started collecting, as ISO date.
lastUpdatedstringWhen the statistics were last updated, as ISO date.

MetricTimeseries

PropertyTypeDescription
countnumberThe number of values.
timestampsstring[]The ISO dates of the values.
values(number | null)[]The values, in the same order as the timestamps.

Metric

PropertyTypeDescription
idstringThe id of the metric.
labelstring | nullThe label of the metric.
descriptionstring | nullThe description of the metric.
pluginRelation | nullThe plugin providing the metric.
typeRelationThe type of the metric.
categoryRelation | nullThe category of the metric.
groupRelation | nullThe group of the metric.
isStaticbooleanWhether the value of the metric never changes.

The metric also contains the properties value, valueUpdated, valueChanged, statistics and timeseries. Use the ones of the MetricValue instead, which are always up to date.

MetricType

PropertyTypeDescription
idstringThe id of the metric type.
labelstringThe label of the metric type.
descriptionstring | nullThe description of the metric type.
pluginRelation | nullThe plugin providing the metric type, if any.
iconRelation | nullThe icon of the metric type.
valueTypeMetricTypeValueTypeThe value type of all metrics of this type.
baseUnitMetricUnitThe unit plugins provide values in.
unitsMetricUnit[]All units values can be converted to.

MetricTypeValueType

type MetricTypeValueType =
| 'Custom'
| 'String'
| 'Numeric'
| 'Duration'
| 'DateTime'
| 'DateOnly'
| 'TimeOnly'
| 'Resource'
| 'Currency'
| 'Boolean'

MetricUnit

PropertyTypeDescription
labelstringThe label of the unit.
abbreviationstringThe abbreviation of the unit, e.g. °C.
descriptionstring | nullThe description of the unit.
fromBaseFormulastringThe formula to convert a value from the base unit to this unit.
toBaseFormulastringThe formula to convert a value from this unit to the base unit.

Relation

A reference to another item, like a plugin or a category.

PropertyTypeDescription
idstringThe id of the referenced item.
hrefstringThe API path of the item.

Widget

The following types are exported by @modbros/dashboard-sdk.

ItemPosition

The position of a widget on the dashboard.

PropertyTypeDescription
xnumberThe horizontal position in pixels.
ynumberThe vertical position in pixels.

ItemSize

The size of a widget on the dashboard.

PropertyTypeDescription
widthnumberThe width in pixels.
heightnumberThe height in pixels.

Settings

The settings selected in MoBro, as returned by useSettings. This type is not exported.

PropertyTypeDescription
languagestringThe selected language, e.g. en.
timezonestringThe selected timezone, e.g. Europe/Vienna.
themestringThe selected theme of the app.