|
| 1 | +# Contributing to ha-light-controller |
| 2 | + |
| 3 | +Thank you for your interest in contributing! This document provides guidelines |
| 4 | +and information for contributors. |
| 5 | + |
| 6 | +## Getting Started |
| 7 | + |
| 8 | +1. Fork the repository |
| 9 | +2. Clone your fork: `git clone https://github.com/YOUR_USERNAME/ha-light-controller.git` |
| 10 | +3. Create a feature branch: `git checkout -b feature/your-feature-name` |
| 11 | +4. Make your changes |
| 12 | +5. Push to your fork: `git push origin feature/your-feature-name` |
| 13 | +6. Open a Pull Request against the `main` branch |
| 14 | + |
| 15 | +## Development Setup |
| 16 | + |
| 17 | +### Prerequisites |
| 18 | + |
| 19 | +- Python 3.13+ |
| 20 | +- [UV](https://docs.astral.sh/uv/) package manager |
| 21 | + |
| 22 | +### Install UV |
| 23 | + |
| 24 | +```bash |
| 25 | +curl -LsSf https://astral.sh/uv/install.sh | sh |
| 26 | +``` |
| 27 | + |
| 28 | +### Set up the project |
| 29 | + |
| 30 | +```bash |
| 31 | +git clone https://github.com/L3DigitalNet/ha-light-controller.git |
| 32 | +cd ha-light-controller |
| 33 | +make setup # Creates venv and installs dependencies |
| 34 | +source .venv/bin/activate |
| 35 | +``` |
| 36 | + |
| 37 | +### Run tests |
| 38 | + |
| 39 | +```bash |
| 40 | +make test # Run all tests |
| 41 | +make test-cov # Run tests with coverage report |
| 42 | +pytest tests/test_controller.py # Run a specific test file |
| 43 | +``` |
| 44 | + |
| 45 | +Tests mock the `homeassistant` module — no running Home Assistant instance is needed. |
| 46 | + |
| 47 | +### Quality checks |
| 48 | + |
| 49 | +```bash |
| 50 | +make lint # Ruff linter |
| 51 | +make lint-fix # Lint with auto-fix |
| 52 | +make format # Ruff formatter |
| 53 | +make type-check # mypy type checker |
| 54 | +make quality # All checks at once |
| 55 | +make ci # Full CI simulation |
| 56 | +``` |
| 57 | + |
| 58 | +## Pull Request Guidelines |
| 59 | + |
| 60 | +- **One concern per PR.** Keep changes focused and reviewable. |
| 61 | +- **Write descriptive commit messages.** Explain *what* changed and *why*. |
| 62 | +- **Update CHANGELOG.md** for all non-trivial changes. |
| 63 | +- **Add tests** for new functionality. |
| 64 | +- **Ensure all checks pass** before requesting review: `make ci` |
| 65 | + |
| 66 | +## Home Assistant Constraints |
| 67 | + |
| 68 | +This is a Home Assistant integration. All contributions must follow HA's async requirements: |
| 69 | + |
| 70 | +- **Never use blocking I/O** — no `time.sleep()`, sync `requests`, or blocking file operations |
| 71 | +- **All I/O must be async** — use `await`, or `hass.async_add_executor_job()` for unavoidable sync calls |
| 72 | +- **Use HA APIs** — `hass.services.async_call`, `hass.states.get`, etc. Never bypass the state machine |
| 73 | + |
| 74 | +## Code Style |
| 75 | + |
| 76 | +This project uses [Ruff](https://docs.astral.sh/ruff/) for linting and formatting, and [mypy](https://mypy.readthedocs.io/) for type checking. |
| 77 | + |
| 78 | +- Run `make format` to auto-format code |
| 79 | +- Run `make lint` to check for issues (or `make lint-fix` to auto-fix) |
| 80 | +- Run `make type-check` to verify types — all new code must pass with 0 errors |
| 81 | +- Use modern Python type hints (`list[str]`, `X | None` — not `List`, `Optional`) |
| 82 | +- Prefer flat over nested — if nesting exceeds 3 levels, extract a helper |
| 83 | + |
| 84 | +## Reporting Issues |
| 85 | + |
| 86 | +- Use the [issue tracker](https://github.com/L3DigitalNet/ha-light-controller/issues) to report bugs |
| 87 | +- Check existing issues before creating a new one |
| 88 | +- Use the issue templates when available |
| 89 | +- Include steps to reproduce for bug reports |
| 90 | + |
| 91 | +## Security Issues |
| 92 | + |
| 93 | +Please do **not** open public issues for security vulnerabilities. See [SECURITY.md](SECURITY.md) for responsible disclosure instructions. |
| 94 | + |
| 95 | +## License |
| 96 | + |
| 97 | +By contributing, you agree that your contributions will be licensed under the same [MIT License](LICENSE) as the project. |
| 98 | + |
| 99 | +## Questions? |
| 100 | + |
| 101 | +Feel free to open a [GitHub Discussion](https://github.com/L3DigitalNet/ha-light-controller/discussions) or an issue if you have questions about contributing. |
0 commit comments