smokkelaar / carchargewithhourcurrentrates Goto Github PK
View Code? Open in Web Editor NEWCharing on the cheapest power rates
License: GNU General Public License v3.0
Charing on the cheapest power rates
License: GNU General Public License v3.0
No data from entsoe since 01-01-2021
Need to update the taxes of energy 2021
Add different loglevels in the code for debugging:
Requested loglevels:
CRITICAL | 50
ERROR | 40
WARNING | 30
INFO | 20
DEBUG | 10
NOTSET | 0
By the looks of the website it seems they changed a bit of stuff. Probably filling datafields from another source than before which can't be handled by requests. Found out that selenum can do this.
I would like to put in a pull request but im not sure how things get handled when summer and wintertime changes. Please let me know what you think!
import datetime as dt
from selenium import webdriver
from bs4 import BeautifulSoup
#######################################################
###Input: none
###Function: Get the day ahead prices form entsoe, and transform them to price per kWh including taxation. (*0.00121)
###Output: List of upcoming prices so far as possible. in the format: list[time, price buy, price sell]
#######################################################
def Ophalen():
nu = dt.datetime.now(dt.timezone.utc)
morgen = nu + dt.timedelta(days=1)
urlvandaag = "https://transparency.entsoe.eu/transmission-domain/r2/dayAheadPrices/show?name=&defaultValue=false&viewType=TABLE&areaType=BZN&atch=false&dateTime.dateTime="+"{:02d}".format(nu.day)+"."+"{:02d}".format(nu.month)+"."+str(nu.year)+"+00:00|CET|DAY&biddingZone.values=CTY|10YNL----------L!BZN|10YNL----------L&resolution.values=PT60M&dateTime.timezone=CET_CEST&dateTime.timezone_input=CET+(UTC+1)+/+CEST+(UTC+2)"
urlmorgen = "https://transparency.entsoe.eu/transmission-domain/r2/dayAheadPrices/show?name=&defaultValue=false&viewType=TABLE&areaType=BZN&atch=false&dateTime.dateTime="+"{:02d}".format(morgen.day)+"."+"{:02d}".format(morgen.month)+"."+str(morgen.year)+"+00:00|CET|DAY&biddingZone.values=CTY|10YNL----------L!BZN|10YNL----------L&resolution.values=PT15M&resolution.values=PT30M&resolution.values=PT60M&dateTime.timezone=CET_CEST&dateTime.timezone_input=CET+(UTC+1)+/+CEST+(UTC+2)"
#print(urlvandaag)
#print (urlmorgen)
pagevandaag = webdriver.Chrome()
pagemorgen = webdriver.Chrome()
pagevandaag.get(urlvandaag)
pagemorgen.get(urlmorgen)
soupv = BeautifulSoup(pagevandaag.page_source, 'html.parser')
soupm = BeautifulSoup(pagemorgen.page_source, 'html.parser')
pagevandaag.quit()
pagemorgen.quit()
price_hidev = soupv.find_all(class_='dv-value-cell')
price_hidem = soupm.find_all(class_='dv-value-cell')
returnvalues = []
for price in price_hidev:
try:
#print(price)
noISOdatum = str(price).split("\', \'")[2]
datum = dt.datetime.fromisoformat(noISOdatum[:-1]) + dt.timedelta(hours=3)
if ((datum.timestamp() - nu.timestamp()) >= 0):
#print(datum + dt.timedelta(hours=-1))
#print(price.text)
returnvalues.append([datum, str(round(float(price.text)*0.00121, 7)), str(round(float(price.text)*0.00121, 7))])
except:
pass
try:
for price in price_hidem:
try:
#print(price)
noISOdatum = str(price).split("\', \'")[2]
datum = dt.datetime.fromisoformat(noISOdatum[:-1]) + dt.timedelta(hours=3)
if ((datum.timestamp() - nu.timestamp()) >= 0):
#print(datum + dt.timedelta(hours=-1))
#print(price.text)
returnvalues.append([datum, str(round(float(price.text)*0.00121, 7)), str(round(float(price.text)*0.00121, 7))])
except:
pass
except:
pass
return returnvalues
Depending on the system where it runs you get a different current time.
my own system:
huidige prijs op dit moment: 0.2226153
Minimaleprijs de komende uren: 0.2009926
Maximaleprijs de komende uren: 0.2304198
23.86924342105268
Pythonanywhere:
aantal gegevens easy 34
aantal gegevens entsoe 35
prijs dit uur easy 0.0628353
prijs dit uur entsoe 0.0616495
huidige prijs op dit moment: 0.2214295
Minimaleprijs de komende uren: 0.2009926
Maximaleprijs de komende uren: 0.2304198
27.495888157894743
So something is going on with terminating the current timezome.
manual work arround is, change the time in entsoe to -3600 instead of -7200.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.