Add control/floodlight_tasks

This commit is contained in:
QuantumEntangledAndy committed 2023-10-23 09:57:33 +07:00
1 parent 7d5782d2a3
commit 9ae537fb38
4 files changed
+35 -104

No files matched your search

+30
View File
@@ -1001,6 +1001,36 @@ async fn handle_mqtt_message(
.await
.with_context(|| "Failed to publish wakeup")?;
}
MqttReplyRef {
topic: "control/floodlight_tasks",
message,
} => {
let reply = match message.parse::<bool>() {
Ok(state) => {
if let Err(e) = camera
.run_task(|cam| {
Box::pin(async move {
cam.flightlight_tasks_enable(state).await?;
AnyResult::Ok(())
})
})
.await
{
format!("FAIL: {e:?}")
} else {
"OK".to_string()
}
}
Err(e) => {
error!("Failed to parse message as bool: {:?}", e);
format!("FAIL: '{message}' => {e:?}")
}
};
mqtt.send_message("control/floodlight_tasks", &reply, false)
.await
.with_context(|| "Failed to publish floodlight_tasks")?;
}
MqttReplyRef {
topic: "query/battery",
..