Skip to content

Commit

Permalink
Fixed query of climater, preheater, fixed last_update_time, oil and h…
Browse files Browse the repository at this point in the history
…ybrid range
  • Loading branch information
t0bias-r committed Mar 4, 2024
1 parent 1f54639 commit 1ea37d4
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 88 deletions.
18 changes: 0 additions & 18 deletions .github/workflows/lintPR.yaml

This file was deleted.

45 changes: 0 additions & 45 deletions .github/workflows/release.yml

This file was deleted.

19 changes: 13 additions & 6 deletions custom_components/audiconnect/audi_connect_account.py
Original file line number Diff line number Diff line change
Expand Up @@ -409,8 +409,8 @@ async def update(self):
await self.call_update(self.update_vehicle_position, 3)
info = "climater"
await self.call_update(self.update_vehicle_climater, 3)
info = "charger"
await self.call_update(self.update_vehicle_charger, 3)
#info = "charger"
#await self.call_update(self.update_vehicle_charger, 3)
info = "preheater"
await self.call_update(self.update_vehicle_preheater, 3)
# Return True on success, False on error
Expand Down Expand Up @@ -762,7 +762,7 @@ def service_inspection_distance_supported(self):
check = self._vehicle.fields.get("MAINTENANCE_INTERVAL_DISTANCE_TO_INSPECTION")
if check and parse_int(check):
return True

@property
def service_adblue_distance(self):
"""Return distance left for service inspection"""
Expand Down Expand Up @@ -809,12 +809,19 @@ def oil_change_distance_supported(self):
def oil_level(self):
"""Return oil level percentage"""
if self.oil_level_supported:
return float(self._vehicle.fields.get("OIL_LEVEL_DIPSTICKS_PERCENTAGE"))
val = self._vehicle.fields.get("OIL_LEVEL_DIPSTICKS_PERCENTAGE")
if type(val) is bool:
if val:
return 100
else:
return 1
if parse_float(val):
return True

@property
def oil_level_supported(self):
check = self._vehicle.fields.get("OIL_LEVEL_DIPSTICKS_PERCENTAGE")
if check and parse_float(check):
if check is not None:
return True

@property
Expand Down Expand Up @@ -1201,7 +1208,7 @@ def actual_charge_rate(self):
return parse_float(self._vehicle.state.get("actualChargeRate"))
except ValueError:
return -1


@property
def actual_charge_rate_supported(self):
Expand Down
20 changes: 5 additions & 15 deletions custom_components/audiconnect/audi_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,12 @@ 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"])
Expand All @@ -77,7 +75,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
Expand Down Expand Up @@ -111,16 +111,6 @@ def _getFromJson(self, json, loc):
return None
child = child[i]
return child

self.states.append({"name" : "stateOfCharge", "value" : data["measurements"]["fuelLevelStatus"]["value"]["currentSOC_pct"], "measure_time" : data["measurements"]["fuelLevelStatus"]["value"]["carCapturedTimestamp"] })
self.states.append({"name" : "chargingMode", "value" : data["charging"]["chargingStatus"]["value"]["chargeType"], "measure_time" : data["charging"]["chargingStatus"]["value"]["carCapturedTimestamp"] })
self.states.append({"name" : "actualChargeRate", "value" : data["charging"]["chargingStatus"]["value"]["chargeRate_kmph"], "measure_time" : data["charging"]["chargingStatus"]["value"]["carCapturedTimestamp"] })
self.states.append({"name" : "chargingPower", "value" : data["charging"]["chargingStatus"]["value"]["chargePower_kW"], "measure_time" : data["charging"]["chargingStatus"]["value"]["carCapturedTimestamp"] })
self.states.append({"name" : "chargeMode", "value" : data["charging"]["chargingStatus"]["value"]["chargeMode"], "measure_time" : data["charging"]["chargingStatus"]["value"]["carCapturedTimestamp"] })
self.states.append({"name" : "chargingState", "value" : data["charging"]["chargingStatus"]["value"]["chargingState"], "measure_time" : data["charging"]["chargingStatus"]["value"]["carCapturedTimestamp"] })
self.states.append({"name" : "plugState", "value" : data["charging"]["plugStatus"] ["value"]["plugConnectionState"], "measure_time" : data["charging"]["plugStatus"] ["value"]["carCapturedTimestamp"] })
#self.states.append({"name" : "remainingChargingTime", "value" : data["charging"]["chargingStatus"]["value"]["remainingChargingTimeToComplete_min"] "measure_time" : data["charging"]["chargingStatus"]["value"]["carCapturedTimestamp"] })


def appendDoorState(self, data):
doors = data["access"]["accessStatus"]["value"]["doors"];
Expand Down
4 changes: 2 additions & 2 deletions custom_components/audiconnect/audi_services.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
6 changes: 6 additions & 0 deletions custom_components/audiconnect/dashboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 0 additions & 2 deletions custom_components/audiconnect/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,3 @@ def parse_float(val: str):
return float(val)
except (ValueError, TypeError):
return None
except TypeError:
return None

0 comments on commit 1ea37d4

Please sign in to comment.