Get charging cost #42
-
| Hi! Does this API support getting the cost for car charging? I would like to use this API to write a script that calculates my average cost for charging my car. Br, | 
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
| You can get the price per kWh using tibber.py, but you won't be able to get any information about your car charging status or how much it has charged over the past X hours using tibber.py (or the Tibber API) afaik. If you know the power (Wattage) of your car charger, and it's constant (ish) during charging, you can get the cost of charging by multiplying the current electricity price (in currency/kWh) with the wattage of the car charger (in kW) multiplied with the amount of time charged (in hours). The current price can be found like this: import tibber
account = tibber.Account("<tibber token>")
home = account.homes[0]  # Choose a home
subscription = home.subscriptions[0]  # Choose a subscription
price = subscription.price_info.currentThe price variable is of type  print(price.total)
print(price.tax)
print(price.energy)
print(price.currency)
print(price.starts_at)To get the hourly prices for electricity today and tomorrow, you can do this: It will return lists of Price objects. It might come in handy to know that the  Good luck! | 
Beta Was this translation helpful? Give feedback.
You can get the price per kWh using tibber.py, but you won't be able to get any information about your car charging status or how much it has charged over the past X hours using tibber.py (or the Tibber API) afaik. If you know the power (Wattage) of your car charger, and it's constant (ish) during charging, you can get the cost of charging by multiplying the current electricity price (in currency/kWh) with the wattage of the car charger (in kW) multiplied with the amount of time charged (in hours).
The current price can be found like this: