Skip to content

feat: Add JSON file persistence and simplify tank alert system#16

Merged
StuartF303 merged 3 commits intomainfrom
claude/camper-van-control-setup-011CUpsFKnx2JFyoEDjhfgbz
Nov 9, 2025
Merged

feat: Add JSON file persistence and simplify tank alert system#16
StuartF303 merged 3 commits intomainfrom
claude/camper-van-control-setup-011CUpsFKnx2JFyoEDjhfgbz

Conversation

@StuartF303
Copy link
Copy Markdown
Owner

Backend Persistence:

  • Add JsonFileStore service for local JSON file-based data persistence
  • Store tanks, controls, and configuration in individual JSON files in /data directory
  • Auto-load persisted data on startup with fallback to defaults
  • Thread-safe concurrent operations with SemaphoreSlim
  • Tanks saved to tanks.json, controls to controls.json

Tank Alert System Improvements:

  • Replace LowLevelThreshold and HighLevelThreshold with single AlertLevel field
  • Add AlertWhenOver boolean to configure alert direction:
    • false = alert when UNDER threshold (tank running empty) - for fresh water, LPG, fuel
    • true = alert when OVER threshold (tank getting full) - for waste water
  • Update default tanks with appropriate alert configurations:
    • Fresh Water: Alert at 20% when under (running empty)
    • Waste Water: Alert at 80% when over (getting full)
    • LPG: Alert at 20% when under (running empty)
  • Remove global tank thresholds from SystemConfiguration.AlertSettings
  • Alert levels now configured per-tank in Tanks page

UI Updates:

  • Tanks.razor: Add alert level slider and "Alert When Over/Under" toggle with visual feedback
  • Index.razor: Update tank color indicators to use new alert system
  • Settings.razor: Remove global threshold fields, add note about per-tank configuration
  • Improved alert messages with actual percentage values
  • Dynamic alert severity based on criticality (Warning vs Error)

All data persists to JSON files and survives application restarts. Data location: {AppContext.BaseDirectory}/data/

Backend Persistence:
- Add JsonFileStore service for local JSON file-based data persistence
- Store tanks, controls, and configuration in individual JSON files in /data directory
- Auto-load persisted data on startup with fallback to defaults
- Thread-safe concurrent operations with SemaphoreSlim
- Tanks saved to tanks.json, controls to controls.json

Tank Alert System Improvements:
- Replace LowLevelThreshold and HighLevelThreshold with single AlertLevel field
- Add AlertWhenOver boolean to configure alert direction:
  * false = alert when UNDER threshold (tank running empty) - for fresh water, LPG, fuel
  * true = alert when OVER threshold (tank getting full) - for waste water
- Update default tanks with appropriate alert configurations:
  * Fresh Water: Alert at 20% when under (running empty)
  * Waste Water: Alert at 80% when over (getting full)
  * LPG: Alert at 20% when under (running empty)
- Remove global tank thresholds from SystemConfiguration.AlertSettings
- Alert levels now configured per-tank in Tanks page

UI Updates:
- Tanks.razor: Add alert level slider and "Alert When Over/Under" toggle with visual feedback
- Index.razor: Update tank color indicators to use new alert system
- Settings.razor: Remove global threshold fields, add note about per-tank configuration
- Improved alert messages with actual percentage values
- Dynamic alert severity based on criticality (Warning vs Error)

All data persists to JSON files and survives application restarts.
Data location: {AppContext.BaseDirectory}/data/
…ert system

- Remove TankLowLevelThreshold and TankHighLevelThreshold from AlertSettings initialization
- Update AlertService.CheckTankAlertsAsync to use AlertLevel and AlertWhenOver properties
- Improve alert messages with threshold information
- Dynamic severity determination based on alert direction (over vs under)
- Add JsonFileStore mock and ILogger<JsonFileStore> mock to test setup
- Create temporary directory for test file storage to avoid conflicts
- Update TankService constructor call to include JsonFileStore parameter
- All existing tests continue to work with new persistence layer
@StuartF303 StuartF303 merged commit 732e36c into main Nov 9, 2025
4 checks passed
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.

2 participants