EMS dashboard v2, branding Cariflex, MQTT config, EMS docs

This commit is contained in:
Eric F
2026-06-09 03:13:09 -04:00
parent 314480976a
commit a70be14f07
4 changed files with 401 additions and 0 deletions

37
scripts/daily_ems.sh Normal file
View File

@@ -0,0 +1,37 @@
#!/bin/bash
# Cariflex - Daily EMS Automation
# Run at 6:00 AM America/Martinique (10:00 UTC)
# Crontab: 0 10 * * * /home/eric/cariflex/scripts/daily_ems.sh
export FM_PASS="Digitribe972"
LOG_FILE="/var/log/cariflex_daily_ems.log"
log() {
echo "$(date '+%Y-%m-%d %H:%M:%S') - $1" >> "$LOG_FILE"
}
log "=== Starting Daily EMS Automation ==="
# 1. Forecasting - Generate forecasts for all sensors
log "Step 1: Forecasting..."
for sensor in $(seq 41 80); do
result=$(docker exec flexmeasures-server bash -c "
cd /app && timeout 120 .venv/bin/flexmeasures add forecasts \
--sensor $sensor \
--to-date \$(date -u -d '+24 hours' +'%Y-%m-%dT%H:%M:%S+00:00') 2>&1 | tail -3
" 2>/dev/null)
log " Sensor $sensor: $result"
done
# 2. Scheduling - Create schedules for batteries and EVs
log "Step 2: Scheduling..."
bash /home/eric/cariflex/scripts/fm_scheduling.sh >> "$LOG_FILE" 2>&1
# 3. Cleanup old data (keep 30 days)
log "Step 3: Cleanup..."
docker exec flexmeasures-db psql -U flexmeasures -d flexmeasures -c "
DELETE FROM timed_belief WHERE event_start < NOW() - INTERVAL '30 days';
VACUUM timed_belief;
" 2>/dev/null
log "=== Daily EMS Automation Complete ==="

82
scripts/fm_scheduling.sh Normal file
View File

@@ -0,0 +1,82 @@
#!/bin/bash
# Cariflex - FlexMeasures EMS Scheduling Automation
# This script schedules batteries and EVs via FM API
FM_HOST="https://cariflex.digitribe.fr"
FM_EMAIL="admin@digitribe.fr"
FM_PASSWORD_FILE="/tmp/fm_pass.txt"
# Get password
FM_PASSWORD=$(cat "$FM_PASSWORD_FILE")
# Login and get session
login() {
local session=$(mktemp)
local csrf_token=$(curl -sk -c "$session" "$FM_HOST/login" | grep -oP 'id="csrf_token" value="\K[^"]+')
curl -sk -c "$session" -b "$session" -X POST "$FM_HOST/login" \
-d "email=$FM_EMAIL&password=$FM_PASSWORD&csrf_token=$csrf_token&remember=y" \
-L -o /dev/null
echo "$session"
}
# Create schedule for a sensor
create_schedule() {
local session="$1"
local sensor_id="$2"
local duration="$3"
local flex_model="$4"
local start=$(date -u +'%Y-%m-%dT%H:%M:%S+00:00')
curl -sk -c "$session" -b "$session" -X POST \
"$FM_HOST/api/v3_0/sensors/$sensor_id/schedules/trigger" \
-H "Content-Type: application/json" \
-d "{
\"start\": \"$start\",
\"duration\": \"$duration\",
\"flex_model\": $flex_model
}"
}
echo "=== Cariflex EMS Scheduling Automation ==="
echo "Date: $(date)"
# Login
SESSION=$(login)
echo "Logged in successfully"
# Schedule Batteries (sensors 51-60)
echo ""
echo "=== Scheduling Batteries (51-60) ==="
for sensor in $(seq 51 60); do
echo " Scheduling battery sensor $sensor..."
result=$(create_schedule "$SESSION" "$sensor" "PT24H" '{
"soc_min": "10 kWh",
"soc_max": "100 kWh",
"power_capacity": "50 kW",
"charging_efficiency": "0.95",
"discharging_efficiency": "0.95"
}')
echo " Result: $(echo "$result" | grep -oP '"status":"[^"]*"' | head -1)"
done
# Schedule EVs (sensors 71-80)
echo ""
echo "=== Scheduling EVs (71-80) ==="
for sensor in $(seq 71 80); do
echo " Scheduling EV sensor $sensor..."
result=$(create_schedule "$SESSION" "$sensor" "PT12H" '{
"soc_min": "15 kWh",
"soc_max": "75 kWh",
"power_capacity": "11 kW",
"charging_efficiency": "0.95",
"discharging_efficiency": "0.95"
}')
echo " Result: $(echo "$result" | grep -oP '"status":"[^"]*"' | head -1)"
done
# Cleanup
rm -f "$SESSION"
echo ""
echo "=== Scheduling Complete ==="