Skip to content

Fix plugin loading error and improve code consistency - #1

Open
MiroStW wants to merge 9 commits into
SyButter:mainfrom
MiroStW:main
Open

Fix plugin loading error and improve code consistency#1
MiroStW wants to merge 9 commits into
SyButter:mainfrom
MiroStW:main

Conversation

@MiroStW

@MiroStW MiroStW commented Oct 19, 2025

Copy link
Copy Markdown

Summary

This PR fixes a critical bug that prevented the plugin from loading and improves code consistency with other DE1 plugins. It also renames the plugin to follow naming conventions used by established plugins.

Problem

The plugin was failing to load with the error:

can't read "::plugins::de1_water_tracker_plugin::version": no such variable

Photo from Google Photos (7)

Changes

1. Fix: Remove duplicate plugin_name variable declaration

The duplicate variable plugin_name inside the namespace was causing namespace resolution issues during plugin initialization. The plugin system uses the directory name to create the namespace, making this internal variable declaration redundant and problematic.

2. Refactor: Simplify save_plugin_settings calls

Replace namespace variable references with string literals, matching the pattern used by established plugins like advanced_rest_api. This makes the code more maintainable and consistent with DE1 plugin conventions.

3. Refactor: Rename plugin to de1_water_tracker

Remove the _plugin suffix to follow naming conventions used by other established plugins (e.g., advanced_rest_api, mqtt, visualizer_upload).

⚠️ Breaking Change: The plugin directory should be renamed from de1_water_tracker_plugin to de1_water_tracker. Users will need to:

  1. Disable and uninstall the old de1_water_tracker_plugin
  2. Install the renamed de1_water_tracker plugin

Testing

✅ Tested on DE1 production environment
✅ Plugin now loads successfully and appears correctly in the Extensions list
✅ All plugin functionality working as expected
✅ Directory rename tested and working

Reference

Code pattern comparison with working plugin advanced_rest_api confirmed the best practices used in this fix.

Miro Wilms added 5 commits October 19, 2025 21:37
The duplicate 'variable plugin_name' inside the namespace was causing
namespace resolution issues during plugin initialization. The plugin
system uses the directory name to create the namespace, making this
internal variable declaration redundant and problematic.

This fixes the 'can't read ::plugins::de1_water_tracker_plugin::version'
error that prevented the plugin from loading.
Replace namespace variable references with string literals for
save_plugin_settings calls, matching the pattern used by other
established plugins like advanced_rest_api.

This makes the code more maintainable and consistent with DE1 plugin
conventions.
Remove '_plugin' suffix from plugin name to follow naming conventions
used by other established plugins (e.g., advanced_rest_api, mqtt).

The directory should also be renamed from de1_water_tracker_plugin
to de1_water_tracker when installing.

This is a breaking change - users will need to:
1. Disable and remove the old de1_water_tracker_plugin
2. Install the renamed de1_water_tracker plugin
Implements the TODO item to notify users when a water usage threshold is reached.

Features:
- New setting for filter change reminder threshold (in L or gal)
- Automatic notification popup when threshold is reached
- Threshold respects current unit selection (L/gallons)
- Notification flag resets when threshold is changed
- UI input field with auto-conversion based on selected units
- Done button saves threshold before closing settings

The notification flag is reset when:
- Counter is reset (allows notification for next cycle)
- Threshold value is changed (allows notification at new threshold)

Closes: TODO item 'Add a ping to let you know when a set total L/gal
has been reached for filter change'

Version bumped to 0.2

Tested and verified working:
- UI properly spaced to avoid overlapping elements
- Threshold saves correctly when Done button is clicked
- Notification shows at correct threshold
- Notification can be triggered again after changing threshold
- Add dedicated water_filter_warning page with dismiss button
- Warning page displays once per filter cycle (until reset/threshold change)
- More prominent and impossible to miss compared to popup
- Follows DE1 conventions for message pages
- Universal across all skins
@MiroStW

MiroStW commented Oct 22, 2025

Copy link
Copy Markdown
Author

Update: Now includes filter notification feature

This PR has been updated to include all features from PR #2 (filter change reminder notifications) with recent improvements based on maintainer feedback.

Complete Feature Set

This PR now includes:

Bug Fixes (original):

  • ✅ Fix plugin loading error
  • ✅ Improve code consistency
  • ✅ Rename plugin to follow conventions

New Feature (added):

  • ✅ Filter change reminder with configurable threshold
  • ✅ Custom warning page (improved from popup based on maintainer feedback)
  • ✅ Unit conversion (L/gallons)
  • ✅ Smart notification management (shows once per cycle)

The notification system now uses a dedicated warning page that requires user acknowledgment, making it impossible to miss - much better than the popup that quickly fades away.

Note: PR #2 can be considered as a preview/testing branch for the notification feature, while this PR (main branch) represents the complete, production-ready plugin.

Miro Wilms added 4 commits December 10, 2025 12:55
- Implemented 2-column layout for better space utilization
- Left column: volume display and filter reminder settings
- Right column: filter date and reset button
- All elements left-aligned within their columns
- Improved spacing between elements
- Fixed Reset Counter button visibility
- Changed plugin name from de1_water_tracker to ro_filter_monitor
- Updated display name from 'Water Usage Tracker' to 'RO Filter Monitor'
- Updated all namespace references
- Updated description to mention RO filters specifically
- Renamed all page names and settings references
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.

1 participant