From 7456c1ea62cecb1f78aa5fe61ec1912c6b8716e0 Mon Sep 17 00:00:00 2001 From: karwosts <32912880+karwosts@users.noreply.github.com> Date: Tue, 15 Feb 2022 10:18:40 -0800 Subject: [PATCH] Fix "date is not serializable" error. Fix for issue : https://github.com/custom-components/grocy/issues/185 --- custom_components/grocy/json_encode.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/custom_components/grocy/json_encode.py b/custom_components/grocy/json_encode.py index a4482a9..a4d49c2 100644 --- a/custom_components/grocy/json_encode.py +++ b/custom_components/grocy/json_encode.py @@ -1,5 +1,6 @@ import json from datetime import datetime +from datetime import date from pathlib import Path from typing import Any @@ -17,6 +18,8 @@ def default(self, o: Any) -> Any: return o.barcode if isinstance(o, datetime): return o.isoformat() + if isinstance(o, date): + return o.isoformat() if isinstance(o, set): return list(o) if isinstance(o, Path):