Skip to content

feat: pH/EC Regulation v2 — Telegram, daily dose limits, water level safety lock - #29

Draft
m0nk1111 wants to merge 1 commit into
masterfrom
feature/regulate-ph-ec-v2
Draft

feat: pH/EC Regulation v2 — Telegram, daily dose limits, water level safety lock#29
m0nk1111 wants to merge 1 commit into
masterfrom
feature/regulate-ph-ec-v2

Conversation

@m0nk1111

Copy link
Copy Markdown
Collaborator

Summary

Enhanced pH/EC regulation function that replaces/supplements the built-in regulate_ph_ec.py. Designed for hydroponic and aquaponic setups where reliability and safety are critical.

What's New vs Built-in

Feature Built-in regulate_ph_ec This v2
pH regulation (raise/lower)
EC regulation (raise/lower) ✅ (2 pumps) ✅ (up to 4 pumps A-D)
Daily dose limits (ml/day) ✅ with midnight reset
Water level safety lock ✅ blocks dosing when dry
Telegram notifications ✅ danger alerts + stale data
In-band dose halving ✅ gentle convergence
InfluxDB dose logging (ml) ✅ channels 0/1/2 for graphs
Sensor sanity checks ✅ stale + flatline detection
Per-pump ml/min calibration ✅ accurate ml calculation
Persistent status widget function_status_always()
Daily + all-time counters ✅ persisted across restarts
Countdown timer in status

Key Design Decisions

  • Non-breaking: Added as a new function (regulate_ph_ec_v2), does not modify the existing regulate_ph_ec.py
  • All options configurable: No hardcoded values — setpoints, limits, pump IDs, Telegram credentials all via custom_options
  • Graceful degradation: Telegram is optional (just leave token empty), water level sensor is optional, EC pumps C/D are optional
  • Daily limits prevent runaway dosing: If sensors malfunction and report permanently low values, the daily ml cap prevents overdosing
  • In-band halving: When pH/EC is within the regulation band but on the wrong side of setpoint, dose is halved for smooth convergence instead of aggressive correction

Testing

Tested on a production Raspberry Pi 4B running Mycodo v8.16.2 with:

  • DFRobot pH + EC sensors via ADS1115
  • 8× peristaltic dosing pumps (HW-283 relay module)
  • YF-S401 flow sensor
  • XKC-Y25-NPN water level sensors
  • Running 24/7 for 4 weeks managing a single-plant hydroponic NFT system

Target

This PR is on the fork for review. Intended for upstream submission to kizniche/Mycodo once validated.

Checklist

  • No hardcoded UUIDs or installation-specific values
  • All strings in English
  • GPL-3.0 license header
  • Uses lazy_gettext for translatable option labels
  • Valid Python syntax
  • Follows Mycodo custom function conventions
  • Unit tests (to be added before upstream PR)

…locks

Improved version of the built-in regulate_ph_ec function with:
- Telegram notifications for danger ranges and missing measurements
- Daily dose limits (ml/day) with automatic midnight reset
- Water level safety lock (blocks dosing when reservoir is dry)
- Up to 4 EC nutrient pumps (A-D) instead of just raise/lower
- In-band dose halving for gentle convergence to setpoint
- InfluxDB dose logging (ml per event) for dashboard graphs
- Sensor sanity checks (stale readings, flatline detection)
- Persistent function_status_always() for dashboard widget
- Per-pump calibration (ml/min) for accurate dose calculation
- Countdown timer in status display
- All-time and daily dose tracking with persistence
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.

3 participants