diff --git a/src/config.rs b/src/config.rs index d4905c5..6259d84 100644 --- a/src/config.rs +++ b/src/config.rs @@ -116,7 +116,7 @@ pub struct MqttDeviceConfig { pub topic: String, } -#[derive(Debug, Clone, Deserialize)] +#[derive(Debug, Clone, Deserialize, PartialEq, Eq)] pub enum OutletType { Outlet, Kettle, diff --git a/src/devices/ikea_outlet.rs b/src/devices/ikea_outlet.rs index 4a56722..5a34fea 100644 --- a/src/devices/ikea_outlet.rs +++ b/src/devices/ikea_outlet.rs @@ -112,8 +112,9 @@ impl OnMqtt for IkeaOutlet { #[async_trait] impl OnPresence for IkeaOutlet { async fn on_presence(&mut self, presence: bool) { - // Turn off the outlet when we leave the house - if !presence { + // Turn off the outlet when we leave the house (Not if it is a battery charger) + debug!(id = self.identifier, "{:?}", self.outlet_type); + if !presence && self.outlet_type != OutletType::Charger { debug!(id = self.identifier, "Turning device off"); self.set_on(false).ok(); }