Metadata-Version: 2.4
Name: mordomus
Version: 0.1.1
Summary: Python client for Mordomus / iThink home automation HTTP API
Project-URL: Homepage, https://github.com/skymoore/mordomus
Project-URL: Documentation, https://github.com/skymoore/mordomus#readme
Project-URL: Repository, https://github.com/skymoore/mordomus
Project-URL: Issues, https://github.com/skymoore/mordomus/issues
Project-URL: Changelog, https://github.com/skymoore/mordomus/blob/main/CHANGELOG.md
Author: Sky
License-Expression: MIT
License-File: LICENSE
Keywords: home-automation,httpx,ithink,mordomus,smart-home
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Topic :: Home Automation
Classifier: Typing :: Typed
Requires-Python: >=3.11
Requires-Dist: httpx>=0.27
Provides-Extra: dev
Requires-Dist: build>=1.2; extra == 'dev'
Requires-Dist: pytest-asyncio>=0.24; extra == 'dev'
Requires-Dist: pytest>=8.0; extra == 'dev'
Requires-Dist: respx>=0.21; extra == 'dev'
Description-Content-Type: text/markdown

# mordomus

Python client for the **Mordomus / iThink** home-automation HTTP API.

```bash
pip install mordomus
```

```python
from mordomus import Mordomus

with Mordomus("http://192.168.8.46:8888", user="user", password="1234") as home:
    for light in home.devices.lights():
        print(light.cod, light.name, light.value)

    home.devices.on("MDO17")
    home.devices.set_value("MDO17", 100)
    home.climate.set_temperature(room=2, celsius=22)
```

Async:

```python
import asyncio
from mordomus import AsyncMordomus

async def main():
    async with AsyncMordomus("http://192.168.8.46:8888", user="user", password="1234") as home:
        states = await home.devices.states()
        print(states)

asyncio.run(main())
```

## Auth

Login is session-cookie based (`IDHTTPSESSIONID`). Credentials are hashed as:

```
value  = md5(timestamp_ms + username.lower()) + md5(timestamp_ms + password)
value1 = str(3 * timestamp_ms)
GET /logas?value=...&value1=...
```

The client handles this automatically and re-authenticates on `401`.

## API surface

| Resource | Methods |
|----------|---------|
| `home.system` | `version()`, `session_ok()`, `logout()` |
| `home.devices` | `list()`, `states()`, `get()`, `on()`, `off()`, `toggle()`, `set_value()`, `set_rgb()`, `by_room()`, `lights()`, `blinds()`, … |
| `home.climate` | `list()`, `set_temperature()`, `set_mode()`, `set_duration()` |
| `home.alarms` | `list()`, `states()` |
| `home.quickmenu` | `list()`, `run()` |
| `home.multimedia` | `devices()`, `state(room)`, `control()` |
| `home.settings` | `get()`, `set()` |

## Home Assistant

Separate package: [`mordomus-homeassistant`](https://pypi.org/project/mordomus-homeassistant/)

```bash
pip install mordomus-homeassistant
mordomus-ha install /config          # or: mordomus-ha install ~/.homeassistant
# restart Home Assistant → Add integration → Mordomus
```

See [home-assistant/README.md](home-assistant/README.md).

## Development

```bash
uv sync
uv run pytest
```

### Publish to PyPI

Two packages, two versions (keep them in sync for paired releases):

| Package | Path | PyPI name |
|---------|------|-----------|
| Library | repo root | `mordomus` |
| HA integration | `home-assistant/` | `mordomus-homeassistant` |

```bash
# 1. Bump version in pyproject.toml (+ home-assistant/pyproject.toml + manifest.json)
# 2. Build + upload (API token required)
export UV_PUBLISH_TOKEN=pypi-...
./scripts/publish.sh both            # production PyPI
./scripts/publish.sh both --test     # TestPyPI first
./scripts/publish.sh lib --dry-run   # build only
```

Or publish from GitHub Actions on release (trusted publishing) — see `.github/workflows/publish.yml`.
