# StateReader

# StateReader


```
class StateReader : Node, HasOutput
```

<br />

|---|---|---|
| [kotlin.Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html) |||
| ↳ | [com.google.home.automation.Node](https://developers.home.google.com/reference/kotlin/com/google/home/automation/Node) ||
|   | ↳ | [com.google.home.automation.StateReader](https://developers.home.google.com/reference/kotlin/com/google/home/automation/StateReader) |

*** ** * ** ***

A class that accesses a trait's state.

## Summary

| ### Public constructors |
|---|
| `https://developers.home.google.com/reference/kotlin/com/google/home/automation/StateReader#StateReader(com.google.home.automation.Expression,com.google.home.TraitFactory,kotlin.String)( entityExpression: https://developers.home.google.com/reference/kotlin/com/google/home/automation/Expression, trait: https://developers.home.google.com/reference/kotlin/com/google/home/TraitFactory<https://developers.home.google.com/reference/kotlin/com/google/home/Trait>, output: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html )` Create a `StateReader` instance from an entity expression, a `https://developers.home.google.com/reference/kotlin/com/google/home/DeviceType`, and a `https://developers.home.google.com/reference/kotlin/com/google/home/Trait`. |
| `https://developers.home.google.com/reference/kotlin/com/google/home/automation/StateReader#StateReader(com.google.home.HasId,com.google.home.TraitFactory,kotlin.String)(entity: https://developers.home.google.com/reference/kotlin/com/google/home/HasId, trait: https://developers.home.google.com/reference/kotlin/com/google/home/TraitFactory<https://developers.home.google.com/reference/kotlin/com/google/home/Trait>, output: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)` Create a `StateReader` instance from an entity and a `https://developers.home.google.com/reference/kotlin/com/google/home/Trait`. |
| `https://developers.home.google.com/reference/kotlin/com/google/home/automation/StateReader#StateReader(com.google.home.HasId,com.google.home.DeviceTypeFactory,com.google.home.TraitFactory,kotlin.String)( entity: https://developers.home.google.com/reference/kotlin/com/google/home/HasId, deviceType: https://developers.home.google.com/reference/kotlin/com/google/home/DeviceTypeFactory<https://developers.home.google.com/reference/kotlin/com/google/home/DeviceType>?, trait: https://developers.home.google.com/reference/kotlin/com/google/home/TraitFactory<https://developers.home.google.com/reference/kotlin/com/google/home/Trait>, output: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html )` Create a `StateReader` instance from an entity, a `https://developers.home.google.com/reference/kotlin/com/google/home/DeviceType`, and a `https://developers.home.google.com/reference/kotlin/com/google/home/Trait`. |

| ### Public properties |
|---|---|
| `https://developers.home.google.com/reference/kotlin/com/google/home/DeviceTypeFactory<https://developers.home.google.com/reference/kotlin/com/google/home/DeviceType>?` | `https://developers.home.google.com/reference/kotlin/com/google/home/automation/StateReader#deviceType()` The `https://developers.home.google.com/reference/kotlin/com/google/home/DeviceType` associated with the `StateReader`. |
| `https://developers.home.google.com/reference/kotlin/com/google/home/HasId?` | `https://developers.home.google.com/reference/kotlin/com/google/home/automation/StateReader#entity()` The unique ID for the entity associated with the `StateReader`. |
| `https://developers.home.google.com/reference/kotlin/com/google/home/automation/Expression` | `https://developers.home.google.com/reference/kotlin/com/google/home/automation/StateReader#entityExpression()` An expression that selects an entity or a list of entity associated with the `StateReader`. |
| `open https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html` | `https://developers.home.google.com/reference/kotlin/com/google/home/automation/StateReader#output()` The unique ID for the `StateReader` node output. |
| `https://developers.home.google.com/reference/kotlin/com/google/home/TraitFactory<https://developers.home.google.com/reference/kotlin/com/google/home/Trait>` | `https://developers.home.google.com/reference/kotlin/com/google/home/automation/StateReader#trait()` The `https://developers.home.google.com/reference/kotlin/com/google/home/Trait` associated with the `StateReader`. |
| `https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html` | `https://developers.home.google.com/reference/kotlin/com/google/home/automation/StateReader#traitId()` The unique ID for the trait associated with the `StateReader`. |

| ### Inherited properties |
|---|
| From [com.google.home.automation.Node](https://developers.home.google.com/reference/kotlin/com/google/home/automation/Node) |---|---| | `https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html?` | `https://developers.home.google.com/reference/kotlin/com/google/home/automation/Node#nodeId()` String identifier of this node. | |

## Public constructors

### StateReader

```
StateReader(
    entityExpression: Expression,
    trait: TraitFactory<Trait>,
    output: String
)
```

Create a `StateReader` instance from an entity expression, a `https://developers.home.google.com/reference/kotlin/com/google/home/DeviceType`, and a `https://developers.home.google.com/reference/kotlin/com/google/home/Trait`. An entity may be a `Device` or a `Structure`.

| Parameters |
|---|---|
| `entityExpression: https://developers.home.google.com/reference/kotlin/com/google/home/automation/Expression` | An expression that selects an entity or a list of entities associated with the `StateReader`. |
| `trait: https://developers.home.google.com/reference/kotlin/com/google/home/TraitFactory<https://developers.home.google.com/reference/kotlin/com/google/home/Trait>` | The `https://developers.home.google.com/reference/kotlin/com/google/home/Trait` associated with the `https://developers.home.google.com/reference/kotlin/com/google/home/automation/StateReader`. |
| `output: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html` | The output message. |

### StateReader

```
StateReader(entity: HasId, trait: TraitFactory<Trait>, output: String)
```

Create a `StateReader` instance from an entity and a `https://developers.home.google.com/reference/kotlin/com/google/home/Trait`. An entity may be a `Device` or a `Structure`.

| Parameters |
|---|---|
| `entity: https://developers.home.google.com/reference/kotlin/com/google/home/HasId` | The unique ID of the entity associated with the `StateReader`. |
| `trait: https://developers.home.google.com/reference/kotlin/com/google/home/TraitFactory<https://developers.home.google.com/reference/kotlin/com/google/home/Trait>` | The `https://developers.home.google.com/reference/kotlin/com/google/home/Trait` associated with the `StateReader`. |
| `output: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html` | Data that uniquely identifies the `StateReader`. Note that this is different than the `StateReader` node ID. |

### StateReader

```
StateReader(
    entity: HasId,
    deviceType: DeviceTypeFactory<DeviceType>?,
    trait: TraitFactory<Trait>,
    output: String
)
```

Create a `StateReader` instance from an entity, a `https://developers.home.google.com/reference/kotlin/com/google/home/DeviceType`, and a `https://developers.home.google.com/reference/kotlin/com/google/home/Trait`. An entity may be a `Device` or a `Structure`.

| Parameters |
|---|---|
| `entity: https://developers.home.google.com/reference/kotlin/com/google/home/HasId` | The unique ID of the `StateReader`. |
| `deviceType: https://developers.home.google.com/reference/kotlin/com/google/home/DeviceTypeFactory<https://developers.home.google.com/reference/kotlin/com/google/home/DeviceType>?` | The `https://developers.home.google.com/reference/kotlin/com/google/home/DeviceType` associated with the `https://developers.home.google.com/reference/kotlin/com/google/home/automation/StateReader`. |
| `trait: https://developers.home.google.com/reference/kotlin/com/google/home/TraitFactory<https://developers.home.google.com/reference/kotlin/com/google/home/Trait>` | The `https://developers.home.google.com/reference/kotlin/com/google/home/Trait` associated with the `https://developers.home.google.com/reference/kotlin/com/google/home/automation/StateReader`. |
| `output: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html` | The output message. |

## Public properties

### deviceType

```
val deviceType: DeviceTypeFactory<DeviceType>?
```

The `https://developers.home.google.com/reference/kotlin/com/google/home/DeviceType` associated with the `StateReader`.

### entity

```
val entity: HasId?
```

The unique ID for the entity associated with the `StateReader`. Expected to be either a HomeDevice or a `https://developers.home.google.com/reference/kotlin/com/google/home/Structure`. If the target is not a static entity, this is set to `null`.

### entityExpression

```
val entityExpression: Expression
```

An expression that selects an entity or a list of entity associated with the `StateReader`.

### output

```
open val output: String
```

The unique ID for the `StateReader` node output.

### trait

```
val trait: TraitFactory<Trait>
```

The `https://developers.home.google.com/reference/kotlin/com/google/home/Trait` associated with the `StateReader`.

### traitId

```
val traitId: String
```

The unique ID for the trait associated with the `StateReader`.