Commit Graph

21 Commits

Author SHA1 Message Date
Wizznu c79033de91 fix: Add polling mechanism for sensor threshold monitoring
Problem:
- Firebase SDK listener not triggering (SDK timeout)
- No sensor data being checked despite sensor=true
- Log shows no SENSOR CHECK output

Solution:
- Add polling every 30 seconds using REST API (reliable)
- Keep Firebase listener as backup if SDK recovers
- Check kontrolConfig.sensor flag before processing
- Shared checkSensorThresholds() function for both methods

This ensures sensor mode works even when Firebase SDK fails
2026-02-16 19:45:29 +07:00
Wizznu 581ab42fac feat: Add verbose logging for sensor mode threshold monitoring
- Log every sensor check with full sensor data
- Display threshold config for each check
- Show detailed evaluation for each pot
- Log cooldown status and trigger events
- Help debug why mosfet not triggering
2026-02-16 19:30:34 +07:00
Wizznu 91cb3eaaea feat: Dynamic threshold system for sensor-based watering
- Detect all threshold_* nodes from kontrol_1
- Support unlimited threshold configurations
- Each threshold: batas_bawah, batas_atas, smart_mode, pot_aktif[], pompa settings
- Smart mode: water until batas_atas reached
- Fixed mode: water for fixed duration
- Setup script: setup-firebase-threshold.js for auto Firebase initialization
- Improved logging: show threshold ID, mode, and pot info on trigger
2026-02-16 12:31:26 +07:00
Wizznu 6f4b7c25f1 feat: Flexible jadwal system + kontrol_1 path support
- Added FIREBASE_PATHS config for easy path switching
- Support unlimited jadwal (jadwal_1, jadwal_2, ... jadwal_N)
- Each jadwal can select specific pots (pot_aktif array)
- Per-schedule config: duration, pompa_air, pompa_pupuk
- Updated all kontrol refs to use FIREBASE_PATHS.kontrol (kontrol_1)
- Added setup script for auto Firebase initialization
- Added comprehensive documentation (FLEXIBLE_SCHEDULE_GUIDE.md)
- Backward compatible with legacy waktu_1/waktu_2 format

Files added:
- setup-firebase-jadwal.js: Auto setup Firebase jadwal
- FLEXIBLE_SCHEDULE_GUIDE.md: Complete guide for flexible schedules
- firebase-example.json: Example Firebase structure

Changes:
- worker.js: Dynamic schedule detection, kontrol_1 path support
2026-02-16 11:05:22 +07:00
Wizznu 561881e18e fix: Optimize Firebase connection with smart fallback system - SDK timeout 10s->5s - Smart fallback after 3 consecutive failures - API statistics tracking (SDK vs REST) - Auto-recovery every 50 minutes 2026-02-16 09:58:17 +07:00
Wizznu 5e85ad61e2 HOTFIX: Fix incomplete replacement causing syntax errors in setFirebaseViaREST and readFirebaseSmart 2026-02-11 12:32:48 +07:00
Wizznu 935e1059f6 CRITICAL: Fix fetch() timeout not working in Node.js + add job-level timeout + extensive debug logging 2026-02-11 12:23:10 +07:00
Wizznu 1fc1d7ecbc HOTFIX: Fix syntax error in healthCheck function (line 878) 2026-02-11 12:01:16 +07:00
Wizznu 895ce4c1fe CRITICAL FIX: Add timeout+REST fallback for ALL Firebase operations (set, read, delete) 2026-02-11 11:57:25 +07:00
Wizznu 68ce136317 Fix Firebase update timeout: add REST API fallback for write operations 2026-02-11 11:39:09 +07:00
Wizznu 5c8c93c104 Fix BullMQ job ID: replace colon with underscore 2026-02-11 11:25:43 +07:00
Wizznu 4d9add606e Add Firebase REST API fallback and smart fetch mechanism 2026-02-11 11:12:03 +07:00
Wizznu 6ce4affe6b Critical fix: Add timeout handler for Firebase fetch to prevent hanging 2026-02-11 11:03:19 +07:00
Wizznu 6e4f73928f Add extensive debug logging to trace checkScheduledWatering execution 2026-02-11 10:49:56 +07:00
Wizznu 556199a28d Fix: Add error handling and timing fix for scheduler checks 2026-02-11 10:38:33 +07:00
Wizznu 76bb751962 Fix: Add verbose logging for debugging scheduler and aktuator issues 2026-02-11 10:27:13 +07:00
Wizznu 8b8ad29c4d Add debugging: time sync monitoring, manual test functions, aktuator validation 2026-02-11 10:06:49 +07:00
Wizznu 4434a05db1 Completely suppress Firebase SDK warnings 2026-02-11 07:58:50 +07:00
Wizznu acefe143b4 Add crash prevention and keep-alive mechanisms 2026-02-11 07:55:08 +07:00
Wizznu 2f59a363da Optimize worker: reduce Firebase warnings and verbose logging 2026-02-11 07:49:29 +07:00
Wizznu 8da7b66494 Initial commit: Railway Worker for ApsGo IoT System 2026-02-11 07:40:33 +07:00