Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nicer name for alarms #18

Merged
merged 1 commit into from
Apr 13, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 15 additions & 3 deletions custom_components/sonos_alarm/switch.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,6 @@ def __init__(self, soco, alarm):
self._is_available = True
speaker_info = self._soco.get_speaker_info(True)
self._unique_id = "{}-{}".format(soco.uid, self._id)
self._name = "Sonos {} Alarm (id: {})".format(
speaker_info["zone_name"], self._id
)
_entity_id = slugify("sonos_alarm_{}".format(self._id))
self.entity_id = ENTITY_ID_FORMAT.format(_entity_id)
self._model = speaker_info["model_name"]
Expand All @@ -131,6 +128,13 @@ def __init__(self, soco, alarm):
ATTR_PLAY_MODE: str(self.alarm.play_mode),
ATTR_SCHEDULED_TODAY: self._is_today
}

self._name = "Sonos Alarm {} {} {}".format(
speaker_info["zone_name"],
self.alarm.recurrence.title(),
str(self.alarm.start_time)[0:5]
)

rasmusbe marked this conversation as resolved.
Show resolved Hide resolved
_LOGGER.debug(self.alarm.recurrence)
super().__init__()
_LOGGER.debug("reached end of init")
Expand All @@ -151,6 +155,14 @@ def update(self, now=None):
ATTR_INCLUDE_LINKED_ZONES
] = self.alarm.include_linked_zones
self._is_available = True

speaker_info = self._soco.get_speaker_info(True)
self._name = "Sonos Alarm {} {} {}".format(
speaker_info["zone_name"],
self.alarm.recurrence.title(),
str(self.alarm.start_time)[0:5]
)

_LOGGER.debug("successfully updated alarms")
except SoCoException as exc:
_LOGGER.error(
Expand Down