HomeAssistant WS wrapper library
Project description
hass-client
Home Assistant async API wrapper
API Documentation
Example Usage:
from hass_ws import HassWS
async def main():
client = await HassWS("wss://server.hass", "token")
print(await client.fetch_states()) # Displays all HASS states
print(await client.call_service("light", "turn_on")) # Turns on all lights
async with client.listen_event(type="call_service") as listener:
async for i in listener:
print(i)
await client.close()
HassWS Interface:
await HassWS(server: str, token: str)
server: Required, str. Base server URL of HASS instance, includingwss://orws://protocol specifier.token: Required, str. Long-lived HASS access token.
Properties/Members:
HassWS().ready: Boolean value,Trueif the client is ready to send commands.HassWS().meta:HassMeta, server metadata.Noneif not connected.
Methods:
await HassWS().close(): Closes the currently active connection. To reconnect, callawait HassWS().authenticate()await HassWS().fetch_states() -> HassEntity[]: Returns current states of all entities.await HassWS().fetch_config() -> HassConfig: Returns current server configawait HassWS().fetch_services() -> {domain: {service: HassService}}: Returns all available servicesawait HassWS().fetch_panels() -> {name: HassPanel}: Returns all UI panelsawait HassWS().call_service(domain: str, service: str, target: HassServiceTarget = {}, data: dict = {}) -> bool: Calls a service, returning boolean success value.async with HassWS().listen_event(type: str = None) -> AsyncIterator: Subscribes to an event (or all events, iftype = None), and returns an asynchronous iterator for them.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file hass_websocket_client-0.2.0.tar.gz.
File metadata
- Download URL: hass_websocket_client-0.2.0.tar.gz
- Upload date:
- Size: 5.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.7.1 CPython/3.12.1 Linux/6.2.0-1018-azure
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d5152107b940953d574404df690e8fbc8bc10151332101ad6a903ad3a11a3c17
|
|
| MD5 |
c371228e31a91fc880c0bd28d3ffa2b4
|
|
| BLAKE2b-256 |
60deedc066649ca7af720cc5c706f9163ccbd162d26ab9d10b7a09735960658f
|
File details
Details for the file hass_websocket_client-0.2.0-py3-none-any.whl.
File metadata
- Download URL: hass_websocket_client-0.2.0-py3-none-any.whl
- Upload date:
- Size: 6.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.7.1 CPython/3.12.1 Linux/6.2.0-1018-azure
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
97aa52b332c3e554783d64ad362fb662c3826ce30575fc0a82a91498547176b4
|
|
| MD5 |
7f6b0b818f9881e7f223df4a6061d686
|
|
| BLAKE2b-256 |
9359b3ae2989ebf8eebf0962eb954f13ab9be118dda2a802e76483837d9d9d8b
|