Add odometer sensor

This commit is contained in:
Linus Dietz
2023-06-22 13:18:37 +02:00
parent 6a01f70637
commit 5ea045f1cf
2 changed files with 4 additions and 0 deletions
+2
View File
@@ -12,6 +12,7 @@ CAR_LOCK_STATE_URL = "https://api.volvocars.com/connected-vehicle/v2/vehicles/{0
CAR_LOCK_URL = "https://api.volvocars.com/connected-vehicle/v2/vehicles/{0}/commands/lock"
CAR_UNLOCK_URL = "https://api.volvocars.com/connected-vehicle/v2/vehicles/{0}/commands/unlock"
RECHARGE_STATE_URL = "https://api.volvocars.com/energy/v1/vehicles/{0}/recharge-status"
ODOMETER_STATE_URL = "https://api.volvocars.com/connected-vehicle/v1/vehicles/{0}/odometer"
charging_system_states = {"CHARGING_SYSTEM_CHARGING": "Charging", "CHARGING_SYSTEM_IDLE": "Idle",
"CHARGING_SYSTEM_FAULT": "Fault", "CHARGING_SYSTEM_UNSPECIFIED": "Unspecified"}
@@ -22,6 +23,7 @@ supported_sensors = [
{"name": "Estimated Charging Time", "id": "estimated_charging_time", "unit": "minutes", "icon": "timer-sync-outline", "url": RECHARGE_STATE_URL},
{"name": "Charging System Status", "id": "charging_system_status", "icon": "ev-plug-ccs2", "url": RECHARGE_STATE_URL},
{"name": "Estimated Charging Finish Time", "id": "estimated_charging_finish_time", "icon": "timer-sync-outline", "url": RECHARGE_STATE_URL},
{"name": "Odometer", "id": "odometer", "unit": "km" if settings["babelLocale"] != "en_US" else "mi", "icon": "counter", "url": ODOMETER_STATE_URL},
{"name": "Last Data Update", "id": "last_data_update", "icon": "timer", "url": ""}
]
+2
View File
@@ -226,5 +226,7 @@ def parse_api_data(data, sensor_id=None):
return None
elif sensor_id == "lock_status":
return data["data"]["carLocked"]["value"]
elif sensor_id == "odometer":
return data["data"]["odometer"]["value"]
else:
return ""