# IfFlowDsl


```
interface IfFlowDsl : AutomationFlowContributor
```

<br />

Known direct subclasses [SequentialFlowBuilder](https://developers.home.google.com/reference/kotlin/com/google/home/automation/SequentialFlowBuilder)

|---|---|
| `https://developers.home.google.com/reference/kotlin/com/google/home/automation/SequentialFlowBuilder` | Type-safe builder that builds a `https://developers.home.google.com/reference/kotlin/com/google/home/automation/SequentialFlow` Node. |

*** ** * ** ***

Interface for constructing conditional flow nodes, starting with an `https://developers.home.google.com/reference/kotlin/com/google/home/automation/IfChain` and potentially concluding as an `https://developers.home.google.com/reference/kotlin/com/google/home/automation/IfFlow`, and contributing them to an automation flow.

An `https://developers.home.google.com/reference/kotlin/com/google/home/automation/IfChain` represents an in-progress conditional structure, consisting of an initial `ifThen` and zero or more `elseIf` clauses. An `https://developers.home.google.com/reference/kotlin/com/google/home/automation/IfFlow` is a complete conditional structure, which is formed when an `orElse` clause is added to an `https://developers.home.google.com/reference/kotlin/com/google/home/automation/IfChain`.

## Summary

| ### Public functions |
|---|---|
| `open https://developers.home.google.com/reference/kotlin/com/google/home/automation/IfChain` | `@https://errorprone.info/api/latest/com/google/errorprone/annotations/CanIgnoreReturnValue.html https://developers.home.google.com/reference/kotlin/com/google/home/automation/IfChain.https://developers.home.google.com/reference/kotlin/com/google/home/automation/IfFlowDsl#(com.google.home.automation.IfChain).elseIf(com.google.home.automation.TypedExpression,kotlin.Function1)(condition: https://developers.home.google.com/reference/kotlin/com/google/home/automation/TypedExpression<https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html>, then: https://developers.home.google.com/reference/kotlin/com/google/home/automation/SequentialFlowBuilder.() -> https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html)` Extends the current `https://developers.home.google.com/reference/kotlin/com/google/home/automation/IfChain` by adding an `elseIf` clause. |
| `open https://developers.home.google.com/reference/kotlin/com/google/home/automation/IfChain` | `@https://errorprone.info/api/latest/com/google/errorprone/annotations/CanIgnoreReturnValue.html https://developers.home.google.com/reference/kotlin/com/google/home/automation/IfFlowDsl#ifThen(com.google.home.automation.TypedExpression,kotlin.Function1)(condition: https://developers.home.google.com/reference/kotlin/com/google/home/automation/TypedExpression<https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html>, then: https://developers.home.google.com/reference/kotlin/com/google/home/automation/SequentialFlowBuilder.() -> https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html)` Starts a conditional block by building an `https://developers.home.google.com/reference/kotlin/com/google/home/automation/IfChain` with an initial `ifThen` clause and adding it to the flow. |
| `open https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html` | `https://developers.home.google.com/reference/kotlin/com/google/home/automation/IfChain.https://developers.home.google.com/reference/kotlin/com/google/home/automation/IfFlowDsl#(com.google.home.automation.IfChain).orElse(kotlin.Function1)(elseThen: https://developers.home.google.com/reference/kotlin/com/google/home/automation/SequentialFlowBuilder.() -> https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html)` Completes the conditional block by adding a final `orElse` clause to the `https://developers.home.google.com/reference/kotlin/com/google/home/automation/IfChain`. |

### Inherited functions

From [com.google.home.automation.AutomationFlowContributor](https://developers.home.google.com/reference/kotlin/com/google/home/automation/AutomationFlowContributor) `https://developers.home.google.com/reference/kotlin/com/google/home/automation/AutomationFlowBuilder` `https://developers.home.google.com/reference/kotlin/com/google/home/automation/AutomationFlowContributor#flowBuilder()()`

## Public functions

### elseIf

```
@CanIgnoreReturnValue
open fun IfChain.elseIf(condition: TypedExpression<Boolean>, then: SequentialFlowBuilder.() -> Unit): IfChain
```

Extends the current `https://developers.home.google.com/reference/kotlin/com/google/home/automation/IfChain` by adding an `elseIf` clause. This allows for multiple conditional branches. Returns a new `https://developers.home.google.com/reference/kotlin/com/google/home/automation/IfChain` instance representing the updated conditional structure.

| Parameters |
|---|---|
| `condition: https://developers.home.google.com/reference/kotlin/com/google/home/automation/TypedExpression<https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html>` | The `https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html` expression for the `elseIf` clause. |
| `then: https://developers.home.google.com/reference/kotlin/com/google/home/automation/SequentialFlowBuilder.() -> https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html` | The `https://developers.home.google.com/reference/kotlin/com/google/home/automation/Node` to execute if the condition is true. |

| Returns |
|---|---|
| `https://developers.home.google.com/reference/kotlin/com/google/home/automation/IfChain` | A new `https://developers.home.google.com/reference/kotlin/com/google/home/automation/IfChain` instance including the added `elseIf` clause. |

### ifThen

```
@CanIgnoreReturnValue
open fun ifThen(condition: TypedExpression<Boolean>, then: SequentialFlowBuilder.() -> Unit): IfChain
```

Starts a conditional block by building an `https://developers.home.google.com/reference/kotlin/com/google/home/automation/IfChain` with an initial `ifThen` clause and adding it to the flow. The returned `https://developers.home.google.com/reference/kotlin/com/google/home/automation/IfChain` can be extended with `elseIf` or finalized with `orElse`.

| Parameters |
|---|---|
| `condition: https://developers.home.google.com/reference/kotlin/com/google/home/automation/TypedExpression<https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html>` | The `https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html` expression for the `ifThen` clause. |
| `then: https://developers.home.google.com/reference/kotlin/com/google/home/automation/SequentialFlowBuilder.() -> https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html` | The `https://developers.home.google.com/reference/kotlin/com/google/home/automation/Node` to execute if the condition is true. |

| Returns |
|---|---|
| `https://developers.home.google.com/reference/kotlin/com/google/home/automation/IfChain` | The created `https://developers.home.google.com/reference/kotlin/com/google/home/automation/IfChain` instance, which can be used to add `elseIf` or `orElse` clauses. |

### orElse

```
open fun IfChain.orElse(elseThen: SequentialFlowBuilder.() -> Unit): Unit
```

Completes the conditional block by adding a final `orElse` clause to the `https://developers.home.google.com/reference/kotlin/com/google/home/automation/IfChain`. This transforms the `https://developers.home.google.com/reference/kotlin/com/google/home/automation/IfChain` into a fully formed `https://developers.home.google.com/reference/kotlin/com/google/home/automation/IfFlow` within the automation graph. Once `orElse` is called, no further `elseIf` or `orElse` can be added to this specific conditional structure.

| Parameters |
|---|---|
| `elseThen: https://developers.home.google.com/reference/kotlin/com/google/home/automation/SequentialFlowBuilder.() -> https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html` | The `https://developers.home.google.com/reference/kotlin/com/google/home/automation/Node` to execute if none of the preceding `ifThen` or `elseIf` conditions are true. |