- Sync and async HTTP clients for Ignis Core WiZ server - 23 endpoints: auth, devices, groups, control, schedules, stats, API keys - Pydantic models with client-side validation - 108 unit tests - README with role table and usage examples
72 lines
1.9 KiB
Markdown
72 lines
1.9 KiB
Markdown
# Ignis Client (Python)
|
|
|
|
HTTP-клиент для Ignis Core — сервера управления WiZ-лампами.
|
|
|
|
## Установка
|
|
|
|
```bash
|
|
pip install -e .
|
|
# или вручную:
|
|
pip install httpx pydantic
|
|
```
|
|
|
|
## Быстрый старт
|
|
|
|
```python
|
|
from ignis_client import IgnisClient, CommandRequest
|
|
|
|
ignis = IgnisClient("http://192.168.1.50:8000", api_key="change-me")
|
|
|
|
# Авторизация
|
|
me = ignis.auth_me()
|
|
print(f"Роль: {me['name']}")
|
|
|
|
# Список устройств
|
|
devices = ignis.list_devices()
|
|
for mac, dev in devices.items():
|
|
print(f"{mac}: {dev['name']}")
|
|
|
|
# Управление группой
|
|
ignis.control_group("bedroom", CommandRequest(state=True, brightness=80))
|
|
|
|
# Сцена
|
|
ignis.control_group("livingroom", CommandRequest(scene="fireplace"))
|
|
|
|
# RGB
|
|
ignis.control_device("aa:bb:cc:dd", CommandRequest(r=255, g=120, b=60))
|
|
```
|
|
|
|
## Асинхронный клиент
|
|
|
|
```python
|
|
from ignis_client import AsyncIgnisClient, CommandRequest
|
|
|
|
async with AsyncIgnisClient("http://...", api_key="...") as ignis:
|
|
await ignis.control_group("bedroom", CommandRequest(state=False))
|
|
```
|
|
|
|
## Роли доступа
|
|
|
|
| Метод | guest | admin | master |
|
|
|---|---|---|---|
|
|
| `auth_me`, `list_devices`, `list_groups`, `list_scenes` | да | да | да |
|
|
| `control_device`, `control_group`, `blink_device` | да | да | да |
|
|
| `device_status`, `group_status` | да | да | да |
|
|
| `system_info` | да | да | да |
|
|
| `create_group`, `delete_group`, `rescan` | — | да | да |
|
|
| `create_*_schedule`, `list_schedules`, `delete_schedule` | — | да | да |
|
|
| `stats_summary`, `stats_log` | — | да | да |
|
|
| `list_api_keys`, `create_api_key`, `revoke_api_key`, `activate_api_key` | — | — | да |
|
|
|
|
## Тесты
|
|
|
|
```bash
|
|
python -m unittest discover -s tests -v
|
|
```
|
|
|
|
## Зависимости
|
|
|
|
- Python >= 3.10
|
|
- httpx >= 0.26
|
|
- pydantic >= 2.5
|