diff --git a/README.md b/README.md index 786c6ca..9ef0e26 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/src/mqtt/discovery.rs b/src/mqtt/discovery.rs index 1790e1c..6f2cb67 100644 --- a/src/mqtt/discovery.rs +++ b/src/mqtt/discovery.rs @@ -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 + ) + })?; + } } }