Add config options for mqtt threads
This commit is contained in:
3 files changed
+43
-5
No files matched your search
@@ -209,6 +209,7 @@ Status Messages:
|
||||
- `/status/motion` Contains the motion detection alarm status. `on` for motion and `off` for still
|
||||
- `/status/ptz/preset` Sent in reply to a `/query/ptz/preset` an XML encoded version of the
|
||||
PTZ presets
|
||||
- `/status/preview` a base64 encoded camera image updated every 0.5s
|
||||
|
||||
Query Messages:
|
||||
|
||||
@@ -216,6 +217,28 @@ Query Messages:
|
||||
- `/query/pir` Request that the camera reports its pir status
|
||||
- `/query/ptz/preset` Request that the camera reports its PTZ presets
|
||||
|
||||
### MQTT Disable Features
|
||||
|
||||
Certain features like preview and motion detection may not be desired
|
||||
you can disable them by them with the following config options.
|
||||
Disabling these may help to conserve battery
|
||||
|
||||
```toml
|
||||
enable_motion = false # motion detection
|
||||
# (limited battery drain since it
|
||||
# is a passive listening connection)
|
||||
|
||||
enable_pings = false # keep alive pings that keep the camera connected
|
||||
|
||||
enable_light = false # flood lights only avaliable on some camera
|
||||
# (limited battery drain since it
|
||||
# is a passive listening connection)
|
||||
|
||||
enable_battery = false # battery updates in `/status/battery_level`
|
||||
|
||||
enable_preview = false # preview image in `/status/preview`
|
||||
```
|
||||
|
||||
#### MQTT Discovery
|
||||
|
||||
[MQTT Discovery](https://www.home-assistant.io/integrations/mqtt/#mqtt-discovery) is partially supported.
|
||||
|
||||
@@ -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