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,True
if the client is ready to send commands.HassWS().meta
:HassMeta
, server metadata.None
if 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
Close
Hashes for hass_websocket_client-0.1.1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | dca5cd10d107aed275651f235b4883dd482afd6c20ce7f079ba4ad5c4ccb8aaa |
|
MD5 | a84c9a46d51ec85c75c0558b82f1ad41 |
|
BLAKE2b-256 | f31d8daaebb8406d3ceb04a9027b8c4cd712fab613cc59909ef22e760097119a |
Close
Hashes for hass_websocket_client-0.1.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ea5ba3fc4988b5d9147d3c9aea660d5818abefaba06a701711372b3bee93d31b |
|
MD5 | 63d8accbb06a2dd6a29108b01938acc3 |
|
BLAKE2b-256 | 4dba6937186c920d1f9fa2ef244cc111bbf0af2bddf758936c4f37621b0fa39c |