#!/bin/bash
export PATH=/opt/domoticz/:/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/bin

# Récupérer la date actuelle au format YYYY-MM-DD
current_date=$(date +%F)

# Calculer la date antérieure de 30 jours
previous_date=$(date -d "$current_date - 30 days" +%F)
previous_date_1=$(date -d "$current_date - 1 days" +%F)

echo "Date actuelle : $current_date"
echo "Date antérieure de 30 jours : $previous_date"


/usr/bin/curl -H "Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOlsiMTQ4OTg1NTI3OTMzOTciXSwiZXhwIjoxNzk1NTQ3MjgxLCJpYXQiOjE3MDExOTg0ODF9.l1kWoiJLFXsN9YUAaxn7Sy0PvtFiFt5spjF1E_deu_E" -X GET "https://conso.boris.sh/api/daily_consumption?prm=14898552793397&start=$previous_date&end=$current_date" >/opt/domoticz/www/enedis.json

/usr/bin/curl -H "Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOlsiMTQ4OTg1NTI3OTMzOTciXSwiZXhwIjoxNzk1NTQ3MjgxLCJpYXQiOjE3MDExOTg0ODF9.l1kWoiJLFXsN9YUAaxn7Sy0PvtFiFt5spjF1E_deu_E" -X GET "https://conso.boris.sh/api/consumption_load_curve?prm=14898552793397&start=$previous_date_1&end=$current_date" >/opt/domoticz/www/enedis_curve.json

