2121
2222class WebsocketClient (RawWebsocketClient ):
2323 """
24-
24+
2525 The main class for interactign with the Home Assistant WebSocket API client.
2626
2727 Here's a quick example of how to use the :py:class:`WebsocketClient` class:
28-
28+
2929 .. code-block:: python
3030
3131 from homeassistant_api import WebsocketClient
@@ -66,7 +66,7 @@ def get_rendered_template(self, template: str) -> str:
6666 def get_config (self ) -> dict [str , Any ]:
6767 """
6868 Get the Home Assistant configuration.
69-
69+
7070 Sends command :code:`{"type": "get_config", ...}`.
7171 """
7272 return cast (
@@ -80,7 +80,7 @@ def get_config(self) -> dict[str, Any]:
8080 def get_states (self ) -> Tuple [State , ...]:
8181 """
8282 Get a list of states.
83-
83+
8484 Sends command :code:`{"type": "get_states", ...}`.
8585 """
8686 return tuple (
@@ -170,7 +170,7 @@ def get_domains(self) -> dict[str, Domain]:
170170 Get a list of services that Home Assistant offers (organized into a dictionary of service domains).
171171
172172 For example, the service :code:`light.turn_on` would be in the domain :code:`light`.
173-
173+
174174 Sends command :code:`{"type": "get_services", ...}`.
175175 """
176176 resp = self .recv (self .send ("get_services" ))
@@ -203,7 +203,7 @@ def trigger_service(
203203 ) -> None :
204204 """
205205 Trigger a service (that doesn't return a response).
206-
206+
207207 Sends command :code:`{"type": "call_service", ...}`.
208208 """
209209 params = {
@@ -236,7 +236,7 @@ def trigger_service_with_response(
236236 ) -> dict [str , Any ]:
237237 """
238238 Trigger a service (that returns a response) and return the response.
239-
239+
240240 Sends command :code:`{"type": "call_service", ...}`.
241241 """
242242 params = {
@@ -261,7 +261,7 @@ def listen_events(
261261 Listen for all events of a certain type.
262262
263263 For example, to listen for all events of type `test_event`:
264-
264+
265265 .. code-block:: python
266266
267267 with ws_client.listen_events("test_event") as events:
@@ -275,7 +275,7 @@ def listen_events(
275275 def _subscribe_events (self , event_type : Optional [str ]) -> int :
276276 """
277277 Subscribe to all events of a certain type.
278-
278+
279279
280280 Sends command :code:`{"type": "subscribe_events", ...}`.
281281 """
@@ -292,15 +292,15 @@ def listen_trigger(
292292
293293 For example, in Home Assistant Automations we can subscribe to a state trigger for a light entity with YAML:
294294
295- .. code-block:: yaml
296-
295+ .. code-block:: yaml
296+
297297 triggers:
298298 # ...
299299 - trigger: state
300300 entity_id: light.kitchen
301301
302302 To subscribe to that same state trigger with :py:class:`WebsocketClient` instead
303-
303+
304304 .. code-block:: python
305305
306306 with ws_client.listen_trigger("state", entity_id="light.kitchen") as trigger:
@@ -309,7 +309,7 @@ def listen_trigger(
309309 if <some_condition>:
310310 break
311311 # exiting the context manager unsubscribes from the trigger
312-
312+
313313 Woohoo! We can now listen to triggers in Python code!
314314 """
315315 subscription = self ._subscribe_trigger (trigger , ** trigger_fields )
@@ -325,7 +325,7 @@ def listen_trigger(
325325 def _subscribe_trigger (self , trigger : str , ** trigger_fields ) -> int :
326326 """
327327 Return the subscription id of the trigger we subscribe to.
328-
328+
329329 Sends command :code:`{"type": "subscribe_trigger", ...}`.
330330 """
331331 return self .recv (
@@ -351,7 +351,7 @@ def _wait_for(
351351 def _unsubscribe (self , subcription_id : int ) -> None :
352352 """
353353 Unsubscribe from all events of a certain type.
354-
354+
355355 Sends command :code:`{"type": "unsubscribe_events", ...}`.
356356 """
357357 resp = self .recv (self .send ("unsubscribe_events" , subscription = subcription_id ))
@@ -361,7 +361,7 @@ def _unsubscribe(self, subcription_id: int) -> None:
361361 def fire_event (self , event_type : str , ** event_data ) -> Context :
362362 """
363363 Fire an event.
364-
364+
365365 Sends command :code:`{"type": "fire_event", ...}`.
366366 """
367367 params : dict [str , Any ] = {"event_type" : event_type }
0 commit comments