Make alert cooldown configurable and increase default to 15 minutes#41
Make alert cooldown configurable and increase default to 15 minutes#41fakebizprez wants to merge 1 commit intomasterfrom
Conversation
|
Skipped: This PR does not contain any of your configured labels: ( |
WalkthroughThe PR introduces a configurable alert cooldown mechanism by adding an Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@README.md`:
- Line 105: Update the README text that still says "5-minute cooldown between
same alert type" to reflect the actual default of 15 minutes (900 seconds) or
make it reference the ALERT_COOLDOWN_SECONDS variable; locate the sentence in
the README that mentions the 5-minute cooldown and change it to either
"15-minute cooldown (ALERT_COOLDOWN_SECONDS = 900 seconds)" or a phrasing that
points readers to the ALERT_COOLDOWN_SECONDS configuration value so the docs
match the code.
🧹 Nitpick comments (1)
temp_monitor.py (1)
559-560: Consider passingalert_cooldownwhen dynamically creatingWebhookService.When a
WebhookServiceis created dynamically via the PUT/api/webhook/configendpoint (line 560), thealert_cooldownparameter is not passed, so it defaults to 900 seconds. This differs from the initial service creation (lines 126-130) which respectsALERT_COOLDOWN_SECONDS.If the intent is for all webhook services to honor the environment variable, consider storing
alert_cooldown_secondsat module level and passing it here as well.Suggested approach
# Initialize webhook service webhook_service = None +alert_cooldown_seconds = int(os.getenv('ALERT_COOLDOWN_SECONDS', '900')) slack_webhook_url = os.getenv('SLACK_WEBHOOK_URL') if slack_webhook_url: webhook_config = WebhookConfig( ... ) - alert_cooldown_seconds = int(os.getenv('ALERT_COOLDOWN_SECONDS', '900')) ...Then at line 560:
if not webhook_service: - webhook_service = WebhookService() + webhook_service = WebhookService(alert_cooldown=alert_cooldown_seconds)And similarly at line 583.
| | `ALERT_TEMP_MAX_C` | `32.0` | High temperature alert (Celsius) | | ||
| | `ALERT_HUMIDITY_MIN` | `20.0` | Low humidity alert (%) | | ||
| | `ALERT_HUMIDITY_MAX` | `70.0` | High humidity alert (%) | | ||
| | `ALERT_COOLDOWN_SECONDS` | `900` | Minimum time between repeating the same alert type | |
There was a problem hiding this comment.
Documentation inconsistency with existing text.
Line 198 still states "5-minute cooldown between same alert type" but the new default is 15 minutes (900 seconds). Consider updating line 198 to reflect the new configurable default or reference the ALERT_COOLDOWN_SECONDS variable.
Suggested fix for line 198
-- **Alert Cooldown**: 5-minute cooldown between same alert type (prevents spam)
+- **Alert Cooldown**: Configurable cooldown between same alert type (default: 15 minutes, see `ALERT_COOLDOWN_SECONDS`)🤖 Prompt for AI Agents
In `@README.md` at line 105, Update the README text that still says "5-minute
cooldown between same alert type" to reflect the actual default of 15 minutes
(900 seconds) or make it reference the ALERT_COOLDOWN_SECONDS variable; locate
the sentence in the README that mentions the 5-minute cooldown and change it to
either "15-minute cooldown (ALERT_COOLDOWN_SECONDS = 900 seconds)" or a phrasing
that points readers to the ALERT_COOLDOWN_SECONDS configuration value so the
docs match the code.
Motivation
Description
alert_cooldownparameter toWebhookService.__init__and increased the default cooldown from 300s to 900s (15 minutes) when not provided.ALERT_COOLDOWN_SECONDSenvironment variable into startup intemp_monitor.pyand pass it toWebhookServicevia thealert_cooldownargument.ALERT_COOLDOWN_SECONDSvariable in.env.exampleandREADME.mdand updated the defaults accordingly.Testing
test_webhook.pyand can be run withpython test_webhook.pyto validate behavior.Codex Task
Summary by CodeRabbit
Release Notes
New Features
ALERT_COOLDOWN_SECONDSenvironment variable, allowing customization of the minimum time between repeated identical alerts.Documentation
Changes
✏️ Tip: You can customize this high-level summary in your review settings.