Compare commits

...
3 Commits
Author SHA1 Message Date
Linus Dietz c87a3cb2d7 Fix #9 2023-06-20 10:58:09 +02:00
Linus DietzandGitHub f6a26e5a41 Update README.md 2023-06-20 10:01:54 +02:00
Linus DietzandGitHub 42d07f1a4c Update README.md 2023-06-20 10:01:39 +02:00
3 changed files with 9 additions and 9 deletions
+1 -1
View File
@@ -22,7 +22,7 @@ Here is what every option means:
| `updateInterval` | `int` | **required** | Update intervall in seconds. |
| `babelLocale` | `string` | **required** | Locale for date Format |
| `mqtt` | `json` | **required** | Broker = Mqtt Broker IP / Username and Passwort are optional! |
| `volvoData` | `json` | **required** | Username and password are required. Car vin can be a single vin or a list of multiple vins like `["vin1", "vin2"]`. If no vin is provided, <b>ALL</b> of your vehicles will be used. Vccapi key is your api key from [here](https://developer.volvocars.com/account/). |
| `volvoData` | `json` | **required** | Username and password are REQUIRED. Car vin can be a single vin or a list of multiple vins like `["vin1", "vin2"]`. If no vin is provided, <b>ALL</b> of your vehicles will be used. Vccapi key is REQUIRED. Get your Vccapi key from [here](https://developer.volvocars.com/account/). |
| `TZ` | `string` | | Container timezone eg "Europe/Berlin" |
If you like my work:
+1 -1
View File
@@ -1,4 +1,4 @@
VERSION = "v1.0.5"
VERSION = "v1.0.6"
OAUTH_URL = "https://volvoid.eu.volvocars.com/as/token.oauth2"
VEHICLES_URL = "https://api.volvocars.com/connected-vehicle/v1/vehicles"
+7 -7
View File
@@ -17,7 +17,7 @@ token_expires_at: datetime
refresh_token = None
vins = []
recharge_response = {}
recharge_last_update = None
recharge_last_update = {}
def authorize():
@@ -111,19 +111,19 @@ def api_call(url, method, vin, sensor_id=None):
global recharge_response, recharge_last_update
if url == RECHARGE_STATUS_URL:
# Minimize API calls for recharge API
if not bool(recharge_response):
# No API Data cached, get fresh data from API
if not vin in recharge_response:
# No API Data for vin cached, get fresh data from API
print("Starting " + method + " call against " + url)
response = session.get(url.format(vin), timeout=15)
recharge_response[vin] = response
recharge_last_update = datetime.now()
recharge_last_update[vin] = datetime.now()
else:
if (datetime.now() - recharge_last_update).total_seconds() >= settings["updateInterval"]:
# Old Data in Cache, updateing
if (datetime.now() - recharge_last_update[vin]).total_seconds() >= settings["updateInterval"]:
# Old Data in Cache, updating
print("Starting " + method + " call against " + url)
response = session.get(url.format(vin), timeout=15)
recharge_response[vin] = response
recharge_last_update = datetime.now()
recharge_last_update[vin] = datetime.now()
else:
# Data is up do date, returning cached data
response = recharge_response[vin]