Siren

Pre-requisite: The LiveView should be already started before making any interactions.

Cameras with a manual siren can sound it on demand over the data channel of a running LiveStreamClient.

Starting and stopping

The siren works as press-and-hold — start it when the button goes down and stop it when the button comes up:

client.startSiren()
client.stopSiren()

startSiren() cancels any siren already running before starting a new one, so a repeated press does not stack up two loops.


What it actually sends

startSiren() does not fire once. It asks the camera for a 3-second siren and repeats that request every 3 seconds until it is stopped, which is what makes press-and-hold work. Nothing else ends the loop, so every startSiren() needs a matching stopSiren() on release — stopSiren() cancels the loop and sends the camera an explicit stop.

Closing the client also tears the loop down, so a siren cannot outlive the stream it was started on.


Auto-disconnect

startSiren() suspends the stream’s auto-disconnect timer and stopSiren() restores it. Skipping stopSiren() therefore leaves the timer suspended as well as the siren sounding, and an unattended stream drains a battery camera — see Setting Up for autoDisconnectAfter.


Availability and gating

Only cameras that advertise the manual siren can sound one:

if (device.supportsManualSiren()) {
  // show the siren button
}

The helper reads the camera’s clusters, so it returns false on flat-settings cameras (device.supportsCluster() is false). DeviceCluster.supportsManualSiren() gives the same answer from a cluster fetched with getDeviceCluster.

Gate the press itself on the stream being live. Unlike the sensor polling loops, the siren loop does not check whether the data channel is open, and a command sent on a closed channel is dropped without an error. Enable the button only once client.status is StreamStatus.STARTED, which is emitted when the first frame renders.



This site uses Just the Docs, a documentation theme for Jekyll.