Skip to content

Commit

Permalink
Merge pull request #26 from briis/version-2.0.4
Browse files Browse the repository at this point in the history
Version 2.0.4
  • Loading branch information
briis authored Mar 12, 2024
2 parents 6f07c9d + aff9a0a commit 32078a3
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 8 deletions.
18 changes: 14 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
# Changelog for Affaldshåndtering DK Home Assistant Integration

**Date**: `2024-03-xx`

## What's Changed

- Adding new Attribute `date_short`. Closing [#22](https://github.com/briis/affalddk/issues/22)
- Fixing missing update of Calendard state. Closing [#27](https://github.com/briis/affalddk/issues/27)
- Fixing missing Containers for Kerteminde. Closing [#19](https://github.com/briis/affalddk/issues/19)
- Bump dependency `pyrenoweb` to 2.0.11

---------------------------

<details>
<summary><b>PREVIOUS CHANGES</b></summary>

**Date**: `2024-03-10`

This is a Hotfix release, only adding missing containers for some municipalities.
Expand All @@ -21,10 +35,6 @@ And create an issue with the data from the logfile, and the Municipality that ha
- Fixing the Genbrug category for Egedal kommune
- Bump dependency `pyrenoweb` to 2.0.10

---------------------------

<details>
<summary><b>PREVIOUS CHANGES</b></summary>

## Version 2.0.2

Expand Down
28 changes: 26 additions & 2 deletions custom_components/affalddk/calendar.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,36 @@ def __init__(
@property
def event(self) -> CalendarEvent | None:
"""Return the next upcoming event."""
return self._event
item = None
_next_pickup = datetime.datetime(2030, 12, 31, 23, 59, 00)
_pickup_event: PickupType = None
_pickup_events: PickupType = None
if self._coordinator.data.pickup_events is None:
return None

# Find the next pickup event
for row in self._coordinator.data.pickup_events:
if row == 'next_pickup':
continue
_pickup_event: PickupType = self._coordinator.data.pickup_events.get(row)
if _pickup_event.date <= _next_pickup:
_next_pickup = _pickup_event.date
_pickup_events = _pickup_event
item = row

_start: dt = _pickup_events.date
_end: dt = _start + timedelta(days=1)
return CalendarEvent(
summary=NAME_LIST.get(item),
description=_pickup_events.description,
start=dt_util.as_local(_start),
end=dt_util.as_local(_end),
)

async def async_get_events(self, hass: HomeAssistant, start_date: datetime.datetime, end_date: datetime.datetime) -> list[CalendarEvent]:
""""Return calendar events within a datetime range."""

events = []
events: list[CalendarEvent] = []
for item in self._coordinator.data.pickup_events:
if self._coordinator.data.pickup_events.get(item) is None:
continue
Expand Down
1 change: 1 addition & 0 deletions custom_components/affalddk/const.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""Constants in renoweb component."""

ATTR_DATE_LONG = "date_long"
ATTR_DATE_SHORT = "date_short"
ATTR_DURATION = "duration"
ATTR_DESCRIPTION = "description"
ATTR_LAST_UPDATE = "last_update"
Expand Down
4 changes: 2 additions & 2 deletions custom_components/affalddk/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"iot_class": "cloud_polling",
"issue_tracker": "https://github.com/briis/affalddk/issues",
"requirements": [
"pyrenoweb==2.0.10"
"pyrenoweb==2.0.11"
],
"version": "2.0.3"
"version": "2.0.4"
}
2 changes: 2 additions & 0 deletions custom_components/affalddk/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
from . import AffaldDKtDataUpdateCoordinator
from .const import (
ATTR_DATE_LONG,
ATTR_DATE_SHORT,
ATTR_DESCRIPTION,
ATTR_DURATION,
ATTR_LAST_UPDATE,
Expand Down Expand Up @@ -270,6 +271,7 @@ def extra_state_attributes(self) -> None:
return {
ATTR_DATE: _date.date() if _date else None,
ATTR_DATE_LONG: f"{_day_name_long} {_date.strftime("d. %d-%m-%Y") if _date else None}" ,
ATTR_DATE_SHORT: f"{_day_name} {_date.strftime("d. %d/%m") if _date else None}" ,
ATTR_DESCRIPTION: self._pickup_events.description,
ATTR_DURATION: _day_text,
ATTR_ENTITY_PICTURE: f"/local/affalddk/{self._pickup_events.entity_picture}?{str(_current_date.timestamp())}",
Expand Down

0 comments on commit 32078a3

Please sign in to comment.