Skip to main content

⚙️ Install / Configure

stars codecov version

Runtime Support: Bun Bun, Node.js Node.js (v20+)

Install Modules

@digital-alchemy/hass installs as a basic package, using 🧩 core to provide a wrapper around all the tools.

yarn add @digital-alchemy/core @digital-alchemy/hass
yarn add -D @digital-alchemy/type-writer

type-writer provides all of the relevant types for your 🏡 Home Assistant installation. These are only for the editing experience & builds, they are not required to run the code.

Add to project

import { CreateApplication } from "@digital-alchemy/core";
import { LIB_HASS } from "@digital-alchemy/hass";

const MY_APP = CreateApplication({
// import this project
libraries: [LIB_HASS],
// used to wire your services together
name: "home_automation",
services: {
// 🏗️ add your services here
}
});

// 🚀 start the app
await MY_APP.bootstrap();

Set connection info

If you are running inside Code Server or inside Code Runner addon, then your application already has access to authentication info 🎉

All other setups need to provide connection details. Using a .env file is the recommended method -

HASS_BASE_URL=http://localhost:8123
HASS_TOKEN=YOUR LONG LIVED ACCESS TOKEN

Tokens can be generated via your user profile > Security tab > Long-lived access tokens

Next Steps

  • 🎬 Type Writer: capture your current 🏡 Home Assistant state as type definitions
  • Creating Services (docs todo)
  • 🎭 Entity Proxies: access entity state, listen for changes, and issue targeted service calls
  • 📣 Call Proxy: access all the tools from the Developer tools > ACTIONS tab