Skip to content

Commit

Permalink
Make README say we wrap ws api too
Browse files Browse the repository at this point in the history
  • Loading branch information
GrandMoff100 committed Dec 22, 2024
1 parent eb2c2b0 commit 4b6d6eb
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,25 +10,27 @@
<img src="https://github.com/GrandMoff100/HomeAssistantAPI/blob/7edb4e6298d37bda19c08b807613c6d351788491/docs/images/homeassistant-logo.png?raw=true" width="60%">
</a>

## 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.

```py
from homeassistant_api import Client

with Client(
'<API Server URL>',
'<API Server URL>', # i.e. 'http://homeassistant.local:8123/api/'
'<Your Long Lived Access-Token>'
) 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
Expand Down

0 comments on commit 4b6d6eb

Please sign in to comment.