Python cURL (bash) JavaScript C# Java
Request:
Copy device_id = "98dc7c66-045d-49cb-a62b-4bb431b0a9fa"
noise_threshold = seam.noise_sensors.noise_thresholds.create(
device_id = device_id,
starts_daily_at = "20:00:00[America/Los_Angeles]",
ends_daily_at = "06:00:00[America/Los_Angeles]",
noise_threshold_decibels = 70
)
pprint(noise_threshold)
Response:
Copy NoiseThreshold(noise_threshold_id='1b64e4b6-4d5d-4416-acca-dc3b1cbc00cd',
device_id='98dc7c66-045d-49cb-a62b-4bb431b0a9fa',
name='builtin_quiet_hours',
noise_threshold_decibels=70,
starts_daily_at='20:00:00[America/Los_Angeles]',
ends_daily_at='06:00:00[America/Los_Angeles]',
noise_threshold_nrs=None)
Request:
Copy curl -X 'POST' \
'https://connect.getseam.com/noise_sensors/noise_thresholds/create' \
-H 'accept: application/json' \
-H 'Authorization: Bearer ${API_KEY}' \
-H 'Content-Type: application/json' \
-d '{
"device_id": "98dc7c66-045d-49cb-a62b-4bb431b0a9fa",
"starts_daily_at": "20:00:00[America/Los_Angeles]",
"ends_daily_at": "06:00:00[America/Los_Angeles]",
"noise_threshold_decibels": 70
}'
Response:
Copy {
"action_attempt": {
"status": "pending",
"action_type": "CREATE_NOISE_THRESHOLD",
"action_attempt_id": "64130fb6-94ed-4268-a7e5-ccba4165fab8",
"result": null,
"error": null
},
"ok": true
}
Request:
Copy const deviceId = "98dc7c66-045d-49cb-a62b-4bb431b0a9fa"
const noiseThresholdAttempt = await seam.noiseThresholds.create({
device_id: deviceId,
starts_daily_at: "20:00:00[America/Los_Angeles]",
ends_daily_at: "06:00:00[America/Los_Angeles]",
noise_threshold_decibels: 70
})
console.log(noiseThresholdAttempt)
Response:
Copy {
action_attempt: {
status: 'pending',
action_type: 'CREATE_NOISE_THRESHOLD',
action_attempt_id: '5e24ef90-8043-44d8-89f9-9f7ae60ec390',
result: null,
error: null
},
ok: true
}
Request:
Copy var deviceId = "98dc7c66-045d-49cb-a62b-4bb431b0a9fa";
var noiseThresholdAttempt = seam.NoiseThresholdsNoiseSensors.Create(
deviceId: deviceId,
startsDailyAt: "20:00:00[America/Los_Angeles]",
endsDailyAt: "06:00:00[America/Los_Angeles]",
noiseThresholdDecibels: 70
);
Type t = noiseThresholdAttempt.GetType();
PropertyInfo[] props = t.GetProperties();
foreach (var prop in props)
{
Console.WriteLine(prop.Name + ": " + prop.GetValue(noiseThresholdAttempt));
}
Response:
Copy Status: pending
ActionType: CREATE_NOISE_THRESHOLD
ActionAttemptId: eb611597-64d2-4b1a-995b-fb00361922c6
Result:
Error:
Request:
Copy var deviceId = "98dc7c66-045d-49cb-a62b-4bb431b0a9fa";
ActionAttempt noiseThresholdAttempt = seam.noiseSensors().noiseThresholds().create(NoiseThresholdsCreateRequest.builder()
.deviceId(deviceId)
.startsDailyAt("20:00:00[America/Los_Angeles]")
.endsDailyAt("06:00:00[America/Los_Angeles]")
.noiseThresholdDecibels(70.0)
.build());
System.out.println(noiseThresholdAttempt.getPending());
Response:
Copy Optional[{
"action_type" : "CREATE_NOISE_THRESHOLD",
"action_attempt_id" : "c954a8ec-3c9a-4f26-8966-85de45966d1b"
}]
This threshold creates a noise threshold of 70 decibels from 20:00-06:00 PST called builtin_quiet_hours
.
Once you have created a threshold, connect it to a webhook to log events.
The Seam Console displays the URL and secret for the newly-created webhook. To test your webhook, click Test your webhook .
Once you have configured your thresholds and webhooks, you can monitor events with the Seam API. The following sample shows how events look:
Copy {
"created_at": "2023-01-09T18:54:32.737Z",
"device_id": "c1296d07-3e96-4ee9-8219-3cd33a09aa37",
"event_id": "c1296d07-3e96-4ee9-8219-3cd33a09aa37",
"event_type": "noise_sensors.noise_threshold_triggered",
"minut_metadata": {},
"noise_level_decibels": 50,
"noise_level_nrs": 40,
"noise_threshold_id": "c1296d07-3e96-4ee9-8219-3cd33a09aa37",
"noise_threshold_name": "builtin_first_disturbance",
"noiseaware_metadata": {}
}