Handle turning off devices when away through lua

This commit is contained in:
2025-08-31 22:10:41 +02:00
parent c6353663df
commit ee6b74a91c
5 changed files with 31 additions and 54 deletions

View File

@@ -4,7 +4,6 @@ use std::str::Utf8Error;
use async_trait::async_trait;
use automation_lib::device::{Device, LuaDeviceCreate};
use automation_lib::event::OnPresence;
use automation_macro::{LuaDevice, LuaDeviceConfig};
use bytes::{Buf, BufMut};
use google_home::errors::{self, DeviceError};
@@ -13,7 +12,7 @@ use serde::{Deserialize, Serialize};
use thiserror::Error;
use tokio::io::{AsyncReadExt, AsyncWriteExt};
use tokio::net::TcpStream;
use tracing::{debug, trace};
use tracing::trace;
#[derive(Debug, Clone, LuaDeviceConfig)]
pub struct Config {
@@ -276,13 +275,3 @@ impl OnOff for KasaOutlet {
.or(Err(DeviceError::TransientError.into()))
}
}
#[async_trait]
impl OnPresence for KasaOutlet {
async fn on_presence(&self, presence: bool) {
if !presence {
debug!(id = Device::get_id(self), "Turning device off");
self.set_on(false).await.ok();
}
}
}