{"id":15486043,"url":"https://github.com/stefanbossbaly/home-assistant-rest","last_synced_at":"2025-04-14T22:37:14.364Z","repository":{"id":149114174,"uuid":"615925553","full_name":"StefanBossbaly/home-assistant-rest","owner":"StefanBossbaly","description":"Home Assistant Async REST API Rust Client","archived":false,"fork":false,"pushed_at":"2024-08-19T20:57:25.000Z","size":72,"stargazers_count":8,"open_issues_count":5,"forks_count":5,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-10-19T07:04:34.704Z","etag":null,"topics":["api","home-assistant","iot-platform","rest","rest-api"],"latest_commit_sha":null,"homepage":"https://crates.io/crates/home-assistant-rest","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/StefanBossbaly.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-03-19T04:36:28.000Z","updated_at":"2024-08-10T13:29:29.000Z","dependencies_parsed_at":"2024-04-11T16:29:57.294Z","dependency_job_id":"8ca3a969-7d9d-4667-8ce2-a03ffd1e622f","html_url":"https://github.com/StefanBossbaly/home-assistant-rest","commit_stats":{"total_commits":60,"total_committers":4,"mean_commits":15.0,"dds":"0.16666666666666663","last_synced_commit":"e58eb506b4f8432e625591919156da7ef2533725"},"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/StefanBossbaly%2Fhome-assistant-rest","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/StefanBossbaly%2Fhome-assistant-rest/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/StefanBossbaly%2Fhome-assistant-rest/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/StefanBossbaly%2Fhome-assistant-rest/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/StefanBossbaly","download_url":"https://codeload.github.com/StefanBossbaly/home-assistant-rest/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248974736,"owners_count":21192189,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["api","home-assistant","iot-platform","rest","rest-api"],"created_at":"2024-10-02T06:05:51.776Z","updated_at":"2025-04-14T22:37:14.345Z","avatar_url":"https://github.com/StefanBossbaly.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Home Assistant REST ![crates.io](https://img.shields.io/crates/v/home-assistant-rest.svg) [![](https://docs.rs/home-assistant-rest/badge.svg)](https://docs.rs/home-assistant-rest)\n\nThis project provides developers with a standard and ergonomic Rust API for\ncalling the various endpoints in Home Assistant's REST API. It handles the\nserialization and deserialization of the requests and responses and allows the\ndeveloper to use the provided structures. Currently this project is still under\nactive development and the API might change at any time.\n\n## Example Usage\n\n```rust\nuse home_assistant_rest::{Client, StateEnum};\n\n#[tokio::main]\nasync fn main() -\u003e Result\u003c(), Box\u003cdyn std::error::Error\u003e\u003e {\n    let base_url = \"REPLACE_WITH_HASS_BASE_URL\";\n    let token = \"REPLACE_WITH_ACCESS_TOKEN\";\n\n    let client = Client::new(base_url, token)?;\n    let api_status = client.get_api_status().await?;\n\n    if api_status.message != \"API running.\" {\n        println!(\"API is NOT running\");\n    } else {\n        println!(\"API is running, getting status of \\\"sun.sun\\\" entity\");\n        let state_entity = client.get_states_of_entity(\"sun.sun\").await?;\n\n        if let Some(state) = state_entity.state {\n            match state {\n                StateEnum::Boolean(x) =\u003e println!(\"Value is boolean with value {}\", x),\n                StateEnum::Decimal(x) =\u003e println!(\"Value is decimal with value {}\", x),\n                StateEnum::Integer(x) =\u003e println!(\"Value is integer with value {}\", x),\n                StateEnum::String(x) =\u003e println!(\"Value is string with value \\\"{}\\\"\", x),\n            }\n        } else {\n            println!(\"Value was not provided\");\n        }\n    }\n\n    Ok(())\n}\n```\n\n## Features\n\n- `serde_debugging` (default: `false`) - Enables `with_debugging` functions that\n  function the same as their counterparts with the exception that they use the\n  [`serde_path_to_error`](https://crates.io/crates/serde_path_to_error) as the\n  deserialization adapter and will return `DeserializeFailed` variant that holds\n  the path to struct field that failed deserialization and the full response\n  from the endpoint. Serde errors can be very cryptic and very hard to debug.\n  These functions allow the developer to easily find field that failed\n  deserialization at the cost of saving the response as well as maintaining a\n  path to the current field during deserialization.\n\n## API Status\n\n| Endpoint                               | Request Type | Implemented | Tested |\n| -------------------------------------- | ------------ | ----------- | ------ |\n| `/api/`                                | GET          | ✅          | ✅     |\n| `/api/config`                          | GET          | ✅          | ✅     |\n| `/api/events`                          | GET          | ✅          | ✅     |\n| `/api/services`                        | GET          | ✅          | ✅     |\n| `/api/history/period/\u003ctimestamp\u003e`      | GET          | ✅          | ✅     |\n| `/api/logbook/\u003ctimestamp\u003e`             | GET          | ✅          | ✅     |\n| `/api/states`                          | GET          | ✅          | ✅     |\n| `/api/states/\u003centity_id\u003e`              | GET          | ✅          | ✅     |\n| `/api/error_log`                       | GET          | ✅          | ✅     |\n| `/api/camera_proxy/\u003ccamera entity_id\u003e` | GET          | ❌          | ❌     |\n| `/api/calendars`                       | GET          | ✅          | ✅     |\n| `/api/calendars/\u003ccalendar entity_id\u003e`  | GET          | ✅          | ✅     |\n| `/api/states/\u003centity_id\u003e`              | POST         | ✅          | ✅     |\n| `/api/events/\u003cevent_type\u003e`             | POST         | ✅          | ✅     |\n| `/api/services/\u003cdomain\u003e/\u003cservice\u003e`     | POST         | ❌          | ❌     |\n| `/api/template`                        | POST         | ✅          | ✅     |\n| `/api/config/core/check_config`        | POST         | ✅          | ✅     |\n| `/api/intent/handle`                   | POST         | ❌          | ❌     |\n\n## Differences between the specification and implementation\n\nHome Assistant provides a\n[API specification](https://developers.home-assistant.io/docs/api/rest/) that\nlists in the various different endpoints, their parameters and their output.\nHowever when implementing this library I have come across a number of\ndiscrepancies between the specification and the my local Home Assistant\ninstance. Here is a list of the differences I have found so far:\n\n1. For the `/api/services` endpoint, the `services` attribute is listed in the\n   example as a list of strings. However testing locally the type for the\n   `services` attribute is actually a map.\n2. For the `/api/camera_proxy/\u003ccamera entity_id\u003e` endpoint, the only listed\n   parameters are the camera id and the time. However looking at the developer\n   tools panel, it shows that a unique token is also needed in order to retrieve\n   the image.\n3. Serialization of non-string types, especially for the `state` attribute. I\n   have seen many entities that report their state as either an integer, decimal\n   or boolean but when that state is serialized in the JSON response, the type\n   is a string and not the underlying type. In order to work around this issue,\n   when deserializing the state we attempt to deserialize into the underlying\n   types first if that fails then we default to a string type. This is not ideal\n   as it is costly to parse various different types. In the future I will\n   consider adding an option that allows the user to opt-out of this \"feature\".\n\n## Authors\n\nStefan Bossbaly\n\n## License\n\nThis project is licensed under the MIT License - see the LICENSE file for\ndetails\n\n## Acknowledgments\n\n- [Home Assistant](https://www.home-assistant.io/)\n- [Home Assistant REST API](https://developers.home-assistant.io/docs/api/rest/)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstefanbossbaly%2Fhome-assistant-rest","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstefanbossbaly%2Fhome-assistant-rest","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstefanbossbaly%2Fhome-assistant-rest/lists"}