Link Search Menu Expand Document

AlarmClock service

Control the sonos alarms and times

The AlarmClock service is available on these models: v2-S1 / v2-S13 / v2-S14 / v2-S18 / v2-S21 / v2-S27 / v2-S3 / v2-S33 / v2-S38 / v2-S6 / v2-S9 / v2-Sub.

const SonosDevice = require('@svrooij/sonos').SonosDevice
const sonos = new SonosDevice('192.168.x.x')
sonos.AlarmClockService.OneOfTheMethodsBelow({...})

All actions that require input expect an object with the specified parameters, even if it only requires one parameter.

  1. CreateAlarm
  2. DestroyAlarm
  3. GetDailyIndexRefreshTime
  4. GetFormat
  5. GetHouseholdTimeAtStamp
  6. GetTimeNow
  7. GetTimeServer
  8. GetTimeZone
  9. GetTimeZoneAndRule
  10. GetTimeZoneRule
  11. ListAlarms
  12. SetDailyIndexRefreshTime
  13. SetFormat
  14. SetTimeNow
  15. SetTimeServer
  16. SetTimeZone
  17. UpdateAlarm
  18. AlarmClockService event

CreateAlarm

Create a single alarm, all properties are required

const result = await sonos.AlarmClockService.CreateAlarm({ StartLocalTime:..., Duration:..., Recurrence:..., Enabled:..., RoomUUID:..., ProgramURI:..., ProgramMetaData:..., PlayMode:..., Volume:..., IncludeLinkedZones:... });

Input object:

property type description
StartLocalTime string The start time as hh:mm:ss
Duration string The duration as hh:mm:ss
Recurrence string Repeat this alarm on Allowed values: ONCE / WEEKDAYS / WEEKENDS / DAILY
Enabled boolean Alarm enabled after creation
RoomUUID string The UUID of the speaker you want this alarm for
ProgramURI string The sound uri
ProgramMetaData Track | string The sound metadata, can be empty string
PlayMode PlayMode Alarm play mode Allowed values: NORMAL / REPEAT_ALL / SHUFFLE_NOREPEAT / SHUFFLE
Volume number Volume between 0 and 100
IncludeLinkedZones boolean Should grouped players also play the alarm?

Output object:

property type description
AssignedID number The ID of the new alarm

DestroyAlarm

Delete an alarm

const result = await sonos.AlarmClockService.DestroyAlarm({ ID:... });

Input object:

property type description
ID number The Alarm ID from ListAlarms

This actions returns a boolean whether or not the requests succeeded.

GetDailyIndexRefreshTime

const result = await sonos.AlarmClockService.GetDailyIndexRefreshTime();

Output object:

property type description
CurrentDailyIndexRefreshTime string  

GetFormat

const result = await sonos.AlarmClockService.GetFormat();

Output object:

property type description
CurrentTimeFormat string  
CurrentDateFormat string  

GetHouseholdTimeAtStamp

const result = await sonos.AlarmClockService.GetHouseholdTimeAtStamp({ TimeStamp:... });

Input object:

property type description
TimeStamp string  

Output object:

property type description
HouseholdUTCTime string  

GetTimeNow

const result = await sonos.AlarmClockService.GetTimeNow();

Output object:

property type description
CurrentUTCTime string  
CurrentLocalTime string  
CurrentTimeZone string  
CurrentTimeGeneration number  

GetTimeServer

const result = await sonos.AlarmClockService.GetTimeServer();

Output object:

property type description
CurrentTimeServer string  

GetTimeZone

const result = await sonos.AlarmClockService.GetTimeZone();

Output object:

property type description
Index number  
AutoAdjustDst boolean  

GetTimeZoneAndRule

const result = await sonos.AlarmClockService.GetTimeZoneAndRule();

Output object:

property type description
Index number  
AutoAdjustDst boolean  
CurrentTimeZone string  

GetTimeZoneRule

const result = await sonos.AlarmClockService.GetTimeZoneRule({ Index:... });

Input object:

property type description
Index number  

Output object:

property type description
TimeZone string  

ListAlarms

Get the AlarmList as XML

const result = await sonos.AlarmClockService.ListAlarms();

Output object:

property type description
CurrentAlarmList string xml string, see remarks
CurrentAlarmListVersion string  

Remarks Some libraries also provide a ListAndParseAlarms where the alarm list xml is parsed

SetDailyIndexRefreshTime

const result = await sonos.AlarmClockService.SetDailyIndexRefreshTime({ DesiredDailyIndexRefreshTime:... });

Input object:

property type description
DesiredDailyIndexRefreshTime string  

This actions returns a boolean whether or not the requests succeeded.

SetFormat

const result = await sonos.AlarmClockService.SetFormat({ DesiredTimeFormat:..., DesiredDateFormat:... });

Input object:

property type description
DesiredTimeFormat string  
DesiredDateFormat string  

This actions returns a boolean whether or not the requests succeeded.

SetTimeNow

const result = await sonos.AlarmClockService.SetTimeNow({ DesiredTime:..., TimeZoneForDesiredTime:... });

Input object:

property type description
DesiredTime string  
TimeZoneForDesiredTime string  

This actions returns a boolean whether or not the requests succeeded.

SetTimeServer

const result = await sonos.AlarmClockService.SetTimeServer({ DesiredTimeServer:... });

Input object:

property type description
DesiredTimeServer string  

This actions returns a boolean whether or not the requests succeeded.

SetTimeZone

const result = await sonos.AlarmClockService.SetTimeZone({ Index:..., AutoAdjustDst:... });

Input object:

property type description
Index number  
AutoAdjustDst boolean  

This actions returns a boolean whether or not the requests succeeded.

UpdateAlarm

Update an alarm, all parameters are required.

const result = await sonos.AlarmClockService.UpdateAlarm({ ID:..., StartLocalTime:..., Duration:..., Recurrence:..., Enabled:..., RoomUUID:..., ProgramURI:..., ProgramMetaData:..., PlayMode:..., Volume:..., IncludeLinkedZones:... });

Input object:

property type description
ID number The ID of the alarm see ListAlarms
StartLocalTime string The start time as hh:mm:ss
Duration string The duration as hh:mm:ss
Recurrence string Repeat this alarm on Allowed values: ONCE / WEEKDAYS / WEEKENDS / DAILY
Enabled boolean Alarm enabled after creation
RoomUUID string The UUID of the speaker you want this alarm for
ProgramURI string The sound uri
ProgramMetaData Track | string The sound metadata, can be empty string
PlayMode PlayMode Alarm play mode Allowed values: NORMAL / REPEAT_ALL / SHUFFLE_NOREPEAT / SHUFFLE
Volume number Volume between 0 and 100
IncludeLinkedZones boolean Should grouped players also play the alarm?

This actions returns a boolean whether or not the requests succeeded.

Remarks Some libraries support PatchAlarm where you can update a single parameter

AlarmClockService event

const SonosDevice = require('@svrooij/sonos').SonosDevice
const sonos = new SonosDevice('192.168.x.x')
sonos.AlarmClockService.Events('serviceEvent', (data) => {
  console.log(data);
});

The AlarmClockService emits events with these properties. Not all properties are emitted every time.

parameter type possible values
AlarmListVersion string  
DailyIndexRefreshTime string  
DateFormat string  
TimeFormat string  
TimeGeneration number  
TimeServer string  
TimeZone string  

This file is automatically generated with @svrooij/sonos-docs, do not edit manually.