Skip to content

Commit a983def

Browse files
committed
read_tag_vehicle_str fixes
1 parent cea959a commit a983def

2 files changed

Lines changed: 14 additions & 3 deletions

File tree

custom_components/evcc_intg/__init__.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -889,9 +889,15 @@ def read_tag_vehicle_int(self, a_tag: Tag, loadpoint_idx: int = None, vehicle_id
889889
return None
890890

891891
def read_tag_vehicle_str(self, a_tag: Tag, vehicle_id: str):
892+
if self.data is None or JSONKEY_VEHICLES not in self.data:
893+
return None
894+
892895
is_veh_PLANSSOC = a_tag == Tag.VEHICLEPLANSOC
893896
is_veh_PLANSTIME = a_tag == Tag.VEHICLEPLANTIME
894897
if is_veh_PLANSSOC or is_veh_PLANSTIME:
898+
if vehicle_id not in self.data[JSONKEY_VEHICLES]:
899+
return {}
900+
895901
# yes this is really a hack! [at a certain point the API just returned 'plan' and 'plans' have been removed] ?!
896902
if JSONKEY_PLAN in self.data[JSONKEY_VEHICLES][vehicle_id] and len(self.data[JSONKEY_VEHICLES][vehicle_id][JSONKEY_PLAN]) > 0:
897903
if is_veh_PLANSSOC:
@@ -906,14 +912,16 @@ def read_tag_vehicle_str(self, a_tag: Tag, vehicle_id: str):
906912
return str(int(value)) # float(int(value))/100
907913
elif is_veh_PLANSTIME:
908914
return self._convert_time(self.data[JSONKEY_VEHICLES][vehicle_id][JSONKEY_PLANS_DEPRECATED][0][JSONKEY_PLAN_TIME])
909-
910915
else:
911-
return None
916+
return {}
912917

913918
elif a_tag in [Tag.VEHICLEREPEATINGPLAN002, Tag.VEHICLEREPEATINGPLAN003, Tag.VEHICLEREPEATINGPLAN004,
914919
Tag.VEHICLEREPEATINGPLAN005, Tag.VEHICLEREPEATINGPLAN006, Tag.VEHICLEREPEATINGPLAN007,
915920
Tag.VEHICLEREPEATINGPLAN008, Tag.VEHICLEREPEATINGPLAN009, Tag.VEHICLEREPEATINGPLAN010]:
916921

922+
if vehicle_id not in self.data[JSONKEY_VEHICLES]:
923+
return {}
924+
917925
# The key difference is when [] is used:
918926
# `get("repeatingPlans", []) uses [] only if the key is missing.`
919927
# while
@@ -944,6 +952,9 @@ def read_tag_vehicle_str(self, a_tag: Tag, vehicle_id: str):
944952
else:
945953
return {}
946954
else:
955+
if vehicle_id not in self.data[JSONKEY_VEHICLES]:
956+
return "0"
957+
947958
# the "default" vehicle data reading code...
948959
if a_tag.json_key in self.data[JSONKEY_VEHICLES][vehicle_id]:
949960
return self.data[JSONKEY_VEHICLES][vehicle_id][a_tag.json_key]

custom_components/evcc_intg/manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,5 @@
1111
"iot_class": "local_push",
1212
"issue_tracker": "https://github.com/marq24/ha-evcc/issues",
1313
"requirements": ["packaging>=21.0"],
14-
"version": "2026.7.0"
14+
"version": "2026.7.1"
1515
}

0 commit comments

Comments
 (0)