Libraries
Use the bridge, or Home Assistant directly, from your own Effect app.
Home Assistant Bridge is built from two Effect v4 libraries, published to npm and JSR. Both work under Bun and Node.
| Package | Use it to |
|---|---|
@timmo001/effect-ha-bridge |
Talk to a running bridge over its socket, sharing its connection |
@timmo001/effect-ha |
Connect to Home Assistant yourself, with typed actions and schemas |
Most local apps want the bridge client: they start instantly, share the bridge’s cache and never hold a token.
Bridge client
bun add @timmo001/effect-ha-bridge @timmo001/effect-ha effect
BridgeClient has one method per RPC: GetEntity, WatchEntity, CallAction, GetConfig and CameraSnapshot. resolveSocketPath finds the socket the same way the CLI does, and getCalendarEvents reads calendar events through CallAction.
import { BunRuntime, BunServices } from "@effect/platform-bun";
import { Light } from "@timmo001/effect-ha";
import { BridgeClient, resolveSocketPath } from "@timmo001/effect-ha-bridge";
import { Effect, Option } from "effect";
const main = Effect.gen(function* () {
const socketPath = yield* resolveSocketPath(Option.none());
yield* Effect.gen(function* () {
const client = yield* BridgeClient;
yield* client.CallAction(Light.toggle("light.desk"));
}).pipe(Effect.provide(BridgeClient.layer(socketPath)));
});
main.pipe(Effect.provide(BunServices.layer), BunRuntime.runMain);
See the client README for watching, action responses, calendars and errors.
Home Assistant library
bun add @timmo001/effect-ha effect
connect opens and authenticates a WebSocket session with callAction, getConfig and raw request. The library also has typed action builders (Light, Switch, Cover, Climate, InputBoolean, InputNumber, AssistSatellite and Calendar), the EntityState schema, frontend-style entity naming and cameraSnapshot.
See the effect-ha README for details.