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 supportsTemperature, supportsHumidity and supportsNightLamp on CameraClustersModel before showing a control.


Cry Detection

Crying is an AI detection like person or vehicle. Switch it with the cry flag of CloudAiDetections — under cloudAi or edgeAi on EventDetectionSettingsRequest — and mute its notifications with cryMute:

Factory.deviceService.updateDeviceCloudAISettings(
    spaceId: spaceId, deviceId: deviceId, wakeup: false,
    request: EventDetectionSettingsRequest(cloudAi: CloudAiDetections(cry: true))
)
Factory.deviceService.updateDeviceCloudNotificationsSettings(
    spaceId: spaceId, deviceId: deviceId, wakeup: false,
    request: NotificationSettingsRequest(cryMute: false)
)

A detection arrives as an event tagged EventTag.cry — see Device Cloud Settings and Events.


Temperature and Humidity Alerts

Two clusters, each with an on/off switch and a high and low threshold:

Cluster Attributes
ClustersType.temperature temperatureAlertEnabled, highTemperature, lowTemperature
ClustersType.humidity humidityAlertEnabled, highHumidity, lowHumidity

CameraClustersModel decodes them, so a settings screen does not need to walk the attributes:

clusters.isTemperatureAlertEnabled        // Bool?
clusters.highTemperatureThreshold          // Int?  – configured limit in °F
clusters.highTemperatureValue              // Int?  – upper bound of the settable range  in °F
clusters.lowTemperatureValue               // Int?  – lower bound in °F
clusters.highTemperatureDefaultValue       // Int?
// …and the low / humidity counterparts

Write thresholds with updateDeviceCluster (several attributes at once) or updateDeviceClustersAttribute — see Device Clusters.

While a live view is running the camera also pushes readings over the stream; LiveViewModel publishes them as temperature and humidity (Int?), so a live-view screen can show the room without polling the clusters.

Crossing a threshold raises an event tagged highTemperature, lowTemperature, highHumidity or lowHumidity, with the reading in EventModel.sensorReading?.temperature / .humidity. The temperature and humidity flags of CloudAiDetections switch the alerts as detections; temperatureMute and humidityMute silence the notifications.


Night Lamp

The ClustersType.nightLamp cluster has two attributes, nightLampEnabled and nightLampBrightness. The brightness range comes from the camera — clusters.nightLampBrightnessMin / nightLampBrightnessMax / nightLampBrightnessDefault. Write them with the cluster APIs above:

Factory.deviceService.updateDeviceCluster(
    spaceId: spaceId,
    deviceId: deviceId,
    clusterId: ClustersType.nightLamp.clusterId,
    wakeup: device.isMcuSupported,
    request: UpdateClusterMultipleAttributeRequestModel(attributes: [
        UpdateClusterAttributeRequestModel(value: .bool(true), attributeId: ClustersAttribute.nightLampEnabled.attributeId),
        UpdateClusterAttributeRequestModel(value: .int(60), attributeId: ClustersAttribute.nightLampBrightness.attributeId)
    ])
)