Skip to content

Commit

Permalink
fix: handle exception for recurringPattern
Browse files Browse the repository at this point in the history
Alexa notifications API only uses recurringPattern when set.
  • Loading branch information
alandtse committed Apr 8, 2020
1 parent e47274c commit 1dfb3be
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions custom_components/alexa_media/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ def _update_recurring_alarm(self, value):
)
)
alarm_on = value[1]["status"] == "ON"
recurring_pattern = value[1]["recurringPattern"]
recurring_pattern = value[1].get("recurringPattern")
while (
alarm_on
and recurring_pattern
Expand Down Expand Up @@ -400,7 +400,11 @@ def icon(self):
@property
def recurrence(self):
"""Return the recurrence pattern of the sensor."""
return RECURRING_PATTERN[self._next["recurringPattern"]] if self._next else None
return (
RECURRING_PATTERN[self._next.get("recurringPattern")]
if self._next
else None
)

@property
def device_state_attributes(self):
Expand Down

0 comments on commit 1dfb3be

Please sign in to comment.