Nursery Monitoring
Pre-requisite: The user has to be signed in to perform the following operations.
What a Baby camera watches beyond motion: crying, and — on cameras with sensors — the temperature and humidity of the room. Plus the night lamp. Sensor features are advertised through clusters; check device.hasTemperatureSensor() / hasHumiditySensor() / supportsNightLamp() before showing a control.
Cry Detection
Crying is an AI detection like person or vehicle. Switch it with the cry flag of AiDetection (under cloudAi or edgeAi on AiSettingsRequest — cameras that detect on-device advertise DeviceCluster.supportsEdgeAICry()), and mute its notifications with cryMute:
InstaVision.deviceServices.updateAiSettings(
device = device,
request = AiSettingsRequest(cloudAi = AiDetection(cry = true)),
onSuccess = { }, onError = { error -> }
)
InstaVision.deviceServices.updateNotificationSettings(
device = device,
request = Notification(cryMute = false),
onSuccess = { }, onError = { error -> }
)
A detection arrives as an event tagged EventTag.CRY.
Temperature and Humidity Alerts
Two clusters, each with an on/off switch and a high and low threshold:
Cluster (DeviceClusterTypes) | Attributes (ClusterAttributeTypes) | DeviceCluster helpers |
|---|---|---|
TemperatureSettings (0xFC23) | TemperatureAlertEnabled, HighTemperatureThreshold, LowTemperatureThreshold | supportsTemperatureAlert(), isTemperatureAlertEnabled(), highTemperatureThreshold(), lowTemperatureThreshold() |
HumiditySettings (0xFC24) | HumidityAlertEnabled, HighHumidityThreshold, LowHumidityThreshold | supportsHumidityAlert(), isHumidityAlertEnabled(), highHumidityThreshold(), lowHumidityThreshold() |
Write thresholds with updateCluster (several attributes at once) or updateClusterAttribute — see Device Clusters. Crossing a threshold raises an event tagged HIGH_TEMPERATURE / LOW_TEMPERATURE / HIGH_HUMIDITY / LOW_HUMIDITY with the reading in event.sensorReading; temperatureMute / humidityMute silence the notifications.
While a live view is running the camera also pushes readings over the stream:
viewModelScope.launch {
client.temperatureInfo.collectLatest { temperature -> /* Float?; null until the first reading */ }
}
viewModelScope.launch {
client.humidityInfo.collectLatest { humidity -> /* Float?; null until the first non-zero reading */ }
}
The display unit is a space setting: Space.settings?.temperatureUnit holds TemperatureUnit.value ("C" / "F", default "F").
Night Lamp
The NightLampSettings cluster (0xFC25) has two attributes, NightLampEnabled and NightLampBrightness. DeviceCluster.isNightLampEnabled() reads the switch and nightLampInfo() returns a ClusterValueProperty with the brightness value and its min / max / step. Write them with the cluster APIs above.