You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -7,7 +7,7 @@
7
7
[](https://github.com/GrandMoff100/HomeassistantAPI/releases)
## 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/)
Copy file name to clipboardExpand all lines: docs/advanced.rst
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -12,7 +12,7 @@ Rather than the default behavior, which is saving the cache to memory or not at
12
12
If you want to persist your requests cache you can pass your own custom cached session to :py:class:`Client`'s init method.
13
13
You can pass a variety of options to your cached session like how fast to expire the cache, where to cache it (the cache backend), and what to do when the cache is expired.
14
14
15
-
Depending on whether you are using this in an async of sync project you will want to use either :py:class:`aiohttp_client_cache.backends.CachedSession` or :py:class:`requests_cache.CachedSession` respectively.
15
+
Depending on whether you are using this in an async or sync project you will want to use either :py:class:`aiohttp_client_cache.backends.CachedSession` or :py:class:`requests_cache.CachedSession` respectively.
16
16
See the docs for `requests_cache <https://requests-cache.readthedocs.io/en/latest/>`__ and `aiohttp_client_cache <https://aiohttp-client-cache.readthedocs.io/en/latest/>`__ for how to implement these backends, options, and much more.
Copy file name to clipboardExpand all lines: docs/index.rst
+3-2Lines changed: 3 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -9,8 +9,8 @@
9
9
Welcome to Homeassistant API!
10
10
=============================
11
11
12
-
Homeassistant API is a pythonic module that interacts with `Homeassistant's REST API integration <https://developers.home-assistant.io/docs/api/rest>`_.
13
-
You can use it to remotely control your Home Assistant like getting entity states, triggering services, etc.
12
+
Homeassistant API is a pythonic module that interacts with `Homeassistant's REST API integration <https://developers.home-assistant.io/docs/api/rest>`_ and Homeassistant's `Websocket API <https://developers.home-assistant.io/docs/api/websocket>`_.
13
+
You can use it to remotely control your Home Assistant to do things like turn on lights, change the temperature, or listen for when the garage door opens.
14
14
15
15
Index
16
16
----------
@@ -30,6 +30,7 @@ Features
30
30
----------
31
31
32
32
- Full consumption of the Home Assistant REST API endpoints.
33
+
- Full consumption of the Home Assistant Websocket API (all of the documented commands and some undocumented ones)
33
34
- Convenient Pydantic Models for data validation.
34
35
- Syncrononous and Asynchronous support for integrating with all applications and/or libraries.
Copy file name to clipboardExpand all lines: docs/usage.rst
+86-4Lines changed: 86 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,20 +6,19 @@ Usage
6
6
The Basics...
7
7
#################
8
8
9
-
This library is centered around the :py:class:`Client` class.
9
+
This library is centered around the :py:class:`Client` and :py:class:`WebsocketClient` classes.
10
10
Once you have have your api base url and Long Lived Access Token from Home Assistant we can start to do stuff.
11
-
The rest of this guide assumes you have the :py:class:`Client` saved to a :code:`client` variable.
11
+
The rest of this guide assumes you have the :py:class:`Client` saved to a :code:`client` variable or a :py:class:`WebsocketClient` saved to a :code:`ws_client` variable.
12
12
Most of these examples require some integrations to be setup inside Home Assistant for the examples to actually work.
13
13
The most commonly used features of this library include triggering services and getting and modifying entity states.
14
14
15
-
16
15
.. code-block:: python
17
16
:linenos:
18
17
19
18
import os
20
19
from homeassistant_api import Client
21
20
22
-
URL='<API BASE URL>'
21
+
URL='<API BASE URL>'# Example: 'https://foobarhomeassistant.duckdns.org:8123/api'
23
22
TOKEN='<LONG LIVED ACCESS TOKEN>'
24
23
25
24
# Assigns the Client object to a variable and checks if it's running.
@@ -31,6 +30,18 @@ The most commonly used features of this library include triggering services and
31
30
# Triggers the light.turn_on service on the entity `light.my_living_room_light`
32
31
33
32
33
+
.. code-block:: python
34
+
:linenos:
35
+
36
+
from homeassistant_api import WebsocketClient
37
+
38
+
WS_URL='<WS API BASE URL>'# Example: 'https://foobarhomeassistant.duckdns.org:8123/api/websocket'
39
+
TOKEN='<LONG LIVED ACCESS TOKEN>'
40
+
41
+
with WebsocketClient(WS_URL, TOKEN) as ws_client: # opens a websocket connection to Home Assistant
# {'set_temperature': Service(service_id='set_temperature', name='Set temperature', description='Set the target temperature for a climate entity.\n', ...
0 commit comments