Alarm Module


The Alarm Module is a siren. When activated it plays a sound once a second for a set time, and its lamp glows and lights up the area.
How to get it
Section titled “How to get it”
Alarm ModulePlace and connect
Section titled “Place and connect”Place it where it should be heard and link it to a Network Repeater. It looks the same from every side.
Configure
Section titled “Configure”| Setting | Meaning |
|---|---|
| Sound | bell, pling, chime or bass. Default bell. |
| Volume | 10 to 100. Default 60. |
| Seconds | How long one activation lasts, 1 to 60. Default 10. |
| Save, Test, Stop | Save the settings, sound it, or silence it. |
Programs can change the same settings with configure, using Sound.BELL and the other constants.
Drive programs
Section titled “Drive programs”Yes: device.activate(), device.deactivate() and the other methods. An alarm with its own program can listen to a
detector on the same network; see the Guard alarm.
Program API
Section titled “Program API”Getting it
Section titled “Getting it”alarms.named(alias)
Refer to an Alarm Module by its name. Use it in a constant, then handle its events with on NAME.event(...).
const siren = alarms.named("siren")alarms.from(alias)
Resolve an alarm module by name.
siren, err = alarms.from("siren")Methods
Section titled “Methods”Properties: siren.connected, siren.id, siren.kind, siren.name. They are read-only.
siren.activate()
Sound the alarm for its configured duration, renewing it when already active.
ok, err = siren.activate()siren.active()
True while the alarm is sounding.
on, err = siren.active()siren.configure(sound, volume, seconds)
Set sound (bell, pling, chime or bass), volume (10–100) and duration in seconds (1–60). Applies from the next activation or sound.
ok, err = siren.configure("bell", 80, 20)siren.deactivate()
Silence the alarm.
ok, err = siren.deactivate()siren.settings()
Read sound, volume, seconds, active and remaining seconds.
info, err = siren.settings()Events
Section titled “Events”| Event | When it runs |
|---|---|
activated | Runs when the alarm starts sounding. |
deactivated | Runs when the alarm is silenced. |
finished | Runs when the alarm stops after its configured duration. |
connected | Runs when the device becomes reachable, for example after its area loads. |
disconnected | Runs when the device stops being reachable: unloaded, unlinked or removed. |
programStarted | Runs when the device's own program starts. |
programStopped | Runs when the device's own program stops. |
programFailed(message) | Runs when the device's own program stops on an error. |
Limits and behavior
Section titled “Limits and behavior”- Activating an alarm that is already sounding restarts its time.
- An alarm stops when its time ends, when it is silenced, when its area unloads or when it is broken. It does not resume after a restart.
- A server lets at most 64 alarms sound at once; more fail with
alarm.limit.
Example
Section titled “Example”const siren = alarms.named("siren")
on startup { siren.configure(Sound.CHIME, 80, 5)}
on siren.finished { print("The alarm went quiet")}