Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
3 changes: 2 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,9 @@ pub struct LongLivedToken {
impl HomeAssistantAPI {
pub fn new(instance_url: String, client_id: String) -> Arc<RwLock<Self>> {
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,
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we have to support using both http:// and ws:// schemas to the config host should be without a schema so we need to add the schema here. Open for suggestions on better locations.

token,
client_id,
self_reference: Weak::new(),
Expand Down
1 change: 0 additions & 1 deletion src/rest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,6 @@ impl Rest {

drop(read_lock);
let response = request.send().await?;

let resp_json: Vec<types::StateObject> = response.json().await?;

Ok(resp_json)
Expand Down
5 changes: 2 additions & 3 deletions src/types.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use serde::{Deserialize, Serialize};

use serde_json::Value;
#[derive(Serialize, Deserialize, Debug)]
pub struct HaEntityAttribute {
pub friendly_name: Option<String>,
Expand Down Expand Up @@ -141,10 +141,9 @@ pub struct ServiceObject {

#[derive(Serialize, Deserialize, Debug)]
pub struct StateObject {
pub attributes: std::collections::HashMap<String, String>,
pub attributes: std::collections::HashMap<String, Value>,
pub entity_id: String,
pub last_changed: String,
pub last_updated: Option<String>,
pub state: String,
}

Expand Down