Add siren discovery and update readme

This commit is contained in:
QuantumEntangledAndy committed 2023-10-26 11:46:07 +07:00
1 parent a634639778
commit f56346194e
2 files changed
+64 -16

No files matched your search

+27 -16
View File
@@ -223,8 +223,13 @@ Control messages:
for normal and 3.5 for 3.5x zoom factor. This only works on cameras that support
zoom
- `/control/pir [on|off]`
- `control/wakeup (mins)` For cameras that are using `idle_disconnect` this will
- `/control/floodlight [on|off]` Turns floodlight (if equipped) on/off
- `/control/floodlight_tasks [on|off]` Turns floodlight (if equipped) tasks on/off
This is the automatic tasks such as on motion and night triggers
- `/control/wakeup (mins)` For cameras that are using `idle_disconnect` this will
force a wakeup for at least the given minutes
- `/control/siren on` Signal the siren, the message is always "on" as there is no
"off" signal for the siren
Status Messages:
@@ -243,6 +248,8 @@ Status Messages:
every camera supports the snapshot command needed for this. In such cases
there will be no `/status/preview` message. Only published when
`enable_preview` is true in the config
- `/status/floodlight_tasks` The current status of the floodlight tasks
used updated every 2s by default
Query Messages:
@@ -313,21 +320,25 @@ username = "admin"
password = "password"
uid = "ABCDEF0123456789"
[cameras.mqtt]
enable_motion = false # motion detection
# (limited battery drain since it
# is a passive listening connection)
#
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`
#
battery_update = 2000 # Number of ms between `/status/battery_level` updates
#
preview_update = 2000 # Number of ms between `/status/preview` updates
enable_motion = false # motion detection
# (limited battery drain since it
# is a passive listening connection)
#
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`
#
enable_floodlight = false # preview image in `/status/floodlight_tasks`
#
battery_update = 2000 # Number of ms between `/status/battery_level` updates
#
preview_update = 2000 # Number of ms between `/status/preview` updates
#
floodlight_update = 2000 # Number of ms between `/status/floodlight_tasks` updates
```
#### MQTT Discovery
+37
View File
@@ -28,6 +28,8 @@ pub(crate) enum Discoveries {
Pt,
#[serde(alias = "battery", alias = "power")]
Battery,
#[serde(alias = "siren", alias = "alarm")]
Siren,
}
#[derive(Debug, Clone)]
@@ -587,6 +589,41 @@ pub(crate) async fn enable_discovery(
)
})?;
}
Discoveries::Siren => {
let config_data = DiscoveryButton {
// Common across all potential features
device: device.clone(),
availability: availability.clone(),
// Identifiers
name: format!("{} Siren", friendly_name.as_str()),
unique_id: format!("neolink_{}_siren", cam_config.name),
icon: Some("mdi:restart".to_string()),
// Switch specific
command_topic: format!("neolink/{}/control/siren", cam_config.name),
payload_press: Some("on".to_string()),
};
// Each feature needs to be individually registered
mqtt.send_message_with_root_topic(
&format!(
"{}/button/{}",
discovery_config.topic, &config_data.unique_id
),
"config",
&serde_json::to_string(&config_data)
.with_context(|| "Cound not serialise discovery siren config into json")?,
true,
)
.await
.with_context(|| {
format!(
"Failed to publish sire auto-discover data on over MQTT for {}",
cam_config.name
)
})?;
}
}
}