Charger does not get turned off when leaving the house
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Dreaded_X 2023-03-20 17:47:42 +01:00
parent 07563a6d30
commit 1a9d12b1f3
Signed by: Dreaded_X
GPG Key ID: FA5F485356B0D2D4
2 changed files with 4 additions and 3 deletions

View File

@ -116,7 +116,7 @@ pub struct MqttDeviceConfig {
pub topic: String, pub topic: String,
} }
#[derive(Debug, Clone, Deserialize)] #[derive(Debug, Clone, Deserialize, PartialEq, Eq)]
pub enum OutletType { pub enum OutletType {
Outlet, Outlet,
Kettle, Kettle,

View File

@ -112,8 +112,9 @@ impl OnMqtt for IkeaOutlet {
#[async_trait] #[async_trait]
impl OnPresence for IkeaOutlet { impl OnPresence for IkeaOutlet {
async fn on_presence(&mut self, presence: bool) { async fn on_presence(&mut self, presence: bool) {
// Turn off the outlet when we leave the house // Turn off the outlet when we leave the house (Not if it is a battery charger)
if !presence { debug!(id = self.identifier, "{:?}", self.outlet_type);
if !presence && self.outlet_type != OutletType::Charger {
debug!(id = self.identifier, "Turning device off"); debug!(id = self.identifier, "Turning device off");
self.set_on(false).ok(); self.set_on(false).ok();
} }