Alarm
in package
implements
AlarmInterface
Provides an interface for managing the alarms on the network.
Table of Contents
Interfaces
- AlarmInterface
- Provides an interface for managing the alarms on the network.
Properties
- $attributes : array<string, string>
- $days : array<int, int>
- $id : string
- $network : NetworkInterface
Methods
- __construct() : mixed
- Create an instance of the Alarm class.
- activate() : $this
- Make the alarm active.
- daily() : $this|bool
- Check or set whether this alarm runs every day or not.
- deactivate() : $this
- Make the alarm inactive.
- delete() : void
- Delete this alarm.
- getDuration() : TimeInterface
- Get the duration of the alarm.
- getFrequency() : int
- Get the frequency of the alarm.
- getFrequencyDescription() : string
- Get the frequency of the alarm as a human readable description.
- getId() : int
- Get the id of the alarm.
- getMusic() : UriInterface
- Get the music that will be played when this alarm goes off.
- getRepeat() : bool
- Check if repeat is active.
- getRoom() : string
- Get the room of the alarm.
- getShuffle() : bool
- Check if shuffle is active.
- getSpeaker() : SpeakerInterface
- Get the speaker of the alarm.
- getTime() : TimeInterface
- Get the start time of the alarm.
- getVolume() : int
- Get the volume of the alarm.
- isActive() : bool
- Check if the alarm is active.
- once() : $this|bool
- Check or set whether this alarm is a one time only alarm.
- onFriday() : $this|bool
- Check or set whether this alarm is active on fridays.
- onMonday() : $this|bool
- Check or set whether this alarm is active on mondays.
- onSaturday() : $this|bool
- Check or set whether this alarm is active on saturdays.
- onSunday() : $this|bool
- Check or set whether this alarm is active on sundays.
- onThursday() : $this|bool
- Check or set whether this alarm is active on thursdays.
- onTuesday() : $this|bool
- Check or set whether this alarm is active on tuesdays.
- onWednesday() : $this|bool
- Check or set whether this alarm is active on wednesdays.
- setDuration() : $this
- Set the duration of the alarm.
- setFrequency() : $this
- Set the frequency of the alarm.
- setMusic() : AlarmInterface
- Set the music that will be played when this alarm goes off.
- setRepeat() : $this
- Turn repeat mode on or off.
- setRoom() : $this
- Set the room of the alarm.
- setShuffle() : $this
- Turn shuffle mode on or off.
- setSpeaker() : $this
- Set the speaker of the alarm.
- setTime() : $this
- Set the start time of the alarm.
- setVolume() : $this
- Set the volume of the alarm.
- getPlayMode() : bool
- Get a particular PlayMode.
- onHandler() : $this|bool
- Check or set whether this alarm is active on a particular day.
- save() : $this
- Update the alarm with the current instance settings.
- setPlayMode() : $this
- Set a particular PlayMode.
- soap() : SoapResponse
- Send a soap request to the speaker for this alarm.
Properties
$attributes
protected
array<string, string>
$attributes
The attributes of the alarm
$days
protected
array<int, int>
$days
= [0 => \duncan3dc\Sonos\Interfaces\AlarmInterface::SUNDAY, 1 => \duncan3dc\Sonos\Interfaces\AlarmInterface::MONDAY, 2 => \duncan3dc\Sonos\Interfaces\AlarmInterface::TUESDAY, 3 => \duncan3dc\Sonos\Interfaces\AlarmInterface::WEDNESDAY, 4 => \duncan3dc\Sonos\Interfaces\AlarmInterface::THURSDAY, 5 => \duncan3dc\Sonos\Interfaces\AlarmInterface::FRIDAY, 6 => \duncan3dc\Sonos\Interfaces\AlarmInterface::SATURDAY]
An mapping of php day values to our day constants.
$id
protected
string
$id
The unique id of the alarm
$network
protected
NetworkInterface
$network
A Network instance this alarm is from.
Methods
__construct()
Create an instance of the Alarm class.
public
__construct(ElementInterface $xml, NetworkInterface $network) : mixed
Parameters
- $xml : ElementInterface
-
The xml element with the relevant attributes
- $network : NetworkInterface
-
A Network instance this alarm is from
activate()
Make the alarm active.
public
activate() : $this
Return values
$thisdaily()
Check or set whether this alarm runs every day or not.
public
daily([bool|null $set = null ]) : $this|bool
Parameters
- $set : bool|null = null
-
Set this alarm to be active every day
Return values
$this|bool —Returns true/false when checking, or itself when setting
deactivate()
Make the alarm inactive.
public
deactivate() : $this
Return values
$thisdelete()
Delete this alarm.
public
delete() : void
getDuration()
Get the duration of the alarm.
public
getDuration() : TimeInterface
Return values
TimeInterfacegetFrequency()
Get the frequency of the alarm.
public
getFrequency() : int
The result is an integer which can be compared using the bitwise operators and the class constants for each day. If the alarm is a one time only alarm then it will not match any of the day constants, but will be equal to the class constant ONCE.
Return values
intgetFrequencyDescription()
Get the frequency of the alarm as a human readable description.
public
getFrequencyDescription() : string
Return values
stringgetId()
Get the id of the alarm.
public
getId() : int
Return values
intgetMusic()
Get the music that will be played when this alarm goes off.
public
getMusic() : UriInterface
Tags
Return values
UriInterfacegetRepeat()
Check if repeat is active.
public
getRepeat() : bool
Return values
boolgetRoom()
Get the room of the alarm.
public
getRoom() : string
Return values
stringgetShuffle()
Check if shuffle is active.
public
getShuffle() : bool
Return values
boolgetSpeaker()
Get the speaker of the alarm.
public
getSpeaker() : SpeakerInterface
Return values
SpeakerInterfacegetTime()
Get the start time of the alarm.
public
getTime() : TimeInterface
Return values
TimeInterfacegetVolume()
Get the volume of the alarm.
public
getVolume() : int
Return values
intisActive()
Check if the alarm is active.
public
isActive() : bool
Return values
boolonce()
Check or set whether this alarm is a one time only alarm.
public
once([bool|null $set = null ]) : $this|bool
Parameters
- $set : bool|null = null
-
Set this alarm to be a one time only alarm
Return values
$this|bool —Returns true/false when checking, or itself when setting
onFriday()
Check or set whether this alarm is active on fridays.
public
onFriday([bool|null $set = null ]) : $this|bool
Parameters
- $set : bool|null = null
-
Set this alarm to be active or not on fridays
Return values
$this|bool —Returns true/false when checking, or itself when setting
onMonday()
Check or set whether this alarm is active on mondays.
public
onMonday([bool|null $set = null ]) : $this|bool
Parameters
- $set : bool|null = null
-
Set this alarm to be active or not on mondays
Return values
$this|bool —Returns true/false when checking, or itself when setting
onSaturday()
Check or set whether this alarm is active on saturdays.
public
onSaturday([bool|null $set = null ]) : $this|bool
Parameters
- $set : bool|null = null
-
Set this alarm to be active or not on saturdays
Return values
$this|bool —Returns true/false when checking, or itself when setting
onSunday()
Check or set whether this alarm is active on sundays.
public
onSunday([bool|null $set = null ]) : $this|bool
Parameters
- $set : bool|null = null
-
Set this alarm to be active or not on sundays
Return values
$this|bool —Returns true/false when checking, or itself when setting
onThursday()
Check or set whether this alarm is active on thursdays.
public
onThursday([bool|null $set = null ]) : $this|bool
Parameters
- $set : bool|null = null
-
Set this alarm to be active or not on thursdays
Return values
$this|bool —Returns true/false when checking, or itself when setting
onTuesday()
Check or set whether this alarm is active on tuesdays.
public
onTuesday([bool|null $set = null ]) : $this|bool
Parameters
- $set : bool|null = null
-
Set this alarm to be active or not on tuesdays
Return values
$this|bool —Returns true/false when checking, or itself when setting
onWednesday()
Check or set whether this alarm is active on wednesdays.
public
onWednesday([bool|null $set = null ]) : $this|bool
Parameters
- $set : bool|null = null
-
Set this alarm to be active or not on wednesdays
Return values
$this|bool —Returns true/false when checking, or itself when setting
setDuration()
Set the duration of the alarm.
public
setDuration(TimeInterface $duration) : $this
Parameters
- $duration : TimeInterface
-
The duration of the alarm
Return values
$thissetFrequency()
Set the frequency of the alarm.
public
setFrequency(int $frequency) : $this
Parameters
- $frequency : int
-
The integer representing the frequency (using the bitwise class constants)
Return values
$thissetMusic()
Set the music that will be played when this alarm goes off.
public
setMusic(UriInterface $uri) : AlarmInterface
Parameters
- $uri : UriInterface
Tags
Return values
AlarmInterfacesetRepeat()
Turn repeat mode on or off.
public
setRepeat(bool $repeat) : $this
Parameters
- $repeat : bool
-
Whether repeat should be on or not
Return values
$thissetRoom()
Set the room of the alarm.
public
setRoom(string $uuid) : $this
Parameters
- $uuid : string
-
The unique id of the room (eg, RINCON_B8E93758723601400)
Return values
$thissetShuffle()
Turn shuffle mode on or off.
public
setShuffle(bool $shuffle) : $this
Parameters
- $shuffle : bool
-
Whether shuffle should be on or not
Return values
$thissetSpeaker()
Set the speaker of the alarm.
public
setSpeaker(SpeakerInterface $speaker) : $this
Parameters
- $speaker : SpeakerInterface
-
The speaker to attach this alarm to
Return values
$thissetTime()
Set the start time of the alarm.
public
setTime(TimeInterface $time) : $this
Parameters
- $time : TimeInterface
-
The time to set the alarm for
Return values
$thissetVolume()
Set the volume of the alarm.
public
setVolume(int $volume) : $this
Parameters
- $volume : int
-
The volume of the alarm
Return values
$thisgetPlayMode()
Get a particular PlayMode.
protected
getPlayMode(string $type) : bool
Parameters
- $type : string
-
The play mode attribute to get
Return values
boolonHandler()
Check or set whether this alarm is active on a particular day.
protected
onHandler(int $day[, bool|null $set = null ]) : $this|bool
Parameters
- $day : int
-
Which day to check/set
- $set : bool|null = null
-
Set this alarm to be active or not on the specified day
Return values
$this|bool —Returns true/false when checking, or itself when setting
save()
Update the alarm with the current instance settings.
protected
save() : $this
Return values
$thissetPlayMode()
Set a particular PlayMode.
protected
setPlayMode(string $type, bool $value) : $this
Parameters
- $type : string
-
The play mode attribute to update
- $value : bool
-
The value to set the attribute to
Return values
$thissoap()
Send a soap request to the speaker for this alarm.
protected
soap(string $service, string $action[, array<string, string|int|bool> $params = [] ]) : SoapResponse
Parameters
- $service : string
-
The service to send the request to
- $action : string
-
The action to call
- $params : array<string, string|int|bool> = []
-
The parameters to pass