Skip to content

Add farm season calendar with yr.no weather integration for Norwegian climate zones#21

Draft
Copilot wants to merge 8 commits intomainfrom
copilot/create-farm-season-calendar
Draft

Add farm season calendar with yr.no weather integration for Norwegian climate zones#21
Copilot wants to merge 8 commits intomainfrom
copilot/create-farm-season-calendar

Conversation

Copy link

Copilot AI commented Jan 24, 2026

Implements garden planning system with companion planting, crop rotation, succession planting, automated reminders, and real-time weather integration optimized for Norwegian climate zones 1-8.

Core Components

4 new doctypes:

  • Crop - Growing data (family, zones, planting/harvest windows, maturity days, frost tolerance, companions)
  • Garden Plot - Physical plot tracking (dimensions, soil type, pH, sun exposure, drainage)
  • Garden Planting Schedule - Seasonal planning with rotation history and email reminders
  • Garden Planting Item - Individual plantings with status tracking

10 API endpoints:

  • get_planting_calendar(zone, month) - Crops by zone/month with proper chronological month handling
  • get_companion_planting_suggestions(crop) - Good/bad companions with substring matching
  • get_crop_rotation_suggestions(plot, previous_crop) - Rotation by family to prevent disease
  • calculate_succession_planting(crop, start_date, end_date) - Multiple planting dates
  • generate_garden_shopping_list(schedule) - Seed/plant quantities
  • get_upcoming_garden_tasks(days_ahead) - Planting/harvest reminders
  • get_weather_forecast_for_location(lat, lon, days) - 7-day weather forecast from yr.no
  • get_frost_risk_for_location(lat, lon) - Frost risk alerts for crop protection
  • get_planting_weather_advice_for_location(lat, lon, crop) - Weather-based planting recommendations
  • get_weather_for_garden_plot(plot_name, days) - Automatic weather for garden plots

Scheduled task:

  • send_garden_reminders() - Daily email notifications with HTML-escaped content

Weather module (assist/utils/weather_yr.py):

  • Real-time data from Norwegian Meteorological Institute (yr.no)
  • 7-day forecasts with temperature, precipitation, wind, humidity
  • Frost detection with severity classification (light/hard)
  • Weather-based planting advice considering crop requirements
  • Crop-specific recommendations using frost tolerance data

Fixtures:

  • 12 Norwegian crops (Tomat, Gulrot, Potet, Salat, Kål, Erter, Løk, Agurk, Reddik, Jordbær, Basilikum, Squash)

Technical Details

Month comparison: Uses numeric indices instead of string comparison to handle chronological ordering and year-spanning seasons correctly.

Companion matching: Substring search allows partial crop name matches (e.g., "Tomat" matches "Tomat (Tomato)").

Security: HTML escaping via frappe.utils.html_escape() on all user inputs in email templates.

Harvest calculation: Automatic expected harvest dates using add_days(planting_date, days_to_maturity).

Validation: Warns on incompatible companion crops and cross-year planting windows.

Weather integration: Complies with yr.no API terms (User-Agent header), includes proper error handling, safe attribute access with getattr(), and comprehensive logging.

Example Usage

# Get crops for zone 3 in May
result = frappe.call(
    "assist.api.get_planting_calendar",
    norwegian_zone="3",
    month="May"
)

# Calculate succession planting for continuous harvest
schedule = frappe.call(
    "assist.api.calculate_succession_planting",
    crop_name="Salat (Lettuce)",
    start_date="2026-04-01",
    end_date="2026-07-31"
)
# Returns 8 planting dates spaced 14 days apart

# Check frost risk before planting
frost = frappe.call(
    "assist.api.get_frost_risk_for_location",
    latitude=59.9139,
    longitude=10.7522
)
# Returns frost alerts with severity classification

# Get weather-based planting advice
advice = frappe.call(
    "assist.api.get_planting_weather_advice_for_location",
    latitude=59.9139,
    longitude=10.7522,
    crop_name="Tomat (Tomato)"
)
# Returns: "Tomat (Tomato) is not frost-tolerant - wait until frost risk passes"

# Create schedule with automatic harvest dates
doc = frappe.get_doc({
    "doctype": "Garden Planting Schedule",
    "garden_plot": "Main Garden",
    "planting_items": [
        {
            "crop": "Tomat (Tomato)",
            "planting_date": "2026-05-15",
            # Expected harvest calculated automatically: 2026-07-24
        }
    ],
    "enable_email_reminders": 1
})

Testing

12 tests covering doctype structure, API methods, fixture data, companion planting integrity, zone validation, and weather integration functionality.

Original prompt

This section details on the original issue you should resolve

<issue_title>Farm season calendar for Norway </issue_title>
<issue_description>Maximize your harvest
Companion planting

The world's most advanced Evidence-Based Companion Planting system — suggests plants that grow best together at the click of a button

Crop rotation

Helps you avoid a build-up of soil-borne pests and diseases from year to year

Succession Planting

Make the most of your space, and see when and where you have space to grow more

Follow-on Plans

Create next year's plan from the previous year's plan with the click of a button

phone-img
graden-planer
Avoid wastage - Never buy too many or too few plants or seeds again
Get a shopping list showing exactly which plants to buy and how many you need
Save money and time by raising the right number of plants

  • track with email reminders when it’s time to plant, sow, and harvest each crop.
  • calendar and planting recommendations
  • garden layout
    </issue_description>

Comments on the Issue (you are @copilot in this section)


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI and others added 5 commits January 24, 2026 14:28
Co-authored-by: minfuel <106936397+minfuel@users.noreply.github.com>
Co-authored-by: minfuel <106936397+minfuel@users.noreply.github.com>
Co-authored-by: minfuel <106936397+minfuel@users.noreply.github.com>
…caping, and validation

Co-authored-by: minfuel <106936397+minfuel@users.noreply.github.com>
Co-authored-by: minfuel <106936397+minfuel@users.noreply.github.com>
Copilot AI changed the title [WIP] Add farm season calendar for Norway Add farm season calendar for Norwegian climate zones Jan 24, 2026
Copilot AI requested a review from minfuel January 24, 2026 14:40
@minfuel
Copy link
Contributor

minfuel commented Jan 24, 2026

@copilot WEATHER INFO FROM YR.NO

Co-authored-by: minfuel <106936397+minfuel@users.noreply.github.com>
Copy link
Author

Copilot AI commented Jan 24, 2026

@copilot WEATHER INFO FROM YR.NO

Implemented yr.no weather integration in commit d8a6e3e:

New weather module (assist/utils/weather_yr.py):

  • 7-day forecasts from Norwegian Meteorological Institute
  • Temperature, precipitation, wind, humidity data
  • Frost risk detection with severity classification
  • Weather-based planting advice

4 new API endpoints:

  • get_weather_forecast_for_location() - Get 7-day forecast
  • get_frost_risk_for_location() - Check frost alerts
  • get_planting_weather_advice_for_location() - Smart planting recommendations
  • get_weather_for_garden_plot() - Weather for your plots

Smart features:

  • Warns about frost risk for frost-sensitive crops
  • Alerts for heavy rain or drought conditions
  • Crop-specific advice based on temperature requirements
  • Integrates with crop frost tolerance and min temperature settings

Example: For tomatoes, it checks frost forecast and warns "Tomat (Tomato) is not frost-tolerant - wait until frost risk passes" when frost is detected.

Full documentation added to FARM_SEASON_CALENDAR.md with API examples.

…, better error handling

Co-authored-by: minfuel <106936397+minfuel@users.noreply.github.com>
Copilot AI changed the title Add farm season calendar for Norwegian climate zones Add farm season calendar with yr.no weather integration for Norwegian climate zones Jan 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Farm season calendar for Norway

2 participants