Create status json for use by the panel control plugin.#2652
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
WalkthroughThe monitor script now conditionally generates a JSON payload containing disk and device monitor events and aggregated per-target health states for PanelControl integration. It provides helper functions to check enablement and rank event severity, constructs events from disk status, temperatures, and health checks, and persists the payload to a state file with change-detection logic. ChangesPanelControl Monitor Payload Generation
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
🔧 PR Test Plugin AvailableA test plugin has been generated for this PR that includes the modified files. Version: 📥 Installation Instructions:Install via Unraid Web UI:
Alternative: Direct Download
|
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 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.
Inline comments:
In `@emhttp/plugins/dynamix/scripts/monitor`:
- Around line 45-47: The function panelcontrol_monitor_has_show_flag currently
always returns true; replace that hardcoded return with a real
feature-flag/config lookup (e.g., read the PanelControl plugin setting key such
as "enabled" or "panelcontrol_enabled" from the plugin configuration or system
feature flags via the existing config-API helper used elsewhere in this script)
and return its boolean value (with a safe default of false if the key is missing
or parsing fails); apply the same change to the duplicate occurrence referenced
around the other location so payload generation only runs when the actual config
flag is enabled.
- Around line 576-579: The current write-then-rename sequence writes JSON to
$tmpPath and calls `@rename`($tmpPath, $payloadPath) but ignores rename()'s return
value, leaving a stale $tmpPath (payloadPath . '.tmp') if rename fails; update
the block around the write to check the boolean result of rename($tmpPath,
$payloadPath) and on failure attempt a safe fallback: write the payloadJson
directly to $payloadPath (e.g., with file_put_contents and LOCK_EX), and then
remove the $tmpPath (unlink) to avoid leaving the .tmp file; ensure errors are
suppressed/handled similarly to the surrounding code and reference the variables
$tmpPath, $payloadPath, rename(), file_put_contents(), and unlink() when
editing.
- Around line 572-574: Check the result of json_encode($payload,
JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES) before appending "\n" and before
comparing/writing to $payloadPath: if json_encode returns false, log or report
the encoding error (include json_last_error_msg()), do not overwrite
panelcontrol-monitor-payload.json, and skip the file_put_contents path; ensure
subsequent logic uses $existingPayloadJson unchanged. Target the $payloadJson
variable and the json_encode(...) call and guard the comparison against
$existingPayloadJson so invalid JSON is never written to $payloadPath.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: 826870c2-29d4-49f1-a06e-76d8c5458ef8
📒 Files selected for processing (1)
emhttp/plugins/dynamix/scripts/monitor
|
Actionable comments posted: 0 |
This change creates a new json in the state directory.
This is to add support for controlling LEDs and LCD panels for devices like LincStation N1/N2 initially with others to follow like S1 and Ugreen.
Summary by CodeRabbit