diff --git a/src/config.yaml b/src/config.yaml index a11041a..7a9d9ab 100644 --- a/src/config.yaml +++ b/src/config.yaml @@ -1,6 +1,6 @@ name: "Volvo2Mqtt" description: "Volvo AAOS MQTT bridge" -version: "1.5.0" +version: "1.5.1" slug: "volvo2mqtt" init: false url: "https://github.com/Dielee/volvo2mqtt" diff --git a/src/const.py b/src/const.py index 10b51cc..869c6ec 100644 --- a/src/const.py +++ b/src/const.py @@ -1,6 +1,6 @@ from config import settings -VERSION = "v1.5.0" +VERSION = "v1.5.1" OAUTH_URL = "https://volvoid.eu.volvocars.com/as/token.oauth2" VEHICLES_URL = "https://api.volvocars.com/connected-vehicle/v1/vehicles" diff --git a/src/volvo.py b/src/volvo.py index b419404..38ff6fd 100644 --- a/src/volvo.py +++ b/src/volvo.py @@ -6,7 +6,8 @@ from config import settings from babel.dates import format_datetime from const import charging_system_states, charging_connection_states, CLIMATE_START_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.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: refresh_auth() - if url == RECHARGE_STATE_URL: - # Minimize API calls for recharge state + if url in [RECHARGE_STATE_URL, WINDOWS_STATE_URL, LOCK_STATE_URL, TYRE_STATE_URL, STATISTICS_URL]: + # Minimize API calls for endpoints with multiple values response = cached_request(url, method, vin, force_update) if response is None: # Exception caught while getting data from volvo api, doing nothing 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": print("Starting " + method + " call against " + url) try: