From 4b6d6ebedf7de7f92bb2580652923cd537d56b68 Mon Sep 17 00:00:00 2001 From: Nate Date: Sat, 21 Dec 2024 20:24:41 -0600 Subject: [PATCH] Make README say we wrap ws api too --- README.md | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 0c17ca6..de109ab 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,11 @@ -## Python wrapper for Homeassistant's [REST API](https://developers.home-assistant.io/docs/api/rest/) +## Python wrapper for Homeassistant's [Websocket API](https://developers.home-assistant.io/docs/api/websocket/) and [REST API](https://developers.home-assistant.io/docs/api/rest/) + +> Note: As of [this comment](https://github.com/home-assistant/architecture/discussions/1074#discussioncomment-9196867) the REST API is not getting any new features or endpoints. +> However, it is not going to be deprecated according to [this comment](https://github.com/home-assistant/developers.home-assistant/pull/2150#pullrequestreview-2017433583) +> But it is recommended to use the Websocket API for new integrations. Here is a quick example. @@ -18,17 +22,15 @@ Here is a quick example. from homeassistant_api import Client with Client( - '', + '', # i.e. 'http://homeassistant.local:8123/api/' '' ) as client: - - light = client.get_domain("light") - - light.turn_on(entity_id="light.living_room_lamp") + light = client.trigger_service('light', 'turn_on', {'entity_id': 'light.living_room'}) ``` -All the methods also support async! -Just prefix the method with `async_` +All the methods also support async/await! +Just prefix the method with `async_` and pass the `use_async=True` argument to the `Client` constructor. +Then you can use the methods as coroutines (i.e. `await light.async_turn_on(...)`). ## Documentation