-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'hansinator85/main'
- Loading branch information
Showing
8 changed files
with
205 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,7 @@ | ||
# [awattar-backtesting.github.io](https://awattar-backtesting.github.io) | ||
A tool to visualize your electricity usage with aWATTar | ||
|
||
# Run Locally | ||
Just start [index.html](docs\index.html), but make sure to allow CORS from local machine. | ||
Therefore you either run your own webserver or just start chrome with disabled web security: | ||
`chrome.exe --user-data-dir="C://Chrome dev session" --disable-web-security` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
metering_point: <Zählpunkt Nummer einfügen> | ||
cookie: "__RequestVerificationToken_XXXX=XXXXXXX-Kopie-von-Browser" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
import requests | ||
import csv | ||
import os | ||
import yaml | ||
from datetime import datetime, timedelta | ||
|
||
def load_config(filename='configuration.yaml'): | ||
with open(filename, 'r') as f: | ||
config = yaml.safe_load(f) | ||
return config | ||
|
||
def download_data(date, metering_point, cookie): | ||
formatted_date = date.strftime("%Y-%m-%dT22:00:00.000Z") | ||
url = f"https://www.endkundenwebportal.at/enView.Portal/api/consumption/date?date={formatted_date}&meteringPointIdentifier={metering_point}&format=csv" | ||
headers = { | ||
'Cookie': cookie, | ||
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/123.0.0.0 Safari/537.36' | ||
} | ||
response = requests.get(url, headers=headers) | ||
if response.status_code == 200: | ||
return response.content | ||
else: | ||
print(f"Failed to download data for {formatted_date}. Status code: {response.status_code}") | ||
return None | ||
|
||
def merge_csv_files(output_filename, input_filenames): | ||
with open(output_filename, 'w', newline='') as output_file: | ||
csv_writer = csv.writer(output_file) | ||
header_written = False | ||
for filename in input_filenames: | ||
with open(filename, 'r') as input_file: | ||
csv_reader = csv.reader(input_file) | ||
if not header_written: | ||
csv_writer.writerow(next(csv_reader)) | ||
header_written = True | ||
else: | ||
next(csv_reader) # Skip the header | ||
for row in csv_reader: | ||
csv_writer.writerow(row) | ||
|
||
def get_days_in_month(year, month): | ||
if month == 12: | ||
next_year = year + 1 | ||
next_month = 1 | ||
else: | ||
next_year = year | ||
next_month = month + 1 | ||
days_in_month = (datetime(next_year, next_month, 1) - datetime(year, month, 1)).days | ||
return days_in_month | ||
|
||
def main(): | ||
config = load_config() | ||
metering_point = config.get('metering_point') | ||
cookie = config.get('cookie') | ||
year_month = input("Bitte geben Sie das Jahr und den Monat im Format YYYY-MM ein: ") | ||
year, month = map(int, year_month.split('-')) | ||
days_in_month = get_days_in_month(year, month) | ||
output_filename = f"ClamStrom-{year_month}.csv" | ||
input_filenames = [] | ||
|
||
for day in range(1, days_in_month+1): | ||
date = datetime(year, month, day) | ||
data = download_data(date, metering_point, cookie) | ||
if data: | ||
filename = f"consumption_{date.strftime('%Y-%m-%d')}.csv" | ||
with open(filename, 'wb') as f: | ||
f.write(data) | ||
input_filenames.append(filename) | ||
|
||
merge_csv_files(output_filename, input_filenames) | ||
|
||
# Cleanup individual CSV files | ||
for filename in input_filenames: | ||
os.remove(filename) | ||
|
||
if __name__ == "__main__": | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
Start;Ende;Vorschub (kWh) - Verbrauch;Z�hlerstand (kWh) - Verbrauch | ||
01.04.2024 00:00:00; 01.04.2024 00:15:00;0,120999999999185; | ||
01.04.2024 00:15:00; 01.04.2024 00:30:00;0,10399999999936; | ||
01.04.2024 00:30:00; 01.04.2024 00:45:00;0,114000000001397; | ||
01.04.2024 00:45:00; 01.04.2024 01:00:00;0,131000000001222; | ||
01.04.2024 01:00:00; 01.04.2024 01:15:00;0,265999999995984; | ||
01.04.2024 01:15:00; 01.04.2024 01:30:00;0,494000000006054; | ||
01.04.2024 01:30:00; 01.04.2024 01:45:00;0,532999999995809; | ||
01.04.2024 01:45:00; 01.04.2024 02:00:00;0,275000000001455; | ||
01.04.2024 02:00:00; 01.04.2024 02:15:00;0,224999999998545; | ||
01.04.2024 02:15:00; 01.04.2024 02:30:00;0,22099999999773; | ||
01.04.2024 02:30:00; 01.04.2024 02:45:00;0,213999999999942; | ||
01.04.2024 02:45:00; 01.04.2024 03:00:00;0,231000000007043; | ||
01.04.2024 03:00:00; 01.04.2024 03:15:00;0,222999999998137; | ||
01.04.2024 03:15:00; 01.04.2024 03:30:00;0,186000000001513; | ||
01.04.2024 03:30:00; 01.04.2024 03:45:00;0,247999999999593; | ||
01.04.2024 03:45:00; 01.04.2024 04:00:00;0,213999999999942; | ||
01.04.2024 04:00:00; 01.04.2024 04:15:00;0,19199999999546; | ||
01.04.2024 04:15:00; 01.04.2024 04:30:00;0,198000000003958; | ||
01.04.2024 04:30:00; 01.04.2024 04:45:00;0,203000000001339; | ||
01.04.2024 04:45:00; 01.04.2024 05:00:00;0,189999999995052; | ||
01.04.2024 05:00:00; 01.04.2024 05:15:00;0,360000000000582; | ||
01.04.2024 05:15:00; 01.04.2024 05:30:00;0,393000000003667; | ||
01.04.2024 05:30:00; 01.04.2024 05:45:00;0,127000000000407; | ||
01.04.2024 05:45:00; 01.04.2024 06:00:00;0,069999999999709; | ||
01.04.2024 06:00:00; 01.04.2024 06:15:00;0,0749999999970896; | ||
01.04.2024 06:15:00; 01.04.2024 06:30:00;0,0800000000017462; | ||
01.04.2024 06:30:00; 01.04.2024 06:45:00;0,0899999999965075; | ||
01.04.2024 06:45:00; 01.04.2024 07:00:00;0,0790000000051805; | ||
01.04.2024 07:00:00; 01.04.2024 07:15:00;0,0669999999954598; | ||
01.04.2024 07:15:00; 01.04.2024 07:30:00;0,0540000000037253; | ||
01.04.2024 07:30:00; 01.04.2024 07:45:00;0,114999999997963; | ||
01.04.2024 07:45:00; 01.04.2024 08:00:00;0,0860000000029686; | ||
01.04.2024 08:00:00; 01.04.2024 08:15:00;0,177999999999884; | ||
01.04.2024 08:15:00; 01.04.2024 08:30:00;0,117999999994936; | ||
01.04.2024 08:30:00; 01.04.2024 08:45:00;0,139999999999418; | ||
01.04.2024 08:45:00; 01.04.2024 09:00:00;0,13300000000163; | ||
01.04.2024 09:00:00; 01.04.2024 09:15:00;0,139999999999418; | ||
01.04.2024 09:15:00; 01.04.2024 09:30:00;0,127000000000407; | ||
01.04.2024 09:30:00; 01.04.2024 09:45:00;0,13300000000163; | ||
01.04.2024 09:45:00; 01.04.2024 10:00:00;0,415999999997439; | ||
01.04.2024 10:00:00; 01.04.2024 10:15:00;0,436000000001513; | ||
01.04.2024 10:15:00; 01.04.2024 10:30:00;0,457000000002154; | ||
01.04.2024 10:30:00; 01.04.2024 10:45:00;0,125; | ||
01.04.2024 10:45:00; 01.04.2024 11:00:00;0,125999999996566; | ||
01.04.2024 11:00:00; 01.04.2024 11:15:00;0,133999999998196; | ||
01.04.2024 11:15:00; 01.04.2024 11:30:00;0,423000000002503; | ||
01.04.2024 11:30:00; 01.04.2024 11:45:00;0,160000000003492; | ||
01.04.2024 11:45:00; 01.04.2024 12:00:00;0,108000000000175; | ||
01.04.2024 12:00:00; 01.04.2024 12:15:00;0,119999999995343; | ||
01.04.2024 12:15:00; 01.04.2024 12:30:00;0,118000000002212; | ||
01.04.2024 12:30:00; 01.04.2024 12:45:00;0,118999999998778; | ||
01.04.2024 12:45:00; 01.04.2024 13:00:00;0,129999999997381; | ||
01.04.2024 13:00:00; 01.04.2024 13:15:00;0,124000000003434; | ||
01.04.2024 13:15:00; 01.04.2024 13:30:00;0,110999999997148; | ||
01.04.2024 13:30:00; 01.04.2024 13:45:00;0,110000000000582; | ||
01.04.2024 13:45:00; 01.04.2024 14:00:00;0,103000000002794; | ||
01.04.2024 14:00:00; 01.04.2024 14:15:00;0,144000000000233; | ||
01.04.2024 14:15:00; 01.04.2024 14:30:00;0,106999999996333; | ||
01.04.2024 14:30:00; 01.04.2024 14:45:00;0,117000000005646; | ||
01.04.2024 14:45:00; 01.04.2024 15:00:00;0,157999999995809; | ||
01.04.2024 15:00:00; 01.04.2024 15:15:00;0,234000000004016; | ||
01.04.2024 15:15:00; 01.04.2024 15:30:00;0,413999999997031; | ||
01.04.2024 15:30:00; 01.04.2024 15:45:00;0,400000000001455; | ||
01.04.2024 15:45:00; 01.04.2024 16:00:00;0,400000000001455; | ||
01.04.2024 16:00:00; 01.04.2024 16:15:00;0,421999999998661; | ||
01.04.2024 16:15:00; 01.04.2024 16:30:00;0,445999999996275; | ||
01.04.2024 16:30:00; 01.04.2024 16:45:00;0,385000000002037; | ||
01.04.2024 16:45:00; 01.04.2024 17:00:00;0,118000000002212; | ||
01.04.2024 17:00:00; 01.04.2024 17:15:00;0,140999999995984; | ||
01.04.2024 17:15:00; 01.04.2024 17:30:00;0,173000000002503; | ||
01.04.2024 17:30:00; 01.04.2024 17:45:00;0,230000000003201; | ||
01.04.2024 17:45:00; 01.04.2024 18:00:00;0,22099999999773; | ||
01.04.2024 18:00:00; 01.04.2024 18:15:00;0,377000000000407; | ||
01.04.2024 18:15:00; 01.04.2024 18:30:00;0,142999999996391; | ||
01.04.2024 18:30:00; 01.04.2024 18:45:00;0,132000000005064; | ||
01.04.2024 18:45:00; 01.04.2024 19:00:00;0,288999999997031; | ||
01.04.2024 19:00:00; 01.04.2024 19:15:00;0,392999999996391; | ||
01.04.2024 19:15:00; 01.04.2024 19:30:00;0,40400000000227; | ||
01.04.2024 19:30:00; 01.04.2024 19:45:00;0,169000000001688; | ||
01.04.2024 19:45:00; 01.04.2024 20:00:00;0,135999999998603; | ||
01.04.2024 20:00:00; 01.04.2024 20:15:00;0,135999999998603; | ||
01.04.2024 20:15:00; 01.04.2024 20:30:00;0,208000000005995; | ||
01.04.2024 20:30:00; 01.04.2024 20:45:00;0,248999999996158; | ||
01.04.2024 20:45:00; 01.04.2024 21:00:00;0,271999999997206; | ||
01.04.2024 21:00:00; 01.04.2024 21:15:00;0,578000000001339; | ||
01.04.2024 21:15:00; 01.04.2024 21:30:00;0,669999999998254; | ||
01.04.2024 21:30:00; 01.04.2024 21:45:00;0,485000000000582; | ||
01.04.2024 21:45:00; 01.04.2024 22:00:00;0,381000000001222; | ||
01.04.2024 22:00:00; 01.04.2024 22:15:00;0,332000000002154; | ||
01.04.2024 22:15:00; 01.04.2024 22:30:00;0,290000000000873; | ||
01.04.2024 22:30:00; 01.04.2024 22:45:00;0,194999999999709; | ||
01.04.2024 22:45:00; 01.04.2024 23:00:00;0,313999999998487; | ||
01.04.2024 23:00:00; 01.04.2024 23:15:00;0,34599999999773; | ||
01.04.2024 23:15:00; 01.04.2024 23:30:00;0,317000000002736; | ||
01.04.2024 23:30:00; 01.04.2024 23:45:00;0,313999999998487; | ||
01.04.2024 23:45:00; 02.04.2024 00:00:00;0,128000000004249; |