README.md

# ๐Ÿ’ก GoveeLights

[![Hex.pm](https://img.shields.io/hexpm/v/govee_lights.svg)](https://hex.pm/packages/govee_lights)
[![Documentation](https://img.shields.io/badge/hexdocs-docs-blue)](https://hexdocs.pm/govee_lights)
[![License: MIT](https://img.shields.io/badge/license-MIT-green.svg)](LICENSE)
[![Build Status](https://img.shields.io/github/actions/workflow/status/adia-dev/govee-lights-ex/ci.yml?branch=main)](https://github.com/adia-dev/govee-lights-ex/actions)

Control your Govee smart lights directly from **Elixir**.

This project provides a clean and simple wrapper for the Govee Developer API, allowing you to list devices, control power, adjust brightness, and modify color temperature, all with straightforward, minimal function calls.

> โš ๏ธ This library is **unofficial** and not affiliated with Govee.  
> It simply gives Elixir developers a nice, ergonomic way to talk to the Govee API.

---

## ๐Ÿš€ Installation

Add to your `mix.exs` dependencies:

```elixir
def deps do
  [
    {:govee_lights, "~> 0.1.2"}
  ]
end
```

Fetch deps:

```bash
mix deps.get
```

---

## ๐Ÿ”‘ API Key

You must export your Govee API key before usage:

```bash
export GOVEE_API_KEY="YOUR_KEY"
```

You can request a key here:
[https://developer.govee.com/reference/apply-you-govee-api-key](https://developer.govee.com/reference/apply-you-govee-api-key)

---

## ๐Ÿ“˜ Usage Examples

### List devices

```elixir
iex> GoveeLights.devices()
[
  %{
    "device" => "AA:BB:CC:DD:EE:FF:11:22",
    "deviceName" => "Bedroom Lightbulb",
    "model" => "H6008",
    "controllable" => true,
    "retrievable" => true,
    "supportCmds" => ["turn", "brightness", "color", "colorTem"]
  }
]
```

---

### Power Control

```elixir
GoveeLights.turn_on("AA:BB:CC:DD:EE:FF:11:22", "H6008")
GoveeLights.turn_off("AA:BB:CC:DD:EE:FF:11:22", "H6008")
```

---

### Brightness (0โ€“100)

```elixir
GoveeLights.set_brightness("AA:BB:CC:DD:EE:FF:11:22", "H6008", 50)
```

---

### Color Temperature

```elixir
# values differ per model โ†’ check devices/0 properties
GoveeLights.set_temperature("AA:BB:CC:DD:EE:FF:11:22", "H6008", 3000)
```

---

## ๐Ÿง  Notes & Tips

| Feature                | Status         |
| ---------------------- | -------------- |
| Device listing         | โœ”๏ธ `devices/0` |
| Power control          | โœ”๏ธ on/off      |
| Brightness             | โœ”๏ธ 0โ€“100       |
| Temperature            | โœ”๏ธ Kelvin      |
| RGB color support      | planned        |
| Scene / effect control | planned        |

---

## ๐Ÿ›  Development

```bash
mix test         # run test suite
mix docs         # generate documentation
```

---

## ๐Ÿ“Œ Planned Improvements / TODO

### Internal Enhancements

- **Device caching layer**
  - reduces API calls dramatically
  - TTL-based refresh or manual invalidation

- **Better error messages**
  - contextual failures (`device not found`, `brightness out of range`, etc.)
  - include Govee error metadata

- Improved fault-tolerance
  - automatic retries for transient network errors
  - optional backoff mechanism

### Feature Expansion

- Add full RGB color control
- Scene / Dynamic effect control
- Presets & automation helpers
- More test coverage + mock API adapter

Create an issue if you'd like to help or suggest something.

---

## โค๏ธ Contributing

Pull requests are welcome!
Issues, ideas, feedback, all appreciated.

If you enjoy this library, leave a โญ on the repo โ€ขอกห˜ใ‡โ€ขอกห˜