feat(automations): self-rearming holiday mode (delay/duration on enable tools) - #39
Conversation
… — self-rearming holiday mode 'Disable for two weeks' now self-rearms: both enable tools accept the IOM's optional delay/duration (seconds until the entity flips back to its prior state), reusing the shared validator from the device tools. Closes #37. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01EYAGXd4bE9D9Z5kZeSHeo7
📝 WalkthroughWalkthroughThe automation enable tools now accept optional non-negative ChangesAutomation enable options
Estimated code review effort: 2 (Simple) | ~10 minutes Sequence Diagram(s)sequenceDiagram
participant Tool
participant EnableHandler
participant IndigoAPI
Tool->>EnableHandler: id, enabled, delay, duration
EnableHandler->>IndigoAPI: trigger.enable or schedule.enable with timing options
IndigoAPI-->>EnableHandler: enable result
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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.
🧹 Nitpick comments (1)
tests/test_automations.py (1)
153-157: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winCover negative
delayvalidation too.The new contract validates both optional fields, but this test exercises only
duration. Add an analogous negative-delaycase and assert thattrigger.enableis not called.Suggested test
+def test_enable_rejects_negative_delay(mock_indigo): + mock_indigo.triggers.__getitem__.side_effect = lambda i: _fake_trigger(5, "T") + with pytest.raises(ValueError, match="delay"): + _trigger_enable_handler( + {"id": 5, "enabled": True, "delay": -1}, mock_indigo) + mock_indigo.trigger.enable.assert_not_called()🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@tests/test_automations.py` around lines 153 - 157, Add a negative-delay test alongside test_enable_rejects_negative_duration, invoking _schedule_enable_handler with a negative delay and asserting ValueError. Also verify mock_indigo.trigger.enable is not called when validation rejects the input.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@tests/test_automations.py`:
- Around line 153-157: Add a negative-delay test alongside
test_enable_rejects_negative_duration, invoking _schedule_enable_handler with a
negative delay and asserting ValueError. Also verify mock_indigo.trigger.enable
is not called when validation rejects the input.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: d8b4f178-ad91-4cff-87c3-ea9ffd0436d6
📒 Files selected for processing (4)
Indigo MCP Lite.indigoPlugin/Contents/Info.plistIndigo MCP Lite.indigoPlugin/Contents/Server Plugin/tools/automations.pypyproject.tomltests/test_automations.py
Closes #37.
trigger_enableandschedule_enablenow accept the IOM's optionaldelay/duration— 'disarm the morning schedule for two weeks' self-rearms with no follow-up ask. Shared validator from the device tools; unknown-arg guard updated. 364 tests (2 new). 2026.7.0 → 2026.7.1.🤖 Generated with Claude Code
https://claude.ai/code/session_01EYAGXd4bE9D9Z5kZeSHeo7
Summary by CodeRabbit
New Features
Bug Fixes
Chores
Tests