Minimalist WebSocket client library for Home Assistant's websocket API. Current stable version is 0.2.5. It provides a simple async interface to connect, authenticate, and interact with Home Assistant, including fetching states, services, panels, config, media player thumbnails, camera thumbnails, calling services, and subscribing to events. Works in Node.js and browsers. Ships TypeScript types. Key differentiators: minimal dependencies, straightforward API, built-in event system for state_changed and other HA events.
npm install homeassistant-wsNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Connects to Home Assistant using a token, fetches all states, turns on a light, subscribes to state changes, then disconnects.
Use await hass({...}) or .then() to get the client.Ensure a WebSocket polyfill is available if targeting older browsers.
Provide a token from your HA profile page for authenticated access.
Remove event listeners before calling close(), or use a single long-lived client instance.
Run 'npm install homeassistant-ws'.
Use import hass from 'homeassistant-ws' instead of import { hass } from 'homeassistant-ws'.Ensure Home Assistant is running, or provide correct host/port in options.
No dependency data recorded yet.