> For the complete documentation index, see [llms.txt](https://docs.chirpwireless.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.chirpwireless.io/dashboards/adding-widgets/conditions.md).

# Conditions

Set per-metric color rules so a reading turns green, yellow, or red — green for comfortable, red for check it now.

Conditions are per-metric color rules that turn a raw sensor reading into visible meaning. Instead of looking at a number and deciding whether it's good or bad, the widget does that for you — a green pin means comfortable, a red pin means check it now, a yellow marker means getting close to the limit. You define what those colors mean for each sensor in each place it's used.

A temperature sensor in the living room should be green at 18–24°C. The same type of sensor watching a fridge should be green at 2–5°C. Different place, different meaning, completely different conditions — even though the data looks the same.

## Which widgets use conditions?

Conditions are available for **Last Data** and **Image** widgets. Each metric in these widgets has its own set of conditions, configured independently.

The **Chart** widget uses a different approach — per-metric color picker and threshold bands on the graph. See [Chart Widget](https://docs.chirpwireless.io/dashboards/adding-widgets/chart-widget.md) if you're working with a Chart.

**Note on metric types:** Both the Image and Last Data metric selectors surface numeric sensors only (INTEGER and FLOAT types). Number conditions are the practical path for both widgets. The conditions modal also exposes String and Boolean data type options — these are described below — but they require a widget that can select a sensor of those types, which is not currently the case for Last Data or the Image widget.

## How do I open the Conditions modal?

1. Open the widget's settings and go to the **Datasource** tab.
2. Find the metric row for the sensor you want to configure.
3. Tap the **Conditions button** — it's labeled **"Conditions: N"** where N is the number of conditions currently set.
4. The Conditions modal opens.

## What does the Conditions modal contain?

The modal is titled **"Conditions"**, and underneath it a subtitle says: "The conditions set first will be considered as a priority"

**Header (applies to the whole metric):**

* **Device metric** — Read-only. Shows which sensor this modal is for.
* **Unit** — A free-text box for the unit shown next to the value on the tile (like `42 cm`). Type **whatever unit you want** — `mm`, `cm`, `m`, inches, `L`, `°C`, anything. It's not limited to a list and it's not a percentage unless you make it one. It starts from the sensor's own unit, and you can change it to suit. The **From / To** numbers in your rules are in this unit (so `From 0 To 30` means 0–30 of whatever you set here).
* **Icon** — Pick or change the icon for this metric.
* **Default color** — The color used when no condition matches. This is the only place to set the metric's base color.

**Conditions list:** Each condition has:

* **Condition name** *(required)* — A label like "Comfortable", "Warning", or "Critical". Must not be empty.
* **Data type** — Number, String, or Boolean (see below)
* **Value fields** — Depend on the data type
* **Color** — The color to show when this condition matches
* **Delete** — Remove this condition

**Add condition** — Tap to add a new condition. New conditions default to: name "Condition N", type Number, From 0, To 100, primary color.

There's no limit on the number of conditions you can add.

**Save** (disabled while any validation error exists) / **Cancel**

## Which condition wins when several match?

Chirp checks the conditions from the top of the list downward and stops at the **first one that fits the current reading**; that condition picks the color, so order matters.

If your sensor reads 7°C and you have:

1. "Normal" — Number, From 2, To 8 — green
2. "Warning" — Number, From 8, To 12 — yellow

The reading 7°C matches condition 1, so green is shown. Condition 2 is not evaluated.

To change priority, reorder the conditions in the list.

## Which value fields appear for each data type?

### Number

**From** and **To** fields — both are optional. Either can be left empty to create an open-ended range:

* **Empty From** — matches any value below To (no lower limit)
* **Empty To** — matches any value above From (no upper limit)
* **Both filled** — From must be ≤ To

Examples:

* From: 18, To: 24 → matches readings between 18 and 24
* From: 30 (no To) → matches any reading 30 and above
* (no From), To: 5 → matches any reading 5 and below

### Number conditions — on/off and open/closed states

Many sensors report binary state as a number: 1 when something is active or open, 0 when it is off or closed. Number conditions map these values to meaningful labels and colors:

* Condition "On" — Number, From 1, To 1 — yellow (or your chosen color)
* Condition "Off" — Number, From 0, To 0 — gray

Examples using this pattern:

* Light sensor: 1 = "On" (yellow), 0 = "Off" (gray)
* Contact sensor (door): 1 = "Open" (red), 0 = "Closed" (green)
* Leak sensor: 1 = "Leak detected" (red), 0 = "Clear" (green)

The same Number condition type handles all of these. The difference is only in the labels and colors you assign.

### String

A single **Value** text field. Matches the reading exactly, case-sensitive. The conditions modal offers it only for widgets that can show a String sensor, which the Last Data and Image widget selectors cannot.

### Boolean

A **True / False** dropdown. Matches the reading exactly. The conditions modal offers it only for widgets that can show a Boolean sensor, which the Last Data and Image widget selectors cannot.

## Which color is used when no condition matches?

1. **Matched condition color** — The color of the first matching condition
2. **Default color** — The color set in the modal header (applies when no condition matches)
3. **Platform default** — Applied when no default color is set in the modal

## What are some examples of conditions?

### Keeping something topped up

Say you've got a sensor on something you want to keep full — a rainwater tank, the salt in a water softener, a heating-oil tank — reading how full it is in whatever unit suits you. Set that in the **Unit** box (it takes anything — `cm`, `m`, inches, liters…); here we'll use **centimeters** of depth. Three rules then turn that into a clear "do I need to refill?" status, and since the **first matching rule wins**, list the most urgent one first:

* **Refill** — Number, From 0, To 30 — red
* **Getting Low** — Number, From 30, To 50 — amber
* **Normal Level** — Number, From 50, To 100 — green

<figure><img src="https://1153890212-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxgYoHO4zlaBzHJcfIrto%2Fuploads%2Fgit-blob-17a87bc099e830525c8ca3b081cda6066e8bc951%2Fconditions.jpg?alt=media" alt="Conditions window with three fill-level rules — Refill 0–30 red, Getting Low 30–50 amber, Normal Level 50–100 green"><figcaption></figcaption></figure>

The tile stays green while it's well stocked, turns amber as it runs down, and goes red as soon as it drops into the refill zone — so you top it up before it runs out. Want a nudge on your phone too? Add an [alert](https://docs.chirpwireless.io/alarm.md) on the same level.

### Number conditions — temperature in two contexts

**Living room sensor:**

* "Comfortable" — From 18, To 24 — green
* "A bit cool" — From 15, To 18 — yellow
* "Cold alert" — (no From), To 15 — red

**Fridge sensor (same sensor type, completely different meaning):**

* "Normal" — From 2, To 5 — green
* "Check fridge" — From 5 (no upper limit) — red

The readings look the same — both are temperatures in °C. The conditions are completely different because "2°C in a fridge" is fine, while "2°C in the living room" is an emergency.

### Number conditions — open-ended bounds for a tank level

A water tank sensor reports its fill level (here in percent, but you choose the unit):

* "Critical" — (no From), To 20 — red
* "Low" — From 20, To 50 — yellow
* "Good" — From 50 (no upper limit) — green

The first condition catches everything below 20%. The last catches everything above 50%. There's no need to specify exact upper/lower limits for every range.

### Number conditions — any numeric reading

The system doesn't care what the number represents. The same pattern works for:

* Battery level (%, 0–100)
* Soil moisture (%, 0–100)
* CO₂ level (ppm)
* Tank volume (liters or gallons)
* Any sensor that reports numbers

The meaning and the thresholds are yours to define.

### String conditions — device status sensor

A sensor that reports text values like "OK", "WARNING", or "FAULT":

* "OK" — String, Value: OK — green
* "Warning" — String, Value: WARNING — yellow
* "Fault" — String, Value: FAULT — red

No math involved. The widget reads the string, matches it exactly, and shows the right color.

### Boolean conditions — binary state sensors

**Motion sensor:**

* "Motion detected" — Boolean, True — orange
* "Clear" — Boolean, False — green

**Leak detector:**

* "Leak detected" — Boolean, True — red
* "Clear" — Boolean, False — green

**Pump running:**

* "Running" — Boolean, True — blue
* "Idle" — Boolean, False — gray

Any binary sensor works the same way: pick a color for each state and a label that makes sense in context.

## See also

* [Last Data Widget](https://docs.chirpwireless.io/dashboards/adding-widgets/last-data-widget.md) — Use conditions to color sensor readings and gauges
* [Image Widget](https://docs.chirpwireless.io/dashboards/adding-widgets/image-widget.md) — Use conditions to color the pins on your image
