# `Espex.SerialProxy.Identity`
[🔗](https://github.com/bbangert/espex/blob/main/lib/espex/serial_proxy/identity.ex#L1)

The identity of the device behind a serial proxy port (API 1.18).

Clients that subscribe with `SubscribeSerialProxyIdentityRequest` get
one `SerialProxyIdentity` per advertised port, then another whenever a
port's identity changes. Home Assistant uses it to tell physical
devices of the same kind apart, for example two identical Zigbee
sticks. It matches on `manufacturer` and `product` whatever the
source.

An adapter reports identities through the optional
`c:Espex.SerialProxy.identity/1` callback and pushes changes with
`Espex.push_serial_proxy_identity/2`. See "Identity" in
`Espex.SerialProxy`.

## Fields

  * `instance` — the `Espex.SerialProxy.Info` instance this describes
  * `source` — `:none` when the port carries no identity (the
    default), `:usb` when it is read from the descriptors of the USB
    device behind the port
  * `connected?` — the device is present and usable on this port
  * `error?` — the USB host stack refused the descriptor query; leave
    the strings and `usb` ids empty
  * `manufacturer`, `product`, `serial_number` — descriptor strings,
    `""` for `:none` and for `:usb` while nothing is connected
  * `usb` — a map of the USB descriptor ids, sent only for `:usb`:
    `:vendor_id`, `:product_id`, `:bcd_device`, `:interface_number`
    (the `bInterfaceNumber` the port is bound through),
    `:interface_class` and `:port_number` (the port's index among those
    a vendor driver exposes on the interface). Missing keys are 0.

# `source`
*since 0.12.0* 

```elixir
@type source() :: :none | :usb
```

# `t`
*since 0.12.0* 

```elixir
@type t() :: %Espex.SerialProxy.Identity{
  connected?: boolean(),
  error?: boolean(),
  instance: non_neg_integer(),
  manufacturer: String.t(),
  product: String.t(),
  serial_number: String.t(),
  source: source(),
  usb: usb() | nil
}
```

# `usb`
*since 0.12.0* 

```elixir
@type usb() :: %{
  optional(:vendor_id) =&gt; non_neg_integer(),
  optional(:product_id) =&gt; non_neg_integer(),
  optional(:bcd_device) =&gt; non_neg_integer(),
  optional(:interface_number) =&gt; non_neg_integer(),
  optional(:interface_class) =&gt; non_neg_integer(),
  optional(:port_number) =&gt; non_neg_integer()
}
```

# `new`
*since 0.12.0* 

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

Build an `%Identity{}` from keyword options.

# `to_proto`
*since 0.12.0* 

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

Convert to the `SerialProxyIdentity` protobuf message.

---

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