update_health_check
To configure health check settings for a unit, use the unit/update_health_check method.
In Wialon Local, the method is available starting from version 2504.
Endpoint
svc=unit/update_health_check¶ms={
"itemId": <long>,
"settings": <object>
}
Parameters
The request must contain the following parameters:
| Parameter | Description |
|---|---|
itemId |
Unit ID. |
settings |
Object with health check settings. See Health check criteria. |
Health check criteria
The settings object can contain the following keys. Each key is optional. If you omit a key, the default settings of this criterion apply. Other keys are ignored.
| Key | Criterion |
|---|---|
missing_position_data |
No GPS data |
insufficient_satellite_coverage |
Number of satellites |
low_battery |
Device battery level |
voltage_out_of_range |
Voltage level. Applies to all voltage sensors of the unit. |
max_messages_last_hour |
Number of messages per hour |
max_distance_between_messages |
Distance between messages. The value is specified in meters. |
no_data |
No messages |
stuck_fls |
No changes in fuel data. Applies to all fuel level sensors of the unit. |
ignition_is_off |
Ignition off. Applies to all ignition sensors of the unit. |
For the description of each criterion, see List of criteria.
To get the current health check settings of a unit, request the unit data with the Advanced properties flag 0x00000100 (256). The settings are returned in the hch key.
Each key contains an object with the following parameters:
| Parameter | Description |
|---|---|
period |
Required. Period after which the unit is considered unhealthy: 1m, 10m, 1h, 1d, <N>s (number of seconds from 0 to 2592000), or none to turn the criterion off. In Wialon Local, the <N>s format is available starting from version 2604. |
unhealthy_conditions |
Optional. Array of conditions. Each condition contains type (less, greater, equal, not_equal, or unchanged) and value (double). |
JSON example
Below is an example of the settings object.
{
"low_battery": {
"period": "1h",
"unhealthy_conditions": [
{
"type": "less", // less, greater, equal, not_equal, unchanged
"value": 20.0
}
]
},
"max_messages_last_hour": {
"period": "1m",
"unhealthy_conditions": [
{
"type": "greater", // less, greater, equal, not_equal, unchanged
"value": 1000.0
}
]
},
"no_data": {
"period": "1d"
},
"missing_position_data": {
"period": "1m"
},
"insufficient_satellite_coverage": {
"period": "1m",
"unhealthy_conditions": [
{
"type": "less", // less, greater, equal, not_equal, unchanged
"value": 4.0
}
]
},
"max_distance_between_messages": {
"period": "1h",
"unhealthy_conditions": [
{
"type": "greater", // less, greater, equal, not_equal, unchanged
"value": 100000.0 // m
}
]
},
"voltage_out_of_range": {
"period": "1m",
"unhealthy_conditions": [
{
"type": "less", // less, greater, equal, not_equal, unchanged
"value": 12.0
},
{
"type": "greater", // less, greater, equal, not_equal, unchanged
"value": 13.0
}
]
},
"stuck_fls": {
"period": "1m",
"unhealthy_conditions": [
{
"type": "unchanged", // less, greater, equal, not_equal, unchanged
"value": 0.0 // not used
}
]
},
"ignition_is_off": {
"period": "1m",
"unhealthy_conditions": [
{
"type": "equal", // equal, not_equal
"value": 0.0 // 0.0: off, 1.0: on
}
]
}
}
Example
Below is an example of the unit/update_health_check request.
svc=unit/update_health_check¶ms={
"itemId": 1583,
"settings": {
"low_battery": {
"period": "1h",
"unhealthy_conditions": [
{
"type": "less",
"value": 20.0
}
]
},
"max_messages_last_hour": {
"period": "1m",
"unhealthy_conditions": [
{
"type": "greater",
"value": 1000.0
}
]
},
"no_data": {
"period": "1d"
},
"missing_position_data": {
"period": "1m"
},
"insufficient_satellite_coverage": {
"period": "1m",
"unhealthy_conditions": [
{
"type": "less",
"value": 4.0
}
]
},
"max_distance_between_messages": {
"period": "1h",
"unhealthy_conditions": [
{
"type": "greater",
"value": 100000.0
}
]
},
"voltage_out_of_range": {
"period": "1m",
"unhealthy_conditions": [
{
"type": "less",
"value": 12.0
},
{
"type": "greater",
"value": 13.0
}
]
},
"stuck_fls": {
"period": "1m",
"unhealthy_conditions": [
{
"type": "unchanged",
"value": 0.0
}
]
},
"ignition_is_off": {
"period": "1m",
"unhealthy_conditions": [
{
"type": "equal",
"value": 0.0
}
]
}
}
}
Response
If the request is completed successfully, an empty object is returned:
{}
If the request fails, an error code is returned.
Error codes
| Error code | Description |
|---|---|
| 4 | Wrong input parameters, or the period value of a criterion is missing or invalid. |
| 6 | Failed to update the health check settings. |
| 7 | The unit doesn’t exist, the Units: Health check service isn’t enabled, or the user doesn’t have the Edit not mentioned properties access right to the unit. |