diff --git a/custom_components/afvalwijzer/collector/opzet.py b/custom_components/afvalwijzer/collector/opzet.py index 0ffadff..c996ea2 100644 --- a/custom_components/afvalwijzer/collector/opzet.py +++ b/custom_components/afvalwijzer/collector/opzet.py @@ -5,7 +5,7 @@ from ..common.day_sensor_data import DaySensorData from ..common.next_sensor_data import NextSensorData -from ..const.const import _LOGGER, SENSOR_COLLECTOR_TO_URL, SENSOR_COLLECTORS_OPZET +from ..const.const import _LOGGER, SENSOR_COLLECTORS_OPZET class OpzetCollector(object): @@ -33,9 +33,6 @@ def __init__( TODAY = datetime.today().strftime("%d-%m-%Y") self.DATE_TODAY = datetime.strptime(TODAY, "%d-%m-%Y") self.DATE_TOMORROW = datetime.strptime(TODAY, "%d-%m-%Y") + timedelta(days=1) - self.DATE_TODAY_NEXT_YEAR = ( - self.DATE_TODAY.date() + timedelta(days=365) - ).strftime("%Y-%m-%d") ( self._waste_data_raw, diff --git a/custom_components/afvalwijzer/common/day_sensor_data.py b/custom_components/afvalwijzer/common/day_sensor_data.py index 790555b..f67be79 100644 --- a/custom_components/afvalwijzer/common/day_sensor_data.py +++ b/custom_components/afvalwijzer/common/day_sensor_data.py @@ -15,7 +15,9 @@ def __init__( ): TODAY = datetime.today().strftime("%d-%m-%Y") - self.waste_data_formatted = waste_data_formatted + self.waste_data_formatted = sorted( + waste_data_formatted, key=lambda d: d["date"] + ) self.today_date = datetime.strptime(TODAY, "%d-%m-%Y") self.tomorrow_date = datetime.strptime(TODAY, "%d-%m-%Y") + timedelta(days=1) self.day_after_tomorrow_date = datetime.strptime(TODAY, "%d-%m-%Y") + timedelta( diff --git a/custom_components/afvalwijzer/common/next_sensor_data.py b/custom_components/afvalwijzer/common/next_sensor_data.py index 7c8ccc8..2a8b93c 100644 --- a/custom_components/afvalwijzer/common/next_sensor_data.py +++ b/custom_components/afvalwijzer/common/next_sensor_data.py @@ -9,7 +9,9 @@ class NextSensorData(object): # INIT ########################################################################## def __init__(self, waste_data_after_date_selected, default_label): - self.waste_data_after_date_selected = waste_data_after_date_selected + self.waste_data_after_date_selected = sorted( + waste_data_after_date_selected, key=lambda d: d["date"] + ) TODAY = datetime.today().strftime("%d-%m-%Y") self.today_date = datetime.strptime(TODAY, "%d-%m-%Y")