# Conditions

## Current Value Compared to Fixed Value

In this example, an alarm will occur if the current value of the tag is >= 6:

<figure><img src="https://253937570-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LzDzLyKYu6xMIADlPIj%2Fuploads%2Fgit-blob-39acfced813297bc373220d9baf12195535ab990%2Falarm-conditions-tag_value.png?alt=media" alt=""><figcaption></figcaption></figure>

## Current Value Compared to Value of Another Tag

In this example, an alarm will occur if the current value of the tag is >= the current value of the `Site 1/battery/1/Battery State of Charge` tag:

<figure><img src="https://253937570-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LzDzLyKYu6xMIADlPIj%2Fuploads%2Fgit-blob-bdb44e771dd3b3797b8f26b4fdd2d70f379d8ada%2Falarm-conditions-two_tag_comp.png?alt=media" alt=""><figcaption></figcaption></figure>

## Max Change Over a Time Interval Compared to Fixed Value

In this example, an alarm will occur if the absolute difference between the minimum and maximum value in the past hour is >= 10:

<figure><img src="https://253937570-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LzDzLyKYu6xMIADlPIj%2Fuploads%2Fgit-blob-3adb9dcba02d5b493eeb12c6e016b30342766db6%2Falarm-conditions-max_change_fixed_value.png?alt=media" alt=""><figcaption></figcaption></figure>

## Max Change Over a Time Interval Compare to Value of Another Tag

In this example, an alarm will occur if the absolute difference between the minimum and maximum value in the past hour is >= the value of the `Site 1/battery/1/Battery State of Charge` tag:

<figure><img src="https://253937570-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LzDzLyKYu6xMIADlPIj%2Fuploads%2Fgit-blob-9395f4c7a7cdb33ffa03116d453d169d414314c8%2Falarm-conditions-maxChange_other_tag.png?alt=media" alt=""><figcaption></figcaption></figure>

## Tag is Unavailable for Amount of Time

In this example, the alarm will occur if the tag is not available (NA, in other words has no value) for 30 minutes straight:

<figure><img src="https://253937570-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LzDzLyKYu6xMIADlPIj%2Fuploads%2Fgit-blob-187f0e491fed6a39bc8e19f366f794888fa98029%2Falarm-conditions-tag_na.png?alt=media" alt=""><figcaption></figcaption></figure>

## Bit Value

In this example, the alarm will occur if bit 12 (`1 << 12` or `0x1000`) of the tag is `1`. Only bits 0-31 of 32-bit integer values are supported (non-integer number values are ignored):

<figure><img src="https://253937570-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LzDzLyKYu6xMIADlPIj%2Fuploads%2Fgit-blob-7b2e931bfcbde7018e93936b393ab4c20ec58b48%2Falarm-conditions-bit_field.png?alt=media" alt=""><figcaption></figcaption></figure>

## Bit Field Alarms

In this example, the alarm will occur if bit 12 (`1 << 12` or `0x1000`) of the tag is `1`, but unlike the above example, this alarm is provided by the `Inverter Status` **Bit Field Type** that is assigned to the tag in the [Tag Settings](https://docs.jcore.io/clarity/tags/edit-settings) form. In this case, the **Severity**, **Bit**, **Active When 0/1**, and **Message** can't be changed here; they can only be changed by editing the bit field type (which will also affect alarms for all other tags with that bit field type).

<figure><img src="https://253937570-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LzDzLyKYu6xMIADlPIj%2Fuploads%2Fgit-blob-1a2229258013f4ef2e1b37f7e6406812c10b3a8a%2Falarm-conditions-bitFieldType.png?alt=media" alt=""><figcaption></figcaption></figure>

## Custom Formulae

In this mode you can enter arbitrary conditions. All of the above conditions can be expressed as a custom formula, and when you switch to **Custom Formula** mode it will show the formula corresponding to the condition you had selected (unless any options were blank). The formula must evaluate to `true`, `false`, or `null`; any time it becomes `true`, it triggers an alarm event. See [formula-language](https://docs.jcore.io/clarity/formula-language "mention") for a complete guide to writing formulae.

<figure><img src="https://253937570-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LzDzLyKYu6xMIADlPIj%2Fuploads%2Fgit-blob-bb943ccf77675f66305f87eb5f5221d753ed4c54%2Falarm-conditions-custom_formula.png?alt=media" alt=""><figcaption></figcaption></figure>
