To create, edit or delete sensors, use the command unit/update_sensor:
svc=unit/update_sensor¶ms={"itemId":<long>, "id":<long>, "callMode":<text>, "unlink":<uint>, "n":<text>, "t":<text>, "d":<text>, "m":<text>, "p":<text>, "f":<uint>, "c":<text>, "vt":<uint>, "vs":<long>, "tbl":[ { "x":<double>, "a":<double>, "b":<double> } ]}
Parameters
Name | Description |
---|---|
itemId | unit ID |
id | sensor ID (0 to create) |
callMode | action: create, update, delete |
unlink | Delete links with another sensors and unit parameters by removing (1 – yes (default), 0 – no ) |
Parameters required only to create and update: | |
n | name |
t | type (see below) |
d | description |
m | metrics |
p | parameter |
f | sensor flags (see below) |
c | configuration (see below) |
vt | validation type (see below) |
vs | validating sensor ID |
tbl | calculation table |
Sensor flags:
Flag | Description |
---|---|
0x01 | sensor type: instant |
0x02 | sensor type: differential |
0x03 | sensor type: differential with overflow (2 bytes) |
0x04 | sensor type: switch from off to on |
0x05 | sensor type: switch from on to off |
0x20 | activate “With overflow” option (see below) |
0x40 | apply lower/upper bounds AFTER calculation (see below) |
Clarification for 0x20:
– actual for the next sensors:
-
-
mileage;
-
-
-
absolute fuel consumption;
-
-
engine hours.
If 0x20-flag is NOT set then sensor works as follows: delta of change is equal to abs(V2 – V1), where V2 – new message value, V1 – prev message value, abs() – absolute value; if flag is set, then when V2 < V1 delta is equal to V2 (i.e. V1 = 0).
Clarification for 0x40:
-
-
if flag unset: any bound is applied to raw data (in case of FLS there are difficulties with setting lower/upper bound for RAW data);
-
-
if flag is set: any bound is applied to calculated (processed) data.
Sensor types:
- absolute fuel consumption – absolute fuel consumption sensor;
- accelerometer – accelerometer;
- alarm trigger – alarm trigger;
- counter – counter sensor;
- custom – custom sensor;
- digital – custom digital sensor;
- driver – driver binding;
- engine efficiency – engine efficiency sensor;
- engine hours – absolute engine hours;
- engine operation – engine ignition sensor;
- engine rpm – engine revs sensor;
- fuel level impulse sensor – fuel level impulse sensor;
- fuel level – fuel level sensor;
- impulse fuel consumption – impulse fuel consumption sensor;
- instant fuel consumption – instant fuel consumption sensor;
- mileage – mileage sensor;
- odometer – relative odometer;
- private mode – private mode;
- relative engine hours – relative engine hours;
- temperature coefficient – temperature coefficient;
- temperature – temperature sensor;
- trailer – trailer binding;
- voltage – voltage sensor;
- weight sensor – weight sensor.
Here you can read more about sensor types.
Sensor configuration params:
Note: JSON-object is sent as a string, that’s why it must be within double quotes, all key and value double quotes must be escaped (\“).
"{
\"act\":<bool>,
\"appear_in_popup\":<bool>,
\"ci\":<object>,
\"filter\":<long>,
\"mu\":<uint>,
\"pos\":<uint>,
\"show_time\":<text>,
\"unbound_code\":<text>,
\"validate_driver_unbound\":<bool>,
\"timeout\":<uint>,
\"uct\":<bool>,
\"lower_bound\":<double>,
\"upper_bound\":<double>
}"
Parameter | Description |
---|---|
act | “Last Message only” option: 0 – ON, 1 – OFF (see additional info below) |
appear_in_popup | “Visible” checkbox: false – uncheck, true – check |
ci | custom intervals |
filter | redefine filtration level |
mu | measure units: 0 – si, 1 – us, 2 – imperial, 3 – metric with gallons |
pos | Sensors list position, count from 1 |
show_time | “Time” checkbox: false – uncheck, true – check |
unbound_code | unbinding code |
validate_driver_unbound | validate unbinding, 0 – no, 1 – yes |
timeout | timeout, seconds |
uct | “Overflow by raw data” option: 0 – off, 1 – on |
lower_bound | “Lower bound” option |
upper_bound | “Upper bound” option |
Clarification for “act”: inverted logic is used for that option: checked option (value 0) means historically older logic version, unchecked option (value 1) reters to newer logic version (data is used for popups, handy when important params are rare to come). Older logic version is chosen by default.
Clarification for “filter”:
– this option allows to redefine filtration level; valid for the next sensors:
-
-
fuel level;
-
-
-
temperature;
-
-
-
engine rpm;
-
-
-
voltage;
-
-
-
accelerometer;
-
-
-
custom;
-
-
weight
Example:
"c":"{\"appear_in_popup\":true,\"pos\":1,\"ci\":{}}"
Validation types:
Type | Description |
---|---|
0x01 | Logical AND |
0x02 | Logical OR |
0x03 | Math AND |
0x04 | Math OR |
0x05 | Sum up |
0x06 | Subtract validator from sensor |
0x07 | Subtract sensor from validator |
0x08 | Multiply |
0x09 | Divide sensor by validator |
0x0A | Divide validator by sensor |
0x0B | Not-null check |
0x0C | Replace sensor with validator in case of error |
Response
On create and edit:
[ <long>, /* sensor ID */ { "id":<long>, /* sensor ID */ "n":<text>, /* name */ "t":<text>, /* type */ "d":<text>, /* description */ "m":<text>, /* metrics */ "p":<text>, /* parameter */ "f":<uint>, /* sensor flags */ "c":<object>, /* configuration */ "vt":<int>, /* validation type*/ "vs":<long>, /* validating sensor ID */ "tbl":[ /* calculation table */ { /* parameters */ "x":<double>, "a":<double>, "b":<double> } ] } ]
On delete:
[ <long>, /* sensor ID */ null ]