Skip to content

Commit

Permalink
add scheduled_today attribute
Browse files Browse the repository at this point in the history
  • Loading branch information
AaronDavidSchneider committed Mar 3, 2021
1 parent 3667c54 commit 2421ccc
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions custom_components/sonos_alarm/switch.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"""Switch for Sonos alarms."""
from datetime import timedelta
from datetime import datetime
import logging

import socket
Expand Down Expand Up @@ -28,6 +29,7 @@
ATTR_DURATION = "duration"
ATTR_PLAY_MODE = "play_mode"
ATTR_RECURRENCE = "recurrence"
ATTR_SCHEDULED_TODAY = "scheduled_today"


async def async_setup_platform(hass, config, async_add_entities, discovery_info=None):
Expand Down Expand Up @@ -128,6 +130,7 @@ def __init__(self, soco, alarm):
ATTR_INCLUDE_LINKED_ZONES: self.alarm.include_linked_zones,
ATTR_RECURRENCE: str(self.alarm.recurrence),
ATTR_PLAY_MODE: str(self.alarm.play_mode),
ATTR_SCHEDULED_TODAY: self.alarm.is_valid_recurrence(int(datetime.today().strftime('%w')))
}
super().__init__()

Expand All @@ -142,6 +145,7 @@ def update(self, now=None):
self._attributes[ATTR_RECURRENCE] = str(self.alarm.recurrence)
self._attributes[ATTR_VOLUME] = self.alarm.volume / 100
self._attributes[ATTR_PLAY_MODE] = str(self.alarm.play_mode)
self._attributes[ATTR_SCHEDULED_TODAY] = self.alarm.is_valid_recurrence(int(datetime.today().strftime('%w')))
self._attributes[
ATTR_INCLUDE_LINKED_ZONES
] = self.alarm.include_linked_zones
Expand Down

0 comments on commit 2421ccc

Please sign in to comment.