From 58ade33c424e042b89cf69518a3c7af71a5f87d1 Mon Sep 17 00:00:00 2001 From: Dreaded_X Date: Mon, 24 Apr 2023 04:44:19 +0200 Subject: [PATCH] Also moved ntfy into devices as it is a quasi device --- src/devices.rs | 2 ++ src/{ => devices}/ntfy.rs | 4 ---- src/event.rs | 5 ++--- src/lib.rs | 1 - src/main.rs | 3 +-- 5 files changed, 5 insertions(+), 10 deletions(-) rename src/{ => devices}/ntfy.rs (97%) diff --git a/src/devices.rs b/src/devices.rs index e9d5111..3350bb8 100644 --- a/src/devices.rs +++ b/src/devices.rs @@ -5,6 +5,7 @@ mod hue_bridge; mod ikea_outlet; mod kasa_outlet; mod light_sensor; +mod ntfy; mod presence; mod wake_on_lan; @@ -15,6 +16,7 @@ pub use self::hue_bridge::{HueBridge, HueBridgeConfig}; pub use self::ikea_outlet::IkeaOutlet; pub use self::kasa_outlet::KasaOutlet; pub use self::light_sensor::{LightSensor, LightSensorConfig}; +pub use self::ntfy::{Notification, Ntfy}; pub use self::presence::{Presence, PresenceConfig, DEFAULT_PRESENCE}; pub use self::wake_on_lan::WakeOnLAN; diff --git a/src/ntfy.rs b/src/devices/ntfy.rs similarity index 97% rename from src/ntfy.rs rename to src/devices/ntfy.rs index 7df10d8..5eba3da 100644 --- a/src/ntfy.rs +++ b/src/devices/ntfy.rs @@ -3,7 +3,6 @@ use std::collections::HashMap; use async_trait::async_trait; use serde::Serialize; use serde_repr::*; -use tokio::sync::mpsc; use tracing::{debug, error, warn}; use crate::{ @@ -13,9 +12,6 @@ use crate::{ event::{OnNotification, OnPresence}, }; -pub type Sender = mpsc::Sender; -pub type Receiver = mpsc::Receiver; - #[derive(Debug)] pub struct Ntfy { base_url: String, diff --git a/src/event.rs b/src/event.rs index c9f8b67..46fa367 100644 --- a/src/event.rs +++ b/src/event.rs @@ -4,15 +4,14 @@ use tokio::sync::mpsc; use impl_cast::device_trait; -use crate::ntfy; -use crate::ntfy::Notification; +use crate::devices::Notification; #[derive(Debug, Clone)] pub enum Event { MqttMessage(Publish), Darkness(bool), Presence(bool), - Ntfy(ntfy::Notification), + Ntfy(Notification), } pub type Sender = mpsc::Sender; diff --git a/src/lib.rs b/src/lib.rs index 413d9b6..e4a5239 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -7,4 +7,3 @@ pub mod error; pub mod event; pub mod messages; pub mod mqtt; -pub mod ntfy; diff --git a/src/main.rs b/src/main.rs index 749119c..67e4b70 100644 --- a/src/main.rs +++ b/src/main.rs @@ -9,10 +9,9 @@ use automation::{ auth::{OpenIDConfig, User}, config::Config, devices, - devices::{DebugBridge, HueBridge, LightSensor, Presence}, + devices::{DebugBridge, HueBridge, LightSensor, Ntfy, Presence}, error::ApiError, mqtt, - ntfy::Ntfy, }; use dotenvy::dotenv; use futures::future::join_all;