Skip to content

Commit

Permalink
fix: handle unknown recurring patterns
Browse files Browse the repository at this point in the history
Amazon appears to have abandoned the `recurringPattern` field in favor
of `rRuleData`. The older recurrence is likely only found in legacy
reminders. Sensors will likely need to be reworked to handle.

closes #1490
  • Loading branch information
alandtse committed May 29, 2022
1 parent 113b5e2 commit 92bab7c
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
1 change: 1 addition & 0 deletions custom_components/alexa_media/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
RECURRING_PATTERN = {
None: "Never Repeat",
"P1D": "Every day",
"P1M": "Every month",
"XXXX-WE": "Weekends",
"XXXX-WD": "Weekdays",
"XXXX-WXX-1": "Every Monday",
Expand Down
4 changes: 2 additions & 2 deletions custom_components/alexa_media/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ def _update_recurring_alarm(self, value):
_LOGGER.debug(
"%s with recurrence %s set to %s",
value[1]["type"],
RECURRING_PATTERN[recurring_pattern],
RECURRING_PATTERN.get(recurring_pattern),
alarm,
)
value[1][self._sensor_property] = alarm
Expand Down Expand Up @@ -526,7 +526,7 @@ def icon(self):
def recurrence(self):
"""Return the recurrence pattern of the sensor."""
return (
RECURRING_PATTERN[self._next.get("recurringPattern")]
RECURRING_PATTERN.get(self._next.get("recurringPattern"))
if self._next
else None
)
Expand Down

0 comments on commit 92bab7c

Please sign in to comment.