Skip to content

Fertigation implementation#386

Open
LuisMMMTS wants to merge 4 commits into
OpenSprinkler:masterfrom
LuisMMMTS:fertigation-implementation
Open

Fertigation implementation#386
LuisMMMTS wants to merge 4 commits into
OpenSprinkler:masterfrom
LuisMMMTS:fertigation-implementation

Conversation

@LuisMMMTS
Copy link
Copy Markdown

@LuisMMMTS LuisMMMTS commented Dec 24, 2025

Relates to issue #373
Define a station as fertilization valve

  • for each station define either % or time of fertilization
  • while master and station is running, fertilization valve is also open
  • center fertilization in the middle of station run so that its active when pipes are already full and also stops before master valve so that water can push the remainds of fertilizer out of the pipes

- Fixed program array format: fertigation at index 5, name at index 6, date range at index 7
- Updated all program name parsing to use correct index based on fertigation support
- Fixed date range enable flag parsing in OSApp.Dates functions
- Maintained backward compatibility with old firmware versions
- Fixed program name saving to use placeholder or calculated program number instead of 'Program New'
- Sync en_daterange field with flag byte bit 7 when reading programs from file
- Ensure en_daterange matches flag byte when endr parameter is not provided
- Clear date range values to defaults when date range is disabled
- Fixes issue where programs were not starting on schedule due to date range flag mismatch
@LuisMMMTS LuisMMMTS changed the title Fertigation implementation #373 Fertigation implementation Dec 24, 2025
- Skip fertigation station when scheduling stations from programs (like master stations)
- Skip fertigation station in manual_start_program function
- Skip fertigation station in runtime queue time-keeping loop
- Fertigation station can only run when triggered by stations with fertigation enabled
@LuisMMMTS
Copy link
Copy Markdown
Author

Is there anyone that can review this like @rayshobby or someone with privileges?

@rayshobby
Copy link
Copy Markdown
Member

Thanks for submitting this! This is a useful but specialized feature that addresses a specific use case.

Currently, our policy is to keep the core firmware focused on features we can fully support, understand, test, and document. Because this is a niche implementation, we are hesitant to merge it immediately as it would become a long-term maintenance liability for us.

For now, we're going to hold off on merging. If we see increased demand from other users for this specific functionality, we will revisit it. In the meantime, we’ll keep this PR open for those looking for this feature.

@LuisMMMTS
Copy link
Copy Markdown
Author

Thank you. Yes this probably is more for professional use. I have also made a pull request on the UI side, OpenSprinkler/OpenSprinkler-App#284 please add the same comment there in case someone comes looking for this later on.

- Replace FertigationConfig{enabled,mode,fert_sid,value}[] with a flat
  uint16_t fert_duration[] array (0 = disabled). Halves per-program fert
  storage and eliminates three fields that were set but never read.

- Fix uint16_t underflow: cap fert_dur <= station_dur before computing
  the centered delay to prevent wrap-around on unsigned subtraction.

- Fix concurrent-group race condition: collect fert_valve_needed across
  all stations before touching the hardware bit, so station B cannot
  close a valve that station A just opened in the same scheduler tick.

- Remove fragile manual-run program matching by duration (±5 s tolerance
  could match the wrong program). Run-once fertigation now flows through
  os.runonce_fert[], populated by /cr and cleared when the queue empties.

- Remove /pf endpoint (server_change_program_fert): it was dead code with
  no app caller and could silently corrupt stored fert values on round-trip.

- Move ProgramStruct prog declaration outside the inner station loop.

- Remove backward-compat validation loop in program.cpp (referenced the
  now-deleted struct fields).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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.

2 participants