Skip to content

Commit

Permalink
retore next_date to date
Browse files Browse the repository at this point in the history
  • Loading branch information
bruxy70 committed Jul 14, 2022
1 parent 232c4de commit b99933f
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions custom_components/garbage_collection/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,12 @@ def __init__(self, config_entry: ConfigEntry) -> None:
self._icon_tomorrow = config.get(const.CONF_ICON_TOMORROW)
exp = config.get(const.CONF_EXPIRE_AFTER)
self.expire_after: time | None = (
None if exp is None else datetime.strptime(exp, "%H:%M:%S").time()
None
if (
exp is None
or datetime.strptime(exp, "%H:%M:%S").time() == time(0, 0, 0)
)
else datetime.strptime(exp, "%H:%M:%S").time()
)
self._date_format = config.get(
const.CONF_DATE_FORMAT, const.DEFAULT_DATE_FORMAT
Expand All @@ -135,9 +140,8 @@ async def async_added_to_hass(self) -> None:
if (state := await self.async_get_last_state()) is not None:
self._attr_state = state.state
self._days = state.attributes[const.ATTR_DAYS]
self._next_date = helpers.parse_datetime(
state.attributes[const.ATTR_NEXT_DATE]
)
next_date = helpers.parse_datetime(state.attributes[const.ATTR_NEXT_DATE])
self._next_date = None if next_date is None else next_date.date()
self.last_collection = helpers.parse_datetime(
state.attributes[const.ATTR_LAST_COLLECTION]
)
Expand Down

0 comments on commit b99933f

Please sign in to comment.