correct daily aggregating data file name

This commit is contained in:
Yinyin Liu 2024-07-31 09:16:49 +02:00
parent 9e870be389
commit 959af2bf5e
4 changed files with 43 additions and 22 deletions

View File

@ -69,7 +69,13 @@ class AggregatedData:
def push_to_s3(self, s3_config):
csv_data = self.to_csv()
compressed_csv = self.compress_csv_data(csv_data)
s3_path = datetime.now().strftime("%Y-%m-%d") + ".csv"
now = datetime.now()
if now.hour == 0 and now.minute < 30:
adjusted_date = now - timedelta(days=1)
else:
adjusted_date = now
s3_path = adjusted_date.strftime("%Y-%m-%d") + ".csv"
response = s3_config.create_put_request(s3_path, compressed_csv)
if response.status_code != 200:
print("ERROR: PUT", response.text)

View File

@ -8,20 +8,21 @@ set -e
battery_file_path="./CerboReleaseFiles/dbus-fzsonick-48tl"
cerbo_release_file_path="./CerboReleaseFiles"
echo -e "\n============================ Deploy ============================\n"
# Berger 10.2.2.36 and Polycom 10.2.4.96 are Cerbo with fork usb0
# ip_addresses_usb0=("10.2.2.118" "10.2.4.155" "10.2.3.244" "10.2.4.127" "10.2.2.36" "10.2.4.96")
ip_addresses_usb0=("10.2.2.118" "10.2.4.155" "10.2.3.244" "10.2.4.127")
ip_addresses_usb1=("10.2.0.179" "10.2.1.241" )
# Polycom 10.2.4.96 are Cerbo with fork usb0
ip_addresses_usb0=("10.2.2.118" "10.2.4.155" "10.2.3.244" "10.2.4.127" "10.2.2.248" "10.2.2.36")
ip_addresses_usb1=("10.2.0.179" "10.2.1.241" "10.2.1.193" "10.2.2.61" "10.2.3.225")
for ip_address in "${ip_addresses_usb0[@]}"; do
# ssh "$username"@"$ip_address" "cd /opt/victronenergy/serial-starter && echo '$root_password' | ./stop-tty.sh ttyUSB0"
ssh "$username"@"$ip_address" "svc -d /service/aggregator"
scp "${battery_file_path}/aggregator.py" "root@"$ip_address":/data/dbus-fzsonick-48tl/"
scp "${battery_file_path}/start.sh" "root@"$ip_address":/data/dbus-fzsonick-48tl/"
scp "${cerbo_release_file_path}/rc.local" "root@"$ip_address":/data"
scp -r "${cerbo_release_file_path}/aggregator" "root@"$ip_address":/data"
scp "${battery_file_path}/aggregator.py" "root@"$ip_address":/opt/victronenergy/dbus-fzsonick-48tl"
ssh "$username"@"$ip_address" "svc -u /service/aggregator"
# scp "${battery_file_path}/start.sh" "root@"$ip_address":/data/dbus-fzsonick-48tl/"
# scp "${cerbo_release_file_path}/rc.local" "root@"$ip_address":/data"
# scp -r "${cerbo_release_file_path}/aggregator" "root@"$ip_address":/data"
# ssh "$username"@"$ip_address" "cd /opt/victronenergy/serial-starter && echo '$root_password' | ./start-tty.sh ttyUSB0"
@ -33,7 +34,10 @@ for ip_address in "${ip_addresses_usb1[@]}"; do
# ssh "$username"@"$ip_address" "cd /opt/victronenergy/serial-starter && echo '$root_password' | ./stop-tty.sh ttyUSB1"
ssh "$username"@"$ip_address" "svc -d /service/aggregator"
scp "${battery_file_path}/aggregator.py" "root@"$ip_address":/data/dbus-fzsonick-48tl/"
scp "${battery_file_path}/aggregator.py" "root@"$ip_address":/opt/victronenergy/dbus-fzsonick-48tl"
ssh "$username"@"$ip_address" "svc -u /service/aggregator"
# scp "${battery_file_path}/start.sh" "root@"$ip_address":/data/dbus-fzsonick-48tl/"
# scp "${cerbo_release_file_path}/rc.local" "root@"$ip_address":/data"
# scp -r "${cerbo_release_file_path}/aggregator" "root@"$ip_address":/data"

View File

@ -68,7 +68,13 @@ class AggregatedData:
def push_to_s3(self, s3_config):
csv_data = self.to_csv()
compressed_csv = self.compress_csv_data(csv_data)
s3_path = datetime.now().strftime("%Y-%m-%d") + ".csv"
now = datetime.now()
if now.hour == 0 and now.minute < 30:
adjusted_date = now - timedelta(days=1)
else:
adjusted_date = now
s3_path = adjusted_date.strftime("%Y-%m-%d") + ".csv"
response = s3_config.create_put_request(s3_path, compressed_csv)
if response.status_code != 200:
print("ERROR: PUT", response.text)

View File

@ -8,24 +8,26 @@ set -e
battery_file_path="./VenusReleaseFiles/dbus-fzsonick-48tl"
venus_release_file_path="./VenusReleaseFiles"
echo -e "\n============================ Deploy ============================\n"
# Berger 10.2.2.36 and Polycom 10.2.4.96 are Cerbo with fork usb0
# Polycom 10.2.4.96 are Cerbo with fork usb0
# Grundmann 10.2.0.155 failed with ssh"
# Wiest 10.2.0.209 failed with ssh"
# Buecheler 10.2.0.224 failed with ssh"
# ip_addresses_usb0=("10.2.1.97" "10.2.0.104" "10.2.1.159" "10.2.0.227" "10.2.2.36" "10.2.4.96" "10.2.0.224" "10.2.0.155" "10.2.0.209")
ip_addresses_usb0=("10.2.1.97" "10.2.0.104" "10.2.1.159" "10.2.0.227" "10.2.2.36" "10.2.4.96")
ip_addresses_usb1=("10.2.1.35")
ip_addresses_usb0=("10.2.1.97" "10.2.0.104" "10.2.1.159" "10.2.0.227" "10.2.4.96")
ip_addresses_usb1=("10.2.1.35" "10.2.0.211")
for ip_address in "${ip_addresses_usb0[@]}"; do
# ssh "$username"@"$ip_address" "cd /opt/victronenergy/serial-starter && echo '$root_password' | ./stop-tty.sh ttyUSB0"
ssh "$username"@"$ip_address" "svc -d /service/aggregator"
scp "${battery_file_path}/aggregator.py" "root@"$ip_address":/data/dbus-fzsonick-48tl/"
scp "${battery_file_path}/start.sh" "root@"$ip_address":/data/dbus-fzsonick-48tl/"
scp "${battery_file_path}/service/run" "root@"$ip_address":/data/dbus-fzsonick-48tl/service"
scp "${venus_release_file_path}/rc.local" "root@"$ip_address":/data"
scp -r "${venus_release_file_path}/aggregator" "root@"$ip_address":/data"
scp "${battery_file_path}/aggregator.py" "root@"$ip_address":/opt/victronenergy/dbus-fzsonick-48tl"
ssh "$username"@"$ip_address" "svc -u /service/aggregator"
# scp "${battery_file_path}/start.sh" "root@"$ip_address":/data/dbus-fzsonick-48tl/"
# scp "${battery_file_path}/service/run" "root@"$ip_address":/data/dbus-fzsonick-48tl/service"
# scp "${venus_release_file_path}/rc.local" "root@"$ip_address":/data"
# scp -r "${venus_release_file_path}/aggregator" "root@"$ip_address":/data"
# ssh "$username"@"$ip_address" "cd /opt/victronenergy/serial-starter && echo '$root_password' | ./start-tty.sh ttyUSB0"
@ -38,11 +40,14 @@ for ip_address in "${ip_addresses_usb1[@]}"; do
# ssh "$username"@"$ip_address" "cd /opt/victronenergy/serial-starter && echo '$root_password' | ./stop-tty.sh ttyUSB1"
ssh "$username"@"$ip_address" "svc -d /service/aggregator"
scp "${battery_file_path}/aggregator.py" "root@"$ip_address":/data/dbus-fzsonick-48tl/"
scp "${battery_file_path}/start.sh" "root@"$ip_address":/data/dbus-fzsonick-48tl/"
scp "${battery_file_path}/service/run" "root@"$ip_address":/data/dbus-fzsonick-48tl/service"
scp "${venus_release_file_path}/rc.local" "root@"$ip_address":/data"
scp -r "${venus_release_file_path}/aggregator" "root@"$ip_address":/data"
scp "${battery_file_path}/aggregator.py" "root@"$ip_address":/opt/victronenergy/dbus-fzsonick-48tl"
ssh "$username"@"$ip_address" "svc -u /service/aggregator"
# scp "${battery_file_path}/start.sh" "root@"$ip_address":/data/dbus-fzsonick-48tl/"
# scp "${battery_file_path}/service/run" "root@"$ip_address":/data/dbus-fzsonick-48tl/service"
# scp "${venus_release_file_path}/rc.local" "root@"$ip_address":/data"
# scp -r "${venus_release_file_path}/aggregator" "root@"$ip_address":/data"
# ssh "$username"@"$ip_address" "cd /opt/victronenergy/serial-starter && echo '$root_password' | ./start-tty.sh ttyUSB1"