Skip to content

Commit

Permalink
handle(=ignore) invalid dates
Browse files Browse the repository at this point in the history
  • Loading branch information
marq24 committed Dec 9, 2024
1 parent 8a4d70e commit 780c190
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
21 changes: 12 additions & 9 deletions custom_components/evcc_intg/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -367,17 +367,20 @@ async def async_write_tag(self, tag: Tag, value, idx: str = None, entity: Entity
return result

def _convert_time(self, value: str):
if "0001-01-01T00:00:00Z" == value:
return None
if value is not None and len(value) > 0:
if "0001-01-01T00:00:00Z" == value:
return None

# we need to convert UTC in local time
value = value.replace("Z", "+00:00")
if ".000" in value:
dt = datetime.strptime(value, "%Y-%m-%dT%H:%M:%S.%f%z")
# we need to convert UTC in local time
value = value.replace("Z", "+00:00")
if ".000" in value:
dt = datetime.strptime(value, "%Y-%m-%dT%H:%M:%S.%f%z")
else:
dt = datetime.strptime(value, "%Y-%m-%dT%H:%M:%S%z")
value = dt.astimezone().isoformat(sep=" ", timespec="minutes")
return value.split("+")[0]
else:
dt = datetime.strptime(value, "%Y-%m-%dT%H:%M:%S%z")
value = dt.astimezone().isoformat(sep=" ", timespec="minutes")
return value.split("+")[0]
return None


class EvccBaseEntity(Entity):
Expand Down
2 changes: 1 addition & 1 deletion custom_components/evcc_intg/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@
"iot_class": "local_polling",
"issue_tracker": "https://github.com/marq24/ha-evcc/issues",
"requirements": [],
"version": "2024.11.0"
"version": "2024.12.0"
}

0 comments on commit 780c190

Please sign in to comment.