Sensor Readings
Note: The camera should have already started streaming LiveView before making any interactions
A camera with environmental sensors reports them over the live view’s data channel, alongside the Wi-Fi signal. The SDK asks for them the moment the channel opens and publishes each reading, so there is nothing to poll and no request to make yourself.
Contents
Temperature and humidity
Both are gated on the flags passed when the live view object was created — see Setting Up. Pass them from the camera’s clusters:
let liveViewObject = LiveViewObjectStore.objectFor(
.liveView,
spaceId: spaceId,
deviceId: deviceId,
wakeup: device.isMcuSupported,
supportRSSI: clusters.supportRSSI,
supportTemperature: clusters.supportsTemperature,
supportHumidity: clusters.supportsHumidity
)
When the data channel opens the SDK sends a request for each flag that is set, and the camera’s replies arrive as published values:
view
.onReceive(liveViewObject.$temperature.receive(on: DispatchQueue.main), perform: { value in
guard let value else { return } // nil until the first reading arrives
self.temperature = value
})
.onReceive(liveViewObject.$humidity.receive(on: DispatchQueue.main), perform: { value in
guard let value else { return }
self.humidity = value
})
Both are Int?, both start as nil, and both stay nil if the flag was not set or the camera never answers — so render a placeholder rather than a zero. Humidity is a percentage. For temperature, label the reading with SpaceSettings.temperatureUnit, the unit the user picked for the space, rather than assuming one.
The readings arrive on the data channel’s own queue. Hop to the main queue before using them, as above, and expect them to refresh only while the stream is up — a value from a closed session is stale, so clear it on disconnect.
supportsTemperatureandsupportsHumiditysay the camera has the sensor. The alert thresholds stored in the same clusters —highTemperature,lowHumidityand the rest — are settings, not readings; see the Cluster Catalogue.
What travels the data channel
Everything the app and camera exchange during a session goes over the same WebRTC data channel. It is worth knowing what is on it, because none of it works before onDataChannelOpen fires:
| What | API | Direction |
|---|---|---|
| Wi-Fi signal | $rssi — see RSSI | Camera → app, every 10 s |
| Temperature, humidity | $temperature, $humidity | Camera → app, on request |
| Siren | startManualSiren(), stopManualSiren() — see Alarm & Deterrence | App → camera |
| Two-way calling | sendTwoWayCallEventId(callEventId:), sendAcceptedTwoWayCall(), sendDisconnectTwoWayCall() — see Two-Way Calling | App → camera |
| Playback control | play(), pause(), seekToTime(time:), mediaInfo(startTime:endTime:) — see SD Card Playback | App → camera |
| Wake-up | sendWakeupMessageOnLiveStart(), sendWakeupMessageOnPlaybackStart() | App → camera |
Two things follow from that. A command sent before the channel is open is dropped, so gate any control you expose on the channel being ready:
liveViewObject.onDataChannelOpen = { [weak self] open in
DispatchQueue.main.async { self?.controlsEnabled = open }
}
And anything the SDK does not decode itself is handed to you raw, for messages your firmware adds that the SDK has no model for:
liveViewObject.onDataChannelMessage = { data in
// RSSI, temperature and humidity are consumed by the SDK and never reach here.
}