> Documentation index: https://developers.home.google.com/apis/ios/automation/dsl/llms.txt

Operators allow you to check the value of trait attributes against specific
values, compare them to one another, and to combine expressions used in
`condition` nodes.

Operators are made available through the following `import` statements:

```swift
import GoogleHomeSDK
```

## Comparison operators

### between

Evaluates to `true` when the value of Expression 1 is between that of Expression
2 and Expression 3 (inclusive). Expressions are ranked differently depending on
their data type. Simple data types such as numbers and strings are ranked the
same way they are in Swift.

<br />

| Expression 1 | Expression 2 | Expression 3 | Result |
|:---:|:---:|:---:|:---:|
| `6` | `1` | `3` | `false` |
| `2` | `1` | `3` | `true` |
[*Example*]

<br />

#### DSL example

```swift
let time = stateReader(structure, Google.TimeTrait)
condition {
  time.currentTime
     .between(
      time.sunsetTime,
      time.sunriseTime)
}
```

### equals

Evaluates to `true` when the Expression 1 equals Expression 2.

<br />

| Expression 1 | Expression 2 | Result |
|:---:|:---:|:---:|
| `6` | `1` | `false` |
| `2` | `2` | `true` |
[*Example*]

<br />

#### DSL example

```swift
lightOnOffState.onOff.equals(true)
```

### greaterThan

Evaluates to `true` when the Expression 1 is greater than Expression 2.

<br />

| Expression 1 | Expression 2 | Result |
|:---:|:---:|:---:|
| `6` | `1` | `true` |
| `1` | `6` | `false` |
[*Example*]

<br />

#### DSL example

```swift
// 1555 = 15 degrees C ~ 60 degrees F
temperatureMeasurement.measuredValue.greaterThan(1555)
```

### greaterThanOrEquals

Evaluates to `true` when the Expression 1 is greater than or equal to Expression
2.

<br />

| Expression 1 | Expression 2 | Result |
|:---:|:---:|:---:|
| `8` | `6` | `true` |
| `6` | `6` | `true` |
| `1` | `6` | `false` |
[*Example*]

<br />

#### DSL example

```swift
starterNode.measuredValue.greaterThanOrEquals(50)
```

### lessThan

evaluates to `true` when the Expression 1 is less than Expression 2.

<br />

| Expression 1 | Expression 2 | Result |
|:---:|:---:|:---:|
| `6` | `1` | `false` |
| `1` | `6` | `true` |
[*Example*]

<br />

#### DSL example

```swift
// 1555 = 15 degrees C ~ 60 degrees F
temperatureMeasurement.measuredValue.lessThan(1555)
```

### lessThanOrEquals

Evaluates to `true` when the Expression 1 is less than or equal to Expression 2.

<br />

| Expression 1 | Expression 2 | Result |
|:---:|:---:|:---:|
| `8` | `6` | `false` |
| `6` | `6` | `true` |
| `1` | `6` | `true` |
[*Example*]

<br />

#### DSL example

```swift
starterNode.measuredValue.lessThanOrEquals(50)
```

### notEquals

Evaluates to `true` when the Expression 1 is not equal to Expression 2.

<br />

| Expression 1 | Expression 2 | Result |
|:---:|:---:|:---:|
| `6` | `1` | `true` |
| `1` | `6` | `true` |
| `2` | `2` | `false` |
[*Example*]

<br />

#### DSL example

```swift
occupancySensorStarter.occupancy.notEquals(.occupied)
```

## Arithmetic operators

Infix operators such as +, -, \*, or / are not supported for building automation
expressions in Swift. Instead, use the operators provided by the SDK, such as
[`Plus`](https://developers.home.google.com/reference/swift/GoogleHomeSDK/Structs/Plus.md.txt) or
[`Minus`](https://developers.home.google.com/reference/swift/GoogleHomeSDK/Structs/Minus.md.txt).

### Add

The addition operator `.plus( )`.

#### DSL example

```swift
var totalCount = 0
...
totalCount = totalCount.plus(1)
```

### Subtract

The subtraction operator `.minus( )`.

#### DSL example

```swift
var countdown = 10
...
countdown = countdown.minus(1)
```

### Multiply

The multiplication operator `.multiply( )`.

#### DSL example

```swift
val millis = seconds.multiply(1000)
```

### Divide

The division operator `.divide( )`.

#### DSL example

```swift
val rpm = revolutions.divide(minutes)
```

## Logical operators

### and

Combines two expressions in a logical AND expression, evaluating to `true` when
both expressions are `true`.

<br />

| Expression 1 | Expression 2 | Result |
|:---:|:---:|:---:|
| `false` | `false` | `false` |
| `true` | `false` | `false` |
| `false` | `true` | `false` |
| `true` | `true` | `true` |
[*Example*]

<br />

#### DSL example

```swift
condition {
  let exp1 = armState.armState
  let exp2 = doorLockState.lockState
  exp1.and(exp2)
}
```

### not

Negates the logical value of an expression.

<br />

| Expression | Result |
|:---:|:---:|
| `true` | `false` |
| `false` | `true` |
[*Example*]

<br />

#### DSL example

```swift
condition {
  let exp1 = armState.armState
  let exp2 = doorLockState.lockState
  exp1.and(exp2.not())
}
```

### or

Combines two expressions into a logical OR expression.

<br />

| Expression 1 | Expression 2 | Result |
|:---:|:---:|:---:|
| `false` | `false` | `false` |
| `true` | `false` | `true` |
| `false` | `true` | `true` |
[*Example*]

<br />

#### DSL example

```swift
condition {
  let exp1 = doorLockState.lockState.equals(.unlocked)
  let exp2 = contactSensorState.stateValue.equals(false)
  exp1.or(exp2)
}
```