Metadata-Version: 2.4
Name: comfort-advisor
Version: 0.1.1
Summary: Psychrometric comfort evaluation and natural ventilation advice
Author: Lyman Epp
License-Expression: AGPL-3.0-or-later
Project-URL: Repository, https://github.com/lymanepp/comfort-advisor
Project-URL: Issues, https://github.com/lymanepp/comfort-advisor/issues
Project-URL: Upstream, https://github.com/lymanepp/ha-comfort-advisor
Keywords: hvac,ventilation,comfort,psychrometrics,weather
Classifier: Development Status :: 4 - Beta
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 :: Scientific/Engineering
Requires-Python: >=3.11
Description-Content-Type: text/markdown
License-File: LICENSE.md
Provides-Extra: dev
Requires-Dist: pytest>=8; extra == "dev"
Requires-Dist: build>=1.2; extra == "dev"
Requires-Dist: twine>=6; extra == "dev"
Dynamic: license-file

# Comfort Advisor

A dependency-free Python library for psychrometric comfort evaluation and natural ventilation advice, extracted from [Home Assistant Comfort Advisor](https://github.com/lymanepp/ha-comfort-advisor). No Home Assistant installation is required. The initial release preserves the existing algorithm; adaptive indoor prediction is future work.

## Installation

```sh
pip install comfort-advisor
```

## Example

```python
from datetime import UTC, datetime, timedelta
from comfort_advisor import ComfortCalculator, Input, Calculated, US_CUSTOMARY_SYSTEM

now = datetime.now(UTC)
calculator = ComfortCalculator(US_CUSTOMARY_SYSTEM, {
    "temperature_unit": "°F",
    "simmer_index_min": 70,
    "simmer_index_max": 85,
    "dew_point_max": 60,
    "humidity_max": 95,
    "pollen_max": 2,
}, clock=lambda: now)
calculator.set_input(Input.INDOOR_TEMPERATURE, 77)
calculator.set_input(Input.INDOOR_HUMIDITY, 50)
calculator.set_input(Input.OUTDOOR_TEMPERATURE, 70)
calculator.set_input(Input.OUTDOOR_HUMIDITY, 50)
calculator.set_input(Input.FORECAST, [
    {"datetime": (now + timedelta(hours=i)).isoformat(),
     "temperature": 70 + i, "humidity": 50}
    for i in range(1, 25)
])
calculator.recalculate()
print(calculator.get_calculated(Calculated.CAN_OPEN_WINDOWS))
print(calculator.extra_attributes)
print(calculator.get_calculated(Calculated.CLOSE_WINDOWS_AT))
```

## API

Use `METRIC_SYSTEM` for Celsius or `US_CUSTOMARY_SYSTEM` for Fahrenheit. Configuration temperatures are expressed in the declared `temperature_unit`; observations and forecasts use the selected unit system. Humidity is a percentage; enthalpy is kJ/kg dry air. Forecasts must be chronological, with timezone-aware ISO timestamps, temperature and humidity, and optional dew point. Supply current observations independently from forecast entries. The optional `clock` callable returns an aware datetime and can be advanced in replay tests; the default clock uses UTC.

Call `set_input` with `None` to mark a required input unavailable. `recalculate()` returns whether outputs have been refreshed or cleared; `available` indicates usable calculated outputs. `expires_at` identifies the next forecast boundary at which callers should refresh. `get_calculated()` accepts `Calculated` values; `extra_attributes` includes the advice reason. `update_pollen()` accepts a normalized level 0–5 or None. `pollen_level()` converts common named levels or IQVIA values. The caller owns scheduling, state subscriptions, persistence and actions. The library never controls equipment.

Optional configuration keys: `cooling_temperature_min` (default 60°F), `temperature_tolerance` (2°F difference), `hysteresis` (1°F difference), `humidity_hysteresis` (2 percentage points). Defaults convert to the selected unit. The initial algorithm uses previous advice for hysteresis, not actual contact sensor state, and compares forecast hours with current indoor conditions.

The `comfort_advisor.formulas` module exposes the original psychrometric functions, including saturation pressure, dew point, relative humidity, summer simmer index and moist-air enthalpy. See function docstrings for units.

## Development and release

```sh
python -m venv .venv
source .venv/bin/activate
python -m pip install -e '.[dev]'
python -m pytest
python -m build
python -m twine check dist/*
```

See [RELEASING.md](RELEASING.md) for GitHub and PyPI setup. The library retains the upstream AGPL-3.0-or-later license; consumers must evaluate compatibility before distribution. No license change is implied by extraction.
