- Changed FIREBASE_PATHS.kontrol from 'kontrol' to 'kontrol_1'
- Worker now reads/writes from correct path (app uses /kontrol_1)
- Fixes issue where kontrol config was always NULL
- Schedule triggers should now work correctly
- Added migration helper script (migrate-history-source.js)
This aligns worker with current app structure after schema update.
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
- 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
- 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