Skip to content

Commit c50ae77

Browse files
committed
Improve
1 parent 3690dac commit c50ae77

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

plugwise/helper.py

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -844,14 +844,17 @@ def _appliance_measurements(
844844
continue
845845

846846
# Skip known obsolete measurements
847-
updated_date_locator = f'.//logs/point_log[type="{measurement}"]/updated_date'
848-
if (updated_date_key := appliance.find(updated_date_locator) is not None:
847+
updated_date_locator = (
848+
f'.//logs/point_log[type="{measurement}"]/updated_date'
849+
)
850+
if (
851+
updated_date_key := appliance.find(updated_date_locator)
852+
) is not None:
849853
if measurement in OBSOLETE_MEASUREMENTS:
850-
updated_date = updated_date_key.text.strip("T")
851-
t1 = dt.strptime(updated_date, "%Y-%m-%d")
852-
t2 = dt.datetime.now().strftime("%Y-%m-%d")
853-
difference = (t2 -t1).days
854-
if difference > 30:
854+
updated_date = updated_date_key.text.split("T")[0]
855+
date_1 = dt.datetime.strptime(updated_date, "%Y-%m-%d")
856+
date_2 = dt.datetime.now()
857+
if int((date_2 - date_1).days) > 30:
855858
continue
856859

857860
if new_name := getattr(attrs, ATTR_NAME, None):

0 commit comments

Comments
 (0)