From ac05d7cbe2d6651b9762c1aed598ad3a17dc7cfb Mon Sep 17 00:00:00 2001 From: ChessSpider Date: Sun, 12 Nov 2023 18:33:35 +0100 Subject: [PATCH] fix sensor.py --- sensor.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sensor.py b/sensor.py index a8758e2..d9fed18 100644 --- a/sensor.py +++ b/sensor.py @@ -85,7 +85,7 @@ def state(self): now = datetime.now() valid_until = datetime.strptime(reservation.get("valid_until", "1900-01-01T00:00:00"), "%Y-%m-%dT%H:%M:%S") - valid_from = datetime.strptime(reservation.get("valid_from", "1900-01-01T00:00:00"), "%Y-%m-%dT%H:%M:%S") + valid_from = datetime.strptime(str(reservation.get("valid_from", "1900-01-01T00:00:00")).split('.')[0], "%Y-%m-%dT%H:%M:%S") if valid_until > now and valid_from <= now: return "present" @@ -167,8 +167,8 @@ def state(self) -> int: future_licenseplates = [] for reservation in active_reservations: - valid_until = datetime.strptime(reservation.get("valid_until", "1900-01-01T00:00:00"), "%Y-%m-%dT%H:%M:%S") - valid_from = datetime.strptime(reservation.get("valid_from", "1900-01-01T00:00:00"), "%Y-%m-%dT%H:%M:%S") + valid_until = datetime.strptime(str(reservation.get("valid_until", "1900-01-01T00:00:00")).split('.')[0], "%Y-%m-%dT%H:%M:%S") + valid_from = datetime.strptime(str(reservation.get("valid_from", "1900-01-01T00:00:00")).split('.')[0], "%Y-%m-%dT%H:%M:%S") license_plate = reservation.get("license_plate") if license_plate: