Add the siren.rs

This commit is contained in:
QuantumEntangledAndy committed 2023-10-26 11:31:22 +07:00
1 parent 44ffdcc2e8
commit 45151203e2
7 files changed
+122

No files matched your search

+23
View File
@@ -1115,6 +1115,29 @@ async fn handle_mqtt_message(
.await
.with_context(|| "Failed to publish floodlight_tasks")?;
}
MqttReplyRef {
topic: "control/siren",
message: "on",
} => {
let res = camera
.run_task(|cam| {
Box::pin(async move {
cam.siren().await?;
AnyResult::Ok(())
})
})
.await;
let reply = if let Err(e) = res {
error!("Failed to trigger siren: {:?}", e);
format!("FAIL: {e:?}")
} else {
"OK".to_string()
};
mqtt.send_message("control/siren", &reply, false)
.await
.with_context(|| "Failed to publish siren")?;
}
MqttReplyRef {
topic: "query/battery",
..