Add WiFi and HDMI power saving features for remote sensors
Implements power saving optimizations to extend battery life on solar-powered remote air quality sensors: - WiFi Power Saving: Disable WiFi 10 minutes after boot to save ~100-200mA - Configurable via web UI checkbox in admin panel - WiFi automatically re-enables after reboot for 10-minute configuration window - Systemd timer (nebuleair-wifi-powersave.timer) manages automatic disable - New wifi/power_save.py script checks database config and disables WiFi via nmcli - HDMI Disable: Added hdmi_blanking=2 to boot config to save ~20-30mA - Automatically configured during installation - Database: Added wifi_power_saving boolean config (default: disabled) - Uses INSERT OR IGNORE for safe updates to existing installations - UI: Added checkbox control in admin.html for WiFi power saving - Includes helpful description of power savings and behavior - Services: Updated setup_services.sh and update_firmware.sh to manage new timer Total power savings: ~120-230mA when WiFi power saving enabled 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -237,6 +237,39 @@ AccuracySec=1h
|
||||
WantedBy=timers.target
|
||||
EOL
|
||||
|
||||
# Create service and timer files for WiFi Power Save
|
||||
cat > /etc/systemd/system/nebuleair-wifi-powersave.service << 'EOL'
|
||||
[Unit]
|
||||
Description=NebuleAir WiFi Power Save Service
|
||||
After=network-online.target
|
||||
Wants=network-online.target
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
ExecStart=/usr/bin/python3 /var/www/nebuleair_pro_4g/wifi/power_save.py
|
||||
User=root
|
||||
StandardOutput=journal
|
||||
StandardError=journal
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
EOL
|
||||
|
||||
cat > /etc/systemd/system/nebuleair-wifi-powersave.timer << 'EOL'
|
||||
[Unit]
|
||||
Description=NebuleAir WiFi Power Save Timer (10 minutes after boot)
|
||||
After=network-online.target
|
||||
|
||||
[Timer]
|
||||
# Run 10 minutes after system boot
|
||||
OnBootSec=10min
|
||||
# Don't persist timer across reboots
|
||||
Persistent=false
|
||||
|
||||
[Install]
|
||||
WantedBy=timers.target
|
||||
EOL
|
||||
|
||||
# Reload systemd to recognize new services
|
||||
systemctl daemon-reload
|
||||
|
||||
@@ -248,6 +281,11 @@ for service in npm envea sara bme280 mppt db-cleanup noise; do
|
||||
echo "Started nebuleair-$service-data timer"
|
||||
done
|
||||
|
||||
# Enable and start WiFi power save timer (separate naming convention)
|
||||
systemctl enable nebuleair-wifi-powersave.timer
|
||||
systemctl start nebuleair-wifi-powersave.timer
|
||||
echo "Started nebuleair-wifi-powersave timer"
|
||||
|
||||
echo "Checking status of all timers..."
|
||||
systemctl list-timers | grep nebuleair
|
||||
|
||||
|
||||
Reference in New Issue
Block a user