Metadata-Version: 2.5
Name: herohealth
Version: 0.1.0
Summary: Unofficial Python client for Hero Health devices and cloud services
Project-URL: Homepage, https://github.com/andrewtryder/py-herohealth
Project-URL: Repository, https://github.com/andrewtryder/py-herohealth
Project-URL: Issues, https://github.com/andrewtryder/py-herohealth/issues
License: MIT
License-File: LICENSE
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Requires-Python: <3.15,>=3.12
Requires-Dist: filelock<5,>=4.2.1
Requires-Dist: httpx<1,>=0.27
Requires-Dist: python-dotenv<2,>=1.2.2
Requires-Dist: websockets<16,>=14
Provides-Extra: dev
Requires-Dist: build; extra == 'dev'
Requires-Dist: mypy>=1.19; extra == 'dev'
Requires-Dist: pre-commit; extra == 'dev'
Requires-Dist: pytest-cov>=5; extra == 'dev'
Requires-Dist: pytest>=8; extra == 'dev'
Requires-Dist: ruff>=0.14; extra == 'dev'
Requires-Dist: twine; extra == 'dev'
Description-Content-Type: text/markdown

# herohealth

An unofficial Python client for the Hero Health HeroConnect cloud API. It is based on observed Android behavior and may break when the service changes. Python 3.12–3.14 are supported.

After the package is published, install it with `pip install herohealth`. Until
then, install from a local checkout with `python -m pip install .`.

Set `HERO_USERNAME` (or `HERO_EMAIL`) and `HERO_PASSWORD`, or `HERO_ACCESS_TOKEN` / `HERO_REFRESH_TOKEN`, in your environment. The client caches tokens at `~/.cache/herohealth/tokens.json`; pass `token_path=Path(...)` to choose a different location. Protect this file like a password. Set `HERO_ACCOUNT_ID` when accessing a specific account. A `.env` in the current working directory is also loaded; existing environment variables take precedence.

```python
from herohealth import HeroClient

with HeroClient() as hero:
    hero.login()
    print(hero.user.status())
    print(hero.home.doses())
```

```python
from herohealth import HeroClient

with HeroClient() as hero:
    print(hero.device.last_d2d_config())
    print(hero.meds.config_current())
```

The client supports the observed authentication and read operations illustrated above. Responses are passed through as received; their schemas are not guaranteed. Other endpoint wrappers are experimental research interfaces, and extracted endpoint names alone do not establish behavior or safety. Mutation methods can affect real medication schedules and devices. The `herohealth` command offers `login`, `whoami`, `home`, and other commands. Responses and `--summary` output may contain sensitive health data. Dispense defaults to preflight; a live start requires explicit confirmation. Never retry a dispense whose outcome is unknown without checking the device and account first. Dispense attempts sharing a token-cache directory are serialized, and an interrupted start remains blocked in the local journal. Use the same cache directory for all clients controlling an account; separate machines or directories cannot coordinate. Malformed dose data or contradictory preflight results are rejected rather than treated as eligible.

Requests time out after 60 seconds. Configured API, RTM, and OAuth origins must use HTTPS; cloud requests are restricted to configured origins and redirects are not followed. Login-page redirects are followed only within the configured OAuth origin, and credential submissions and token requests do not follow redirects. The high-level API methods raise `RateLimitError` on HTTP 429 and do not automatically retry; wait for `Retry-After` or, if absent or invalid, 15–60 minutes before further requests. The low-level `request()` method returns the raw response, so callers must check its status themselves. This is independent research and is not affiliated with Hero Health. See [research and protocol status](https://github.com/andrewtryder/py-herohealth/blob/main/docs/research/README.md), [contributing](https://github.com/andrewtryder/py-herohealth/blob/main/CONTRIBUTING.md), and the [changelog](https://github.com/andrewtryder/py-herohealth/blob/main/CHANGELOG.md).

Library-specific authentication and dispense errors inherit from `HeroError`; `RateLimitError` remains an `AuthError`. Other HTTP failures from the high-level helpers raise `httpx.HTTPStatusError`. The low-level `request()` returns a raw response without checking its status.
