Add sonos alarm clock update service#7521
Conversation
|
@frog32, thanks for your PR! By analyzing the history of the files in this pull request, we identified @pvizeli, @rhooper and @bjarniivarsson to be potential reviewers. |
| a.volume = int(data[ATTR_VOLUME] * 100) | ||
| if ATTR_ENABLED in data: | ||
| _LOGGER.warning("found enabled updating %s" % data[ATTR_ENABLED]) | ||
| a.enabled = data[ATTR_ENABLED] |
There was a problem hiding this comment.
line too long (103 > 79 characters)
There was a problem hiding this comment.
These are debugging comments, will remove them in the final PR
|
|
||
| hass.services.register( | ||
| DOMAIN, SERVICE_UPDATE_ALARM_CLOCK, service_handle, | ||
| descriptions.get(SERVICE_UPDATE_ALARM_CLOCK), schema=SONOS_UPDATE_ALARM_CLOCK_SCHEMA) |
There was a problem hiding this comment.
Could use SERVICE_UPDATE_ALARM instead which would make a lot of names shorter. What do others think?
There was a problem hiding this comment.
Or, just:
descriptions.get(
SERVICE_UPDATE_ALARM_CLOCK),
schema=SONOS_UPDATE_ALARM_CLOCK_SCHEMA
)
There was a problem hiding this comment.
Personally, I think "alarm" is fine. Sonos is not really a clock :)
|
Implementation seems fine 👍 |
| alarm1.configure_mock(_alarm_id="1", start_time=None, enabled=False, | ||
| include_linked_zones=False, volume=100) | ||
| with mock.patch('soco.alarms.get_alarms', return_value=[alarm1]): | ||
| attrs = { |
| 'host': '192.0.2.1' | ||
| }) | ||
| device = self.hass.data[sonos.DATA_SONOS][-1] | ||
| device.hass = self.hass |
There was a problem hiding this comment.
local variable 'spec' is assigned to but never used
| hass.services.register( | ||
| DOMAIN, SERVICE_UPDATE_ALARM, service_handle, | ||
| descriptions.get(SERVICE_UPDATE_ALARM), | ||
| schema=SONOS_UPDATE_ALARM_SCHEMA) |
There was a problem hiding this comment.
continuation line unaligned for hanging indent
| if alarm._alarm_id == str(data[ATTR_ALARM_ID]): # pylint: disable=W0212 | ||
| a = alarm | ||
| if a is None: | ||
| _LOGGER.warning("did not find alarm with id %s", data[ATTR_ALARM_ID]) |
There was a problem hiding this comment.
line too long (81 > 79 characters)
| from soco import alarms | ||
| a = None | ||
| for alarm in alarms.get_alarms(self.soco): | ||
| if alarm._alarm_id == str(data[ATTR_ALARM_ID]): # pylint: disable=W0212 |
There was a problem hiding this comment.
line too long (84 > 79 characters)
Documentation for home-assistant/core#7521
Description:
Initial attempt on getting support for sonos alarm clock. This first service is to update an existing alarm. I would like to get some feedback since sonos uses the alarm_clock_id to identify existing alarms. The idea is to be able to activate/deactivate or change the time of an existing alarm. Is using this ID that is only available through SoCo a good way of doing that? It seems the only reliable way to repeatedly update a single alarm (wake up alarm in my case).
Pull request in home-assistant.github.io with documentation : home-assistant/home-assistant.io#2631
Checklist:
If user exposed functionality or configuration variables are added/changed:
If the code communicates with devices, web services, or third-party tools:
toxrun successfully. Your PR cannot be merged unless tests pass