diff --git a/README.md b/README.md index 603f295ea..77eb0a5a6 100644 --- a/README.md +++ b/README.md @@ -112,12 +112,14 @@ The state value shows the next timer as a timestring (i.e.: `2021-03-07T15:26:17 Both alarms and timers have a property called status. The status of the next alarm/timer (which is used as sensor state value) is also available through sensor state attributes `next_alarm_status` and `next_timer_status` respectively. -| Status | Meaning | -| --------- | ------------------------------------------------------------------ | -| `none` | Alarm or timer does not exist | -| `set` | Alarm or timer has been set | -| `ringing` | Alarm or timer is ringing right now | -| `snoozed` | Alarm was ringing and has been snoozed (only available for alarms) | +| Status | Meaning | +| ---------- | ------------------------------------------------------------------ | +| `none` | Alarm or timer does not exist | +| `set` | Alarm or timer has been set | +| `ringing` | Alarm or timer is ringing right now | +| `snoozed` | Alarm was ringing and has been snoozed (only available for alarms) | +| `inactive` | Alarm is inactive (only available for alarms) | +| `missed` | Alarm was missed (only available for alarms) | Note that timers lack the additional `snoozed` state due to a limitation of the API. If you actually snooze a timer it will just reset itself to the state `set` again. diff --git a/custom_components/google_home/models.py b/custom_components/google_home/models.py index 3cd85ce7e..11f4393c1 100644 --- a/custom_components/google_home/models.py +++ b/custom_components/google_home/models.py @@ -70,11 +70,12 @@ def set_timers(self, timers: list[TimerJsonDict]) -> None: ] def get_sorted_alarms(self) -> list[GoogleHomeAlarm]: - """Returns alarms in a sorted order. Inactive alarms are in the end.""" + """Returns alarms in a sorted order. Inactive & missed alarms are at the end.""" return sorted( self._alarms, key=lambda k: k.fire_time - if k.status != GoogleHomeAlarmStatus.INACTIVE + if k.status + not in (GoogleHomeAlarmStatus.INACTIVE, GoogleHomeAlarmStatus.MISSED) else k.fire_time + sys.maxsize, ) @@ -195,6 +196,7 @@ class GoogleHomeAlarmStatus(Enum): RINGING = 2 SNOOZED = 3 INACTIVE = 4 + MISSED = 5 class GoogleHomeTimerStatus(Enum): diff --git a/custom_components/google_home/sensor.py b/custom_components/google_home/sensor.py index 174d0215d..88d55cea5 100644 --- a/custom_components/google_home/sensor.py +++ b/custom_components/google_home/sensor.py @@ -179,7 +179,9 @@ def state(self) -> str | None: next_alarm = device.get_next_alarm() return ( next_alarm.local_time_iso - if next_alarm and next_alarm.status != GoogleHomeAlarmStatus.INACTIVE + if next_alarm + and next_alarm.status + not in (GoogleHomeAlarmStatus.INACTIVE, GoogleHomeAlarmStatus.MISSED) else STATE_UNAVAILABLE )