From 92bab7c1ad73e9809cbab8de830aa7fb3d82bc55 Mon Sep 17 00:00:00 2001 From: "Alan D. Tse" Date: Sat, 28 May 2022 18:03:39 -0700 Subject: [PATCH] fix: handle unknown recurring patterns 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 --- custom_components/alexa_media/const.py | 1 + custom_components/alexa_media/sensor.py | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/custom_components/alexa_media/const.py b/custom_components/alexa_media/const.py index bcc332e5..6a1085af 100644 --- a/custom_components/alexa_media/const.py +++ b/custom_components/alexa_media/const.py @@ -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", diff --git a/custom_components/alexa_media/sensor.py b/custom_components/alexa_media/sensor.py index a5bfd281..beeff496 100644 --- a/custom_components/alexa_media/sensor.py +++ b/custom_components/alexa_media/sensor.py @@ -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 @@ -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 )