# `NestGen2`
[🔗](https://github.com/integration-technology/nest_gen2_sdk/blob/v0.6.6/lib/nest_gen2.ex#L1)

SDK for a rooted Nest Learning Thermostat (2nd gen).

Adding `:nest_gen2` as a dependency starts the SDK: the backplate link and
keep-alive, display, dial, piezo, backlight and power management.

Subscribe to events with `subscribe/1`; each arrives as
`{:nest_gen2, topic, payload}`:

| Topic | Payload |
|---|---|
| `:dial` | `%{delta: degrees, angle: degrees}` |
| `:dial_step` | `%{direction: :cw \| :ccw, angle: degrees}` |
| `:light` | `%{level: counts}` (light flickering as someone moves nearby, or switched on) |
| `:button` | `:down \| :up` |
| `:gesture` | `:click \| :double_click \| :long_press` (see `NestGen2.Gesture`) |
| `:motion` | `%{level: 0..10, near: boolean, far: boolean}` |
| `:climate` | `%{temperature_c: float, humidity_pct: float}` |
| `:battery` | `%{millivolts: integer}` |
| `:power` | `:awake \| :asleep` |

# `topic`

```elixir
@type topic() ::
  :dial
  | :dial_step
  | :button
  | :gesture
  | :motion
  | :climate
  | :battery
  | :power
```

# `subscribe`

```elixir
@spec subscribe(topic() | [topic()]) :: :ok
```

Subscribes the calling process to one topic or a list of topics.

# `unsubscribe`

```elixir
@spec unsubscribe(topic() | [topic()]) :: :ok
```

Unsubscribes the calling process from one topic or a list of topics.

# `version`

```elixir
@spec version() :: String.t()
```

The SDK's version, e.g. "0.2.0".

---

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