Skip to main content

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, including wss:// or ws:// 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, call await HassWS().authenticate()
  • await HassWS().fetch_states() -> HassEntity[]: Returns current states of all entities.
  • await HassWS().fetch_config() -> HassConfig: Returns current server config
  • await HassWS().fetch_services() -> {domain: {service: HassService}}: Returns all available services
  • await HassWS().fetch_panels() -> {name: HassPanel}: Returns all UI panels
  • await 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, if type = None), and returns an asynchronous iterator for them.

Metadata

Release files for hass-websocket-client 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for hass-websocket-client 0.2.0
File Size Uploaded Provenance
hass_websocket_client-0.2.0.tar.gz 5.0 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for hass-websocket-client 0.2.0
File Interpreter ABI Platform
hass_websocket_client-0.2.0-py3-none-any.whl Python 3 none any Details

Total release size: 11.4 kB

Release files / hass_websocket_client-0.2.0.tar.gz

Download URL hass_websocket_client-0.2.0.tar.gz
Size 5.0 kB
Tags Source
SHA-256 checksum
How to use checksums
d5152107b940953d574404df690e8fbc8bc10151332101ad6a903ad3a11a3c17
BLAKE2b-256 checksum
How to use checksums
60deedc066649ca7af720cc5c706f9163ccbd162d26ab9d10b7a09735960658f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.7.1 CPython/3.12.1 Linux/6.2.0-1018-azure

Release files / hass_websocket_client-0.2.0-py3-none-any.whl

Download URL hass_websocket_client-0.2.0-py3-none-any.whl
Size 6.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
97aa52b332c3e554783d64ad362fb662c3826ce30575fc0a82a91498547176b4
BLAKE2b-256 checksum
How to use checksums
9359b3ae2989ebf8eebf0962eb954f13ab9be118dda2a802e76483837d9d9d8b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.7.1 CPython/3.12.1 Linux/6.2.0-1018-azure

Security for hass-websocket-client 0.2.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page