Add config options for mqtt threads
This commit is contained in:
3 files changed
+43
-5
No files matched your search
@@ -148,6 +148,17 @@ pub(crate) struct MqttConfig {
|
||||
|
||||
#[serde(default)]
|
||||
pub(crate) client_auth: Option<(std::path::PathBuf, std::path::PathBuf)>,
|
||||
|
||||
#[serde(default = "default_true")]
|
||||
pub(crate) enable_motion: bool,
|
||||
#[serde(default = "default_true")]
|
||||
pub(crate) enable_pings: bool,
|
||||
#[serde(default = "default_true")]
|
||||
pub(crate) enable_light: bool,
|
||||
#[serde(default = "default_true")]
|
||||
pub(crate) enable_battery: bool,
|
||||
#[serde(default = "default_true")]
|
||||
pub(crate) enable_preview: bool,
|
||||
|
||||
#[serde(default)]
|
||||
pub(crate) discovery: Option<MqttDiscoveryConfig>,
|
||||
@@ -170,6 +181,10 @@ fn validate_mqtt_config(config: &MqttConfig) -> Result<(), ValidationError> {
|
||||
}
|
||||
}
|
||||
|
||||
const fn default_true() -> bool {
|
||||
true
|
||||
}
|
||||
|
||||
fn default_mqtt() -> Option<MqttConfig> {
|
||||
None
|
||||
}
|
||||
|
||||
@@ -237,7 +237,7 @@ impl EventCamThread {
|
||||
val = async {
|
||||
info!("{}: Listening to Camera Motion", camera_config.name);
|
||||
motion_thread.run().await
|
||||
} => {
|
||||
}, if camera_config.mqtt.as_ref().expect("Should have an mqtt config at this point").enable_motion => {
|
||||
if let Err(e) = val {
|
||||
error!("Motion thread aborted: {:?}", e);
|
||||
Err(e)
|
||||
@@ -249,7 +249,7 @@ impl EventCamThread {
|
||||
val = async {
|
||||
debug!("{}: Starting Pings", camera_config.name);
|
||||
keepalive_thread.run().await
|
||||
} => {
|
||||
}, if camera_config.mqtt.as_ref().expect("Should have an mqtt config at this point").enable_pings => {
|
||||
if let Err(e) = val {
|
||||
debug!("Ping thread aborted: {:?}", e);
|
||||
Err(e)
|
||||
@@ -261,7 +261,7 @@ impl EventCamThread {
|
||||
val = async {
|
||||
info!("{}: Listening to FloodLight Status", camera_config.name);
|
||||
flight_thread.run().await
|
||||
} => {
|
||||
}, if camera_config.mqtt.as_ref().expect("Should have an mqtt config at this point").enable_light => {
|
||||
if let Err(e) = val {
|
||||
error!("FloodLight thread aborted: {:?}", e);
|
||||
Err(e)
|
||||
@@ -273,7 +273,7 @@ impl EventCamThread {
|
||||
val = async {
|
||||
info!("{}: Updating Preview", camera_config.name);
|
||||
snap_thread.run().await
|
||||
} => {
|
||||
}, if camera_config.mqtt.as_ref().expect("Should have an mqtt config at this point").enable_preview => {
|
||||
if let Err(e) = val {
|
||||
error!("Snap thread aborted: {:?}", e);
|
||||
Err(e)
|
||||
@@ -285,7 +285,7 @@ impl EventCamThread {
|
||||
val = async {
|
||||
info!("{}: Updating Battery Level", camera_config.name);
|
||||
battery_thread.run().await
|
||||
} => {
|
||||
}, if camera_config.mqtt.as_ref().expect("Should have an mqtt config at this point").enable_battery => {
|
||||
if let Err(e) = val {
|
||||
error!("Battery thread aborted: {:?}", e);
|
||||
Err(e)
|
||||
|
||||
Reference in new issue
Block a user