From 2421ccc84c023db871f15ff6c0e1a05e321aea87 Mon Sep 17 00:00:00 2001 From: Aaron Schneider Date: Wed, 3 Mar 2021 12:50:08 +0100 Subject: [PATCH] add scheduled_today attribute --- custom_components/sonos_alarm/switch.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/custom_components/sonos_alarm/switch.py b/custom_components/sonos_alarm/switch.py index e28e3aa..03d98f1 100644 --- a/custom_components/sonos_alarm/switch.py +++ b/custom_components/sonos_alarm/switch.py @@ -1,5 +1,6 @@ """Switch for Sonos alarms.""" from datetime import timedelta +from datetime import datetime import logging import socket @@ -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): @@ -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__() @@ -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