diff --git a/Cargo.toml b/Cargo.toml index 16378bf..ee47392 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -15,4 +15,5 @@ license = "Apache-2.0" futures = "0.3" reqwest = { version = "0.10", features = ["json"] } serde = { version = "1.0", features = ["derive"] } +serde_json = "1.0" chrono = "0.4" diff --git a/src/lib.rs b/src/lib.rs index 769177f..e7c3450 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -61,8 +61,9 @@ pub struct LongLivedToken { impl HomeAssistantAPI { pub fn new(instance_url: String, client_id: String) -> Arc> { let token = Token::None; + let http_instance_url = format!("http://{}", instance_url); let ret = Arc::new(RwLock::new(Self { - instance_url, + instance_url: http_instance_url, token, client_id, self_reference: Weak::new(), diff --git a/src/rest.rs b/src/rest.rs index 7e20a91..060a881 100644 --- a/src/rest.rs +++ b/src/rest.rs @@ -318,7 +318,6 @@ impl Rest { drop(read_lock); let response = request.send().await?; - let resp_json: Vec = response.json().await?; Ok(resp_json) diff --git a/src/types.rs b/src/types.rs index 7dff448..c6a15ee 100644 --- a/src/types.rs +++ b/src/types.rs @@ -1,5 +1,5 @@ use serde::{Deserialize, Serialize}; - +use serde_json::Value; #[derive(Serialize, Deserialize, Debug)] pub struct HaEntityAttribute { pub friendly_name: Option, @@ -141,10 +141,9 @@ pub struct ServiceObject { #[derive(Serialize, Deserialize, Debug)] pub struct StateObject { - pub attributes: std::collections::HashMap, + pub attributes: std::collections::HashMap, pub entity_id: String, pub last_changed: String, - pub last_updated: Option, pub state: String, }