Smart Irrigation for Home Assistant

repository·master·Indexed 19 days ago

https://github.com/altmenorg/hasmartirrigation

A Home Assistant integration that calculates irrigation durations to compensate for moisture loss due to evapotranspiration. It accounts for precipitation and weather forecasts across multiple configurable zones. The system provides tools for managing irrigation zones, modules, and weather data mappings, supporting services like OpenWeatherMap and Pirate Weather. It includes features for recurring schedules, seasonal adjustments, and automation triggers based on solar events (sunrise, sunset, or solar azimuth).

Tokens
18.9K
Snippets
31
Records
99
Agent score
60%

What's inside Smart Irrigation

  1. Overview of Smart Irrigation components in Home Assistant

    master

    After installing the Smart Irrigation integration, several entities and interfaces are automatically created in Home Assistant to facilitate irrigation management and automation:

    • Sidebar Panel: Used for configuring the integration settings.
    • Sensor Entities: One sensor entity is created for every configured irrigation zone.
    • Services: A set of services available for automating irrigation tasks.
    • Start Event: An event that triggers when irrigation is scheduled to finish before sunrise.
    • Automations: The combination of sensors, services, and events allows for custom automation logic.
    • Enhanced Scheduling: Support for advanced scheduling and integration with Irrigation Unlimited.
  2. Overview of Smart Irrigation

    master

    Smart Irrigation is a Home Assistant integration designed to calculate the precise duration required to run an irrigation system to compensate for moisture loss caused by evapotranspiration.

    Key Capabilities:

    • Moisture Compensation: Calculates irrigation needs based on evapotranspiration, precipitation (rain, snow), and weather forecasts.
    • Bucket Model: Tracks the total moisture lost or added over time (the 'bucket').
    • Multi-zone Support: Supports multiple irrigation zones, each with its own independent configuration.
    • Forecast Integration: Accounts for upcoming weather to adjust irrigation needs.

    Important Limitations:

    • No Hardware Control: This integration does not control your irrigation system. It only calculates the required durations. You must create Home Assistant automations to trigger your actual irrigation hardware based on the integration's calculations.
    • User Responsibility: Use this integration at your own risk. Always apply common sense (e.g., avoid irrigating during excessive rainfall to prevent flooding).
  3. How solar radiation affects ET calculation accuracy

    master

    The integration uses the PyETO module to compute ET via the FAO-56 Penman-Monteith equation. Solar radiation is the dominant term in this equation.

    • With Radiation Source: The system performs a full Penman-Monteith calculation. This is the most accurate method.
    • Without Radiation Source: The system automatically falls back to a Hargreaves-style approximation, estimating radiation from temperature. This is less precise, particularly in cloudy or coastal climates.

    Note: You do not manually toggle between these methods. The integration automatically uses radiation whenever a source provides it and estimates it otherwise.

  4. Configure zone state and calculation modes

    master

    A zone's State determines how its irrigation duration is managed:

    • Automatic: The integration automatically calculates irrigation duration. This mode requires a module and a sensor group to be configured.
    • Manual: You manually specify the irrigation duration. A module and sensor group are not required.
    • Disabled: The zone is inactive. The duration is set to 0 and no calculations are performed. Setting a module or sensor group is optional in this state.
  5. Configure Total Precipitation with Delta aggregation

    master

    To correctly track precipitation, use the Total precipitation metric.

    • Source: Use a sensor that accumulates precipitation over time (e.g., 'daily rain' or 'total rain').
    • Aggregation: Set the aggregation type to Delta. This allows the integration to handle value resets (e.g., when a daily rain sensor resets to zero at midnight).
    • Note: The value should represent a total amount over a time period, not a current precipitation rate.
  6. Backup and Restore Smart Irrigation configuration

    master
    The integration includes a dedicated Backup / Restore tab in the configuration UI. This allows you to export your entire configuration (including zones, sensor groups, modules, and weather settings) as a single JSON file, which can be used to restore the setup later.
  7. Configure the active start trigger

    master

    Smart Irrigation runs once per day based on a single active trigger selected in the General configuration. While you can define multiple triggers (e.g., sunset, solar azimuth, offsets), only the one designated as the 'active trigger' will initiate the daily irrigation run.

    • Default behavior: The default trigger is Default (sunrise minus total watering duration), which ensures the watering cycle finishes exactly at sunrise.
  8. Use experimental continuous updates

    master

    The Continuous updates feature is an experimental way to capture granular weather data to avoid missing weather patterns.

    Requirements for a zone to use continuous updates:

    1. The zone must be set to automatic.
    2. It must use a sensor group that does not rely on a weather service (none of the data sources can be set to weather service).
    3. It must not use forecasting. Set forecast days for PyETO to 0.

    Behavior:

    • Zones meeting these requirements are excluded from the standard automatic update/calculation cycle and instead use continuous updates.
    • Zones not meeting these requirements follow the standard automatic update and calculation schedule.
    • A sensor debounce setting is available to control the speed of continuous updates.

    Warning: This feature is experimental and may contain bugs.

  9. How the Smart Irrigation bucket model works

    master

    The integration uses a 'bucket' model to determine irrigation needs based on the balance between moisture added to the soil and moisture lost.

    The Calculation Logic

    1. Precipitation (P): Moisture added by rain or snow.
    2. Evapotranspiration (Et): Moisture lost due to sunshine, temperature, wind, and other factors.
    3. Nett Precipitation (D): The difference between precipitation and evapotranspiration (D = P - Et).
    4. Bucket Calculation: At a configurable time each day, the nett precipitation is applied to the current bucket value: new_bucket = old_bucket + D.
    5. Drainage: If the bucket value is greater than 0, a drainage rate (if configured) is subtracted from the bucket. The drainage rate is determined dynamically using the hydraulic conductivity method based on the bucket's fraction of its maximum value.
    6. Irrigation Trigger: Irrigation is required when the calculated bucket value falls below zero (bucket < 0).

    Irrigation Output

    • The sensor sensor.smart_irrigation_[zone_name] provides the irrigation duration in seconds.
    • If bucket >= 0, the duration is 0.
    • If bucket < 0, the duration is the number of seconds required to replenish the moisture.
  10. Use enhanced scheduling features and services

    master

    Advanced scheduling features are managed via Home Assistant services and blueprints rather than the main configuration UI. These include:

    • Recurring schedules: Create daily, weekly, monthly, or interval-based schedules using the smart_irrigation.create_recurring_schedule service.
    • Seasonal adjustments: Automatically adjust irrigation parameters based on the current season.
    • Irrigation Unlimited integration: Bidirectional support for the Irrigation Unlimited component.
    • Automation blueprints: Ready-to-use templates located in the blueprints/ directory.
  11. Configure weather services in Smart Irrigation

    master
    You can switch between weather services (OpenWeatherMap and Pirate Weather) and update API keys directly within the integration's configuration UI without needing to remove and re-add the integration. This allows for seamless transitions between providers.
  12. Understand the Smart Irrigation sensor entity structure

    master

    Each configured zone is added to Home Assistant as a sensor entity following the naming convention: sensor.smart_irrigation_[zone_name]. For example, a zone named lawn results in sensor.smart_irrigation_lawn.

    These sensor entities contain the following attributes:

    AttributeDescription
    idinternal identification
    sizethe total area the irrigation system reaches in m² or sq ft.
    throughputtotal amount of water that flows through the irrigation system in liters or gallon per minute.
    statedisabled, manual, or automatic
    bucketthe bucket size in mm or inch
    unit_of_measurementseconds
    device_classduration
    icondefault: mdi:sprinkler
    friendly_nameName of your zone.

    If you need to expose these attributes as standalone sensors, you can use Home Assistant template sensors.

    {# Example template to extract the bucket attribute #}
    {{ state_attr('sensor.smart_irrigation_your_zone_sensor_name', 'bucket') }}