From 358f7ddb0668c7ef3efd212826ef4e0a5ae90e0d Mon Sep 17 00:00:00 2001 From: t0bias-r Date: Mon, 4 Mar 2024 14:24:47 +0100 Subject: [PATCH] Fixed query of climater, preheater, fixed last_update_time, oil and hybrid range --- custom_components/audiconnect/audi_connect_account.py | 8 ++++---- custom_components/audiconnect/audi_models.py | 9 ++++++--- custom_components/audiconnect/audi_services.py | 4 ++-- custom_components/audiconnect/dashboard.py | 6 ++++++ 4 files changed, 18 insertions(+), 9 deletions(-) diff --git a/custom_components/audiconnect/audi_connect_account.py b/custom_components/audiconnect/audi_connect_account.py index 62dbeb16..644307a1 100644 --- a/custom_components/audiconnect/audi_connect_account.py +++ b/custom_components/audiconnect/audi_connect_account.py @@ -407,12 +407,12 @@ async def update(self): await self.call_update(self.update_vehicle_longterm, 3) info = "position" await self.call_update(self.update_vehicle_position, 3) - #info = "climater" - #await self.call_update(self.update_vehicle_climater, 3) + info = "climater" + await self.call_update(self.update_vehicle_climater, 3) #info = "charger" #await self.call_update(self.update_vehicle_charger, 3) - #info = "preheater" - #await self.call_update(self.update_vehicle_preheater, 3) + info = "preheater" + await self.call_update(self.update_vehicle_preheater, 3) # Return True on success, False on error return self._no_error except Exception as exception: diff --git a/custom_components/audiconnect/audi_models.py b/custom_components/audiconnect/audi_models.py index 3b21075c..6ff9445f 100644 --- a/custom_components/audiconnect/audi_models.py +++ b/custom_components/audiconnect/audi_models.py @@ -54,14 +54,15 @@ def __init__(self, data): self._tryAppendFieldWithTs(data, "LIGHT_STATUS", ["vehicleLights", "lightsStatus", "value", "lights"]) - + self.appendWindowState(data) self.appendSunRoofState(data) self.appendDoorState(data) self.appendHoodState(data) + self._tryAppendStateWithTs(data, "last_update_time", -1, ["measurements", "odometerStatus", "value", "carCapturedTimestamp"]) self._tryAppendStateWithTs(data, "carType", -1, ["fuelStatus", "rangeStatus", "value", "carType"]) - + self._tryAppendStateWithTs(data, "engineTypeFirstEngine", -2, ["fuelStatus", "rangeStatus", "value", "primaryEngine", "type"]) self._tryAppendStateWithTs(data, "primaryEngineRange", -2, ["fuelStatus", "rangeStatus", "value", "primaryEngine", "remainingRange_km"]) self._tryAppendStateWithTs(data, "primaryEngineRangePercent", -2, ["fuelStatus", "rangeStatus", "value", "primaryEngine", "currentSOC_pct"]) @@ -78,7 +79,9 @@ def __init__(self, data): self._tryAppendStateWithTs(data, "chargingState", -1, ["charging", "chargingStatus", "value", "chargingState"]) self._tryAppendStateWithTs(data, "plugState", -1, ["charging", "plugStatus", "value", "plugConnectionState"]) self._tryAppendStateWithTs(data, "remainingChargingTime", -1, ["charging", "plugStatus", "value", "remainingChargingTimeToComplete_min"]) - + + self._tryAppendStateWithTs(data, "climatisationState", -1, ["climatisation", "auxiliaryHeatingStatus", "value", "climatisationState"]) + def _tryAppendStateWithTs(self, json, name, tsoff, loc): ts = None diff --git a/custom_components/audiconnect/audi_services.py b/custom_components/audiconnect/audi_services.py index 120db807..aaccc78b 100644 --- a/custom_components/audiconnect/audi_services.py +++ b/custom_components/audiconnect/audi_services.py @@ -190,12 +190,12 @@ async def get_stored_vehicle_data(self, vin: str): "lvBattery", "measurements", "oilLevel", - "readiness" + "readiness", #"userCapabilities", "vehicleHealthInspection", "vehicleHealthWarnings", "vehicleLights", - } + } self._api.use_token(self._bearer_token_json) data = await self._api.get( "https://emea.bff.cariad.digital/vehicle/v1/vehicles/{vin}/selectivestatus?jobs={jobs}".format( diff --git a/custom_components/audiconnect/dashboard.py b/custom_components/audiconnect/dashboard.py index 3b307f44..0db7c7e6 100644 --- a/custom_components/audiconnect/dashboard.py +++ b/custom_components/audiconnect/dashboard.py @@ -389,6 +389,12 @@ def create_instruments(): Sensor(attr="mileage", name="Mileage", icon="mdi:speedometer", unit="km"), Sensor(attr="service_adblue_distance", name="AdBlue range", icon="mdi:gas-station", unit="km"), Sensor(attr="range", name="Range", icon="mdi:gas-station", unit="km"), + Sensor( + attr="hybrid_range", + name="hybrid Range", + icon="mdi:gas-station-outline", + unit="km", + ), Sensor( attr="service_inspection_time", name="Service inspection time",