feat: intégration capteur CO2 MH-Z19
- Scripts MH-Z19/get_data.py (lecture standalone) et write_data.py (écriture SQLite) - Table data_MHZ19, config MHZ19, cleanup et service systemd (120s) - Web UI : carte test sensors, checkbox admin, boutons database + CSV download - SARA_send_data_v2.py non modifié (sera fait dans un second temps) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -205,6 +205,38 @@ AccuracySec=1s
|
||||
WantedBy=timers.target
|
||||
EOL
|
||||
|
||||
# Create service and timer files for MH-Z19 CO2 Data
|
||||
cat > /etc/systemd/system/nebuleair-mhz19-data.service << 'EOL'
|
||||
[Unit]
|
||||
Description=NebuleAir MH-Z19 CO2 Data Collection Service
|
||||
After=network.target
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
ExecStart=/usr/bin/python3 /var/www/nebuleair_pro_4g/MH-Z19/write_data.py
|
||||
User=root
|
||||
WorkingDirectory=/var/www/nebuleair_pro_4g
|
||||
StandardOutput=append:/var/www/nebuleair_pro_4g/logs/mhz19_service.log
|
||||
StandardError=append:/var/www/nebuleair_pro_4g/logs/mhz19_service_errors.log
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
EOL
|
||||
|
||||
cat > /etc/systemd/system/nebuleair-mhz19-data.timer << 'EOL'
|
||||
[Unit]
|
||||
Description=Run NebuleAir MH-Z19 CO2 Data Collection every 120 seconds
|
||||
Requires=nebuleair-mhz19-data.service
|
||||
|
||||
[Timer]
|
||||
OnBootSec=120s
|
||||
OnUnitActiveSec=120s
|
||||
AccuracySec=1s
|
||||
|
||||
[Install]
|
||||
WantedBy=timers.target
|
||||
EOL
|
||||
|
||||
# Create service and timer files for Database Cleanup
|
||||
cat > /etc/systemd/system/nebuleair-db-cleanup-data.service << 'EOL'
|
||||
[Unit]
|
||||
@@ -294,7 +326,7 @@ systemctl daemon-reload
|
||||
|
||||
# Enable and start all timers
|
||||
echo "Enabling and starting all services..."
|
||||
for service in npm envea sara bme280 mppt db-cleanup noise; do
|
||||
for service in npm envea sara bme280 mppt mhz19 db-cleanup noise; do
|
||||
systemctl enable nebuleair-$service-data.timer
|
||||
systemctl start nebuleair-$service-data.timer
|
||||
echo "Started nebuleair-$service-data timer"
|
||||
|
||||
Reference in New Issue
Block a user