Skip to content

Conditions

Conditions control when an AUTO transition fires. A condition evaluates against an emission event and returns true or false. Only transitions whose condition evaluates to true are executed.

Structure

A condition is a tree of ConditionGroups and ConditionExpressions:

  • A Condition contains one or more root-level ConditionGroups.
  • A ConditionGroup combines its children (expressions and nested groups) using AND or OR logic. Groups can also filter which data points are included in the evaluation.
  • A ConditionExpression is a leaf node that compares a specific field on the event's data point against a value.
Condition
└── ConditionGroup (AND)
    ├── ConditionExpression (concentration > 100)
    └── ConditionGroup (OR)
        ├── ConditionExpression (site_type == "compressor_station")
        └── ConditionExpression (site_type == "tank_battery")

For the condition to pass, all root-level groups must evaluate to true.

ConditionGroups

Each group has the following configuration:

FieldDescription
operatorAND — all children must be true; OR — at least one child must be true
data_providersOptional. Restrict this group's evaluation to data points from specific providers. If set, expressions in this group are only evaluated for matching data points
geo_areaOptional. Restrict this group's evaluation to events whose detection falls within a specific geographic area
parentOptional. If set, this group is a child of another group rather than a root group
positionInteger controlling the display order of groups at the same level

Data Provider Filtering

When a group has one or more data providers configured, its expressions are only evaluated for emissions detected by those providers. This allows you to write conditions like:

"If the emission is from Bridger AND concentration > 500, or from GHGSat AND concentration > 200"

Geographic Filtering

When a group has a geo_area configured, its expressions are only evaluated if the emission detection point falls within that geographic area. This allows regional rules within a single workflow.

ConditionExpressions

Each expression compares a field on the emission event to a value:

FieldDescription
field_typeThe category of field being compared: numeric, extra_data, or site_extra_data
field_nameThe specific field to compare
operatorThe comparison operator
valueThe comparison value
value2Second value, required only for the between operator

Field Types

TypeDescription
numericStandard numeric fields on the DataPoint model (e.g., concentration, emission rate)
extra_dataCustom key-value data stored in DataPoint.data (JSONB). Values are compared case-insensitively
site_extra_dataCustom key-value data stored in Site.extra_data (JSONB). Values are compared case-insensitively

Operators

OperatorSymbolDescription
lt<Less than
lte<=Less than or equal
gt>Greater than
gte>=Greater than or equal
eq==Equal
neq!=Not equal
betweenbetweenValue is between value and value2 (inclusive). Requires value2

Managing Conditions in Django Admin

To create or edit a condition:

  1. Open a Workflow Definition in Django Admin.
  2. In the transitions inline, click the Condition link next to the relevant transition. If no condition exists yet, click Add condition.
  3. You will be taken to the Condition edit form, which shows:
    • A formatted summary of the current condition at the top
    • Nested inlines for groups and expressions
  4. Add root-level ConditionGroups first, then add ConditionExpressions within each group.
  5. To nest groups, add a group with the parent field pointing to an existing group.

The condition editor caches available field names per company so that extra_data and site_extra_data field dropdowns are populated based on actual data in the platform.

Validation

When a condition is saved, the system validates that:

  • At least one root-level group exists
  • Every group has at least one expression, child group, data provider filter, or geo area filter
  • The value2 field is populated when the between operator is used

If validation fails, an error message is shown and the condition is not saved.

Condition Summary Display

In the Condition admin, a formatted HTML summary of the full condition tree is shown at the top of the form. This gives a human-readable overview of all groups and expressions without needing to expand every inline.

Example output:

(concentration > 100.0)
AND
(site_type == "compressor_station" OR site_type == "tank_battery")