- WARNING: upgrading from V1 (V0.0.X) to V2 (V2023.X.X)? Read the instructions below!
Stop what you're doing and capture your V1 configuration before installing V2. V2 is a complete overhaul of this integration and there is no upgrade path. This means that effectively you will have to start over. See the docs for instructions. We will not be able to recover your V1 configuration if you don't capture it before installing V2. |
This integration calculates the time to run your irrigation system to compensate for moisture loss by evapotranspiration. Using this integration you water your garden, lawn or crops precisely enough to compensate what has evaporated. It takes into account precipitation (rain, snow) and moisture loss caused by evapotranspiration and adjusts accordingly. If it rains or snows less than the amount of moisture lost, then irrigation is required. Otherwise, no irrigation is required. The integration can take into account weather forecasts for the coming days and also keeps track of the total moisture lost or added ('bucket') Multiple zones are supported with each zone having it own configuration and set up.
For contributors and developers:
# Clone and setup development environment
git clone <repository-url>
cd HAsmartirrigation
make setup
make help # Show all available commands
make test # Run all tests
make test-knmi # Test KNMI integration
make format # Format code
make lint # Run linting
To run the tests for this Smart Irrigation custom component:
- Install test requirements:
pip install -r requirements.test.txt
Run all tests:
pytest
Run specific test directories:
# Tests in the main tests/ directory
pytest tests/
# Tests in the custom component
pytest custom_components/smart_irrigation/tests/
Run specific test files:
pytest tests/test_services.py
pytest custom_components/smart_irrigation/tests/test_init.py
The project has two test directories:
tests/
- Integration tests and component behavior testscustom_components/smart_irrigation/tests/
- Unit tests for the custom component
If you encounter issues:
-
Missing Home Assistant objects: The test infrastructure includes mocks for Home Assistant core objects like
hass.config
andhass.data
. If you get AttributeErrors, ensure the fixtures are properly imported. -
Import errors: Make sure you're running tests from the repository root directory. The test configuration automatically adds the necessary paths.
-
Module not found errors: Ensure all test dependencies are installed:
pip install -r requirements.test.txt
-
Async/await issues: Tests use pytest-asyncio. Make sure async test functions are properly marked and fixtures are compatible.
Some test files reference modules that don't exist in the current codebase (e.g., core.zone
, core.updater
). These have been disabled with .disabled
extensions until the corresponding functionality is implemented or the tests are updated.
See CONTRIBUTING.md for detailed development instructions.