# Alarm utils

### Alarm

The `alarm` object is the main object for managing alarms.

#### alarm.open(alarmConfig)

Opens an alarm.

**Returns**: void

This function takes as parameter an object with the following fields:

| Property            | Type      | Default       | Mandatory | Description                                                                                                                                                                                                          |
|---------------------|-----------|---------------|-----------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| subEntityIdentifier | String    | entityId      | No        | You can open an alarm on device, subscription or subscriber identifier. With _subEntityIdentifier_ you define selected identifier. If is undefined it will open on _provision.administration.identifier_ identifier  |
| alarmName           | String    |               | No        | Name that you want to see in opened alarm                                                                                                                                                                            |
| ruleName            | String    |               | No        | Name of rule that produce opening of alarm                                                                                                                                                                           |
| severity            | String    | 'INFORMATIVE' | No        | Severity of alarm. Values can be INFORMATIVE, URGENT or CRITICAL                                                                                                                                                     |
| priority            | String    | 'LOW'         | No        | Priority of alarm. Values can be LOW, MEDIUM or HIGH                                                                                                                                                                 |
| description         | String    |               | No        | Alarm description                                                                                                                                                                                                    |
| extraInfo           | String    |               | No        | Extra information.                                                                                                                                                                                                   |

Example of use:

This example open alarm _apnMismatch_ to subscription.

```javascript
alarmConfig = {
    subEntityIdentifier: "id",
    alarmName: "apnMismatch",
    ruleName: "apnMismatchRule",
    severity: "URGENT",
    priority: "MEDIUM",
    description: "APN mismatch with provisioned value",
    extraInfo: "Extra information"
}
  
alarm.open(alarmConfig);
```

And this example open alarm _highTemperature_ to device.

```javascript
alarmConfigDevice = {
    alarmName: "highTemperature",
    ruleName: "highTemperatureRule",
    severity: "URGENT",
    priority: "MEDIUM",
    description: "Device temperature is high"
}

alarm.open(alarmConfigDevice);
```

#### alarm.closeByRuleName(closeByRuleConfig)

Closes alarm by rule name.

**Returns**: void

This function takes as parameter an object with the following fields:

| Property           | Type   | Default | Mandatory | Description                                                                                                                                                                                                           |
|--------------------|--------|---------|-----------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| ruleName           | String |         | Yes       | Rule name that open alarm.                                                                                                                                                                                            |
| entityIdDatastream | String |         | No        | You can close an alarm on device, subscription or subscriber identifier. With _entityIdDatastream_ you define selected identifier. If is undefined it will close on _provision.administration.identifier_ identifier. | 

Example of use:

The example close alarm generated by _highTemperatureRule_ to device.

```javascript
closeByRuleConfig = {
    ruleName: "highTemperatureRule"
}

alarm.closeByRuleName(closeByRuleConfig);
```

#### alarm.closeByAlarmName(closeByNameConfig)

Closes alarm by alarm name.

**Returns**: void

This function takes as parameter an object with the following fields:

| Property           | Type   | Default | Mandatory | Description                                                                                                                                                                                                           |
|--------------------|--------|---------|-----------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| alarmName          | String |         | Yes       | Opened alarm name.                                                                                                                                                                                                    |
| entityIdDatastream | String |         | No        | You can close an alarm on device, subscription or subscriber identifier. With _entityIdDatastream_ you define selected identifier. If is undefined it will close on _provision.administration.identifier_ identifier. | 

Example of use:

The example close opened alarm _apnMismatch_ to device.

```javascript
closeByNameConfig = {
    alarmName: "highTemperatureRule"
}

alarm.closeByAlarmName(closeByNameConfig);
```
