mirror of
https://github.com/Dielee/volvo2mqtt.git
synced 2026-08-13 11:19:52 +02:00
Add statistics endpoint to cached responses
This commit is contained in:
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
name: "Volvo2Mqtt"
|
name: "Volvo2Mqtt"
|
||||||
description: "Volvo AAOS MQTT bridge"
|
description: "Volvo AAOS MQTT bridge"
|
||||||
version: "1.5.0"
|
version: "1.5.1"
|
||||||
slug: "volvo2mqtt"
|
slug: "volvo2mqtt"
|
||||||
init: false
|
init: false
|
||||||
url: "https://github.com/Dielee/volvo2mqtt"
|
url: "https://github.com/Dielee/volvo2mqtt"
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
from config import settings
|
from config import settings
|
||||||
|
|
||||||
VERSION = "v1.5.0"
|
VERSION = "v1.5.1"
|
||||||
|
|
||||||
OAUTH_URL = "https://volvoid.eu.volvocars.com/as/token.oauth2"
|
OAUTH_URL = "https://volvoid.eu.volvocars.com/as/token.oauth2"
|
||||||
VEHICLES_URL = "https://api.volvocars.com/connected-vehicle/v1/vehicles"
|
VEHICLES_URL = "https://api.volvocars.com/connected-vehicle/v1/vehicles"
|
||||||
|
|||||||
+4
-21
@@ -6,7 +6,8 @@ from config import settings
|
|||||||
from babel.dates import format_datetime
|
from babel.dates import format_datetime
|
||||||
from const import charging_system_states, charging_connection_states, CLIMATE_START_URL, \
|
from const import charging_system_states, charging_connection_states, CLIMATE_START_URL, \
|
||||||
OAUTH_URL, VEHICLES_URL, VEHICLE_DETAILS_URL, RECHARGE_STATE_URL, \
|
OAUTH_URL, VEHICLES_URL, VEHICLE_DETAILS_URL, RECHARGE_STATE_URL, \
|
||||||
WINDOWS_STATE_URL, LOCK_STATE_URL, TYRE_STATE_URL, supported_entities, BATTERY_CHARGE_STATE_URL
|
WINDOWS_STATE_URL, LOCK_STATE_URL, TYRE_STATE_URL, supported_entities, BATTERY_CHARGE_STATE_URL, \
|
||||||
|
STATISTICS_URL
|
||||||
|
|
||||||
session = requests.Session()
|
session = requests.Session()
|
||||||
session.headers = {
|
session.headers = {
|
||||||
@@ -168,30 +169,12 @@ def api_call(url, method, vin, sensor_id=None, force_update=False):
|
|||||||
if datetime.now(util.TZ) >= token_expires_at:
|
if datetime.now(util.TZ) >= token_expires_at:
|
||||||
refresh_auth()
|
refresh_auth()
|
||||||
|
|
||||||
if url == RECHARGE_STATE_URL:
|
if url in [RECHARGE_STATE_URL, WINDOWS_STATE_URL, LOCK_STATE_URL, TYRE_STATE_URL, STATISTICS_URL]:
|
||||||
# Minimize API calls for recharge state
|
# Minimize API calls for endpoints with multiple values
|
||||||
response = cached_request(url, method, vin, force_update)
|
response = cached_request(url, method, vin, force_update)
|
||||||
if response is None:
|
if response is None:
|
||||||
# Exception caught while getting data from volvo api, doing nothing
|
# Exception caught while getting data from volvo api, doing nothing
|
||||||
return None
|
return None
|
||||||
elif url == WINDOWS_STATE_URL:
|
|
||||||
# Minimize API calls for window state
|
|
||||||
response = cached_request(url, method, vin, force_update)
|
|
||||||
if response is None:
|
|
||||||
# Exception caught while getting data from volvo api, doing nothing
|
|
||||||
return ""
|
|
||||||
elif url == LOCK_STATE_URL:
|
|
||||||
# Minimize API calls for door state
|
|
||||||
response = cached_request(url, method, vin, force_update)
|
|
||||||
if response is None:
|
|
||||||
# Exception caught while getting data from volvo api, doing nothing
|
|
||||||
return ""
|
|
||||||
elif url == TYRE_STATE_URL:
|
|
||||||
# Minimize API calls for tyre state
|
|
||||||
response = cached_request(url, method, vin, force_update)
|
|
||||||
if response is None:
|
|
||||||
# Exception caught while getting data from volvo api, doing nothing
|
|
||||||
return ""
|
|
||||||
elif method == "GET":
|
elif method == "GET":
|
||||||
print("Starting " + method + " call against " + url)
|
print("Starting " + method + " call against " + url)
|
||||||
try:
|
try:
|
||||||
|
|||||||
Reference in New Issue
Block a user