Skip to content

Commit

Permalink
Fix a typo in a key
Browse files Browse the repository at this point in the history
In the use of custom events, there was a typo i dict key - fixed.
  • Loading branch information
J-Lindvig authored Apr 18, 2022
1 parent 1f297aa commit 37d656f
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 10 deletions.
7 changes: 1 addition & 6 deletions custom_components/flagdays_dk/flagdays.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ def __init__(self, coordinates = DEFAULT_COORDINATES, offset = 0, custom_events
self._offset = offset
self._session = None
self._year = None
self._state = 0
self._next_event = {}
self._events = []

Expand Down Expand Up @@ -135,8 +134,6 @@ def getFlagdays(self):
_LOGGER.debug("getFlagdays, finding the firstcoming event")
self._next_event = self._getNextEvent()

_LOGGER.debug("State: " + str(self._state))

def _getFlagTimes(self, dateStr):
flagTimes = {}

Expand Down Expand Up @@ -202,7 +199,7 @@ def _getCustomEvent(self, event):
# Calculate the timestamp
flagDay['timestamp'] = int(dateObj.timestamp())
# Calculate the days to the event
flagDay['days_to event'] = (dateObj - self._now).days + 1
flagDay['days_to_event'] = (dateObj - self._now).days + 1

# If the 'calculate_years' is not set or set to false,
# calculate the years passed-
Expand All @@ -222,6 +219,4 @@ def _getNextEvent(self):
now_ts = int(self._now.timestamp())
for event in self._events:
if event['timestamp'] > now_ts:
_LOGGER.debug("Keys: " + str(event.keys()))
self._state = event['days_to event']
return event
2 changes: 1 addition & 1 deletion custom_components/flagdays_dk/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@
"codeowners": ["@J-Lindvig"],
"requirements": ["beautifulsoup4", "html.parser"],
"iot_class": "cloud_polling",
"version": "1.8"
"version": "1.8.1"
}
5 changes: 2 additions & 3 deletions custom_components/flagdays_dk/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,7 @@ def __init__(self, hass, coordinator, flagDays) -> None:
self._hass = hass
self._coordinator = coordinator
self._name = 'flagdays'
# self._state = flagDays._next_event['days_to_event']
self._state = flagDays._state
self._state = flagDays._next_event['days_to_event']
self._icon = 'mdi:flag'
self._next_event = flagDays._next_event
self._events = flagDays._events
Expand All @@ -73,7 +72,7 @@ def extra_state_attributes(self):

attr.update(self._next_event)
# Force a update on state
# self._state = self._next_event['days_to_event']
self._state = self._next_event['days_to_event']

attr['events'] = self._events

Expand Down

0 comments on commit 37d656f

Please sign in to comment.