From 7cfaa680f07db321a4be5c78c8b3e28c6c65dc08 Mon Sep 17 00:00:00 2001 From: Avii Date: Sun, 9 Aug 2026 17:10:45 +0200 Subject: [PATCH] 1786288245 --- dashboard/src/error.rs | 3 ++- dashboard/src/home_assistant.rs | 17 ++++------------- dashboard/src/main.rs | 1 + 3 files changed, 7 insertions(+), 14 deletions(-) diff --git a/dashboard/src/error.rs b/dashboard/src/error.rs index 15cefce..fb7402d 100644 --- a/dashboard/src/error.rs +++ b/dashboard/src/error.rs @@ -1,3 +1,4 @@ +#[allow(clippy::all)] #[derive(Debug, thiserror::Error)] pub enum AppError { #[error("HASS_URL is not set")] @@ -16,7 +17,7 @@ pub enum AppError { SlintPlatform(#[from] slint::PlatformError), #[error(transparent)] - HomeAssistant(#[from] Box), + HomeAssistant(#[from] hass_rs::HassError), #[error("Entity {0} not found")] NoEntity(String), diff --git a/dashboard/src/home_assistant.rs b/dashboard/src/home_assistant.rs index 383dfc1..4e9b0fa 100644 --- a/dashboard/src/home_assistant.rs +++ b/dashboard/src/home_assistant.rs @@ -24,7 +24,6 @@ async fn handle_command( client .call_service("light".into(), service.into(), Some(payload)) .await - .map_err(Box::new) .map_err(Into::into) } else { Err(AppError::NoEntity(entity_id)) @@ -39,7 +38,6 @@ async fn handle_command( client .call_service("climate".into(), service.into(), Some(payload)) .await - .map_err(Box::new) .map_err(Into::into) } else { Err(AppError::NoEntity(entity_id)) @@ -56,7 +54,6 @@ async fn handle_command( client .call_service("climate".into(), "set_temperature".into(), Some(payload)) .await - .map_err(Box::new) .map_err(Into::into) } } @@ -86,14 +83,11 @@ pub async fn hass( let url = format!("{}://{}/api/websocket", scheme, url.authority()); - let mut client = HassClient::new(&url).await.map_err(Box::new)?; - client - .auth_with_longlivedtoken(&hass_token) - .await - .map_err(Box::new)?; + let mut client = HassClient::new(&url).await?; + client.auth_with_longlivedtoken(&hass_token).await?; let mut state = HashMap::::new(); - let states = client.get_states().await.map_err(Box::new)?; + let states = client.get_states().await?; states.iter().for_each(|entity| { state.insert(entity.entity_id.clone(), entity.clone()); @@ -103,10 +97,7 @@ pub async fn hass( initial_state.sort_by(|a, b| a.entity_id.cmp(&b.entity_id)); s2c_tx.send(EventMessage::InitialState(initial_state)).ok(); - let mut event_receiver = client - .subscribe_event("state_changed") - .await - .map_err(Box::new)?; + let mut event_receiver = client.subscribe_event("state_changed").await?; loop { tokio::select! { diff --git a/dashboard/src/main.rs b/dashboard/src/main.rs index 566c879..dc3973c 100644 --- a/dashboard/src/main.rs +++ b/dashboard/src/main.rs @@ -13,6 +13,7 @@ use crate::{ messages::{CommandMessage, EventMessage}, }; +#[allow(clippy::result_large_err)] #[tokio::main] async fn main() -> Result<(), AppError> { dotenvy::dotenv().ok();