# `Espex.DeviceConfig.Device`
[🔗](https://github.com/bbangert/espex/blob/main/lib/espex/device_config/device.ex#L1)

Description of an ESPHome sub-device.

An ESPHome node can expose multiple logical devices. Each entity
advertises which sub-device it belongs to via its `device_id` field.
A top-level entity (attached to the node itself, not a sub-device)
uses `device_id: 0` — which is the default for protobuf uint32 and
therefore also the default when the field is omitted.

Populate `Espex.DeviceConfig`'s `:devices` field with a list of
these structs to declare the sub-devices exposed by your server.

# `t`

```elixir
@type t() :: %Espex.DeviceConfig.Device{
  area_id: non_neg_integer(),
  id: pos_integer(),
  name: String.t()
}
```

# `new`

```elixir
@spec new(keyword()) :: t()
```

Build a `%Device{}` from keyword options.

# `to_proto`

```elixir
@spec to_proto(t()) :: Espex.Proto.DeviceInfo.t()
```

Convert to the protobuf `DeviceInfo` message used inside
`DeviceInfoResponse.devices`.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
