Quickstart
Install Hassette, write a one-file app that logs a greeting on startup, and see it connect to Home Assistant. For a containerized setup, see Docker Setup instead. On Home Assistant OS or Supervised, install the Hassette add-on instead.
Prerequisites
- Python 3.11 or later: check with
python --version. - uv: this guide uses
uvto install Hassette. - A running Home Assistant instance: you'll need its URL and a long-lived access token (a token that does not expire, generated in HA).
1. Install Hassette
uv tool install hassette
2. Create a Home Assistant token
Create a long-lived access token from the Home Assistant UI (Profile → Security → Long-Lived Access Tokens).
3. Set up a project directory
Create an empty directory with an apps/ folder, then create a .env file inside it:
mkdir -p my-hassette/apps && cd my-hassette
# .env
HASSETTE__TOKEN=your_long_lived_access_token_here
HASSETTE__BASE_URL=http://homeassistant.local:8123
Replace the token value with the one you created in step 2. Update HASSETTE__BASE_URL to your Home Assistant address without any page path, typically http://homeassistant.local:8123 or http://<your-ip>:8123. The double underscores in HASSETTE__TOKEN and HASSETTE__BASE_URL are required. Hassette uses them to separate configuration namespaces.
4. Create your first app
Your app methods use async def, and calls to Hassette services need await in front of them. The rule: write async def for all your app methods, and add await before any call to self.bus, self.scheduler, or self.api. Regular calls like self.logger.info() do not need await. That covers everything in this guide.
from hassette import App, AppConfig
class MyAppConfig(AppConfig):
greeting: str = "Hello from Hassette!"
class MyApp(App[MyAppConfig]):
async def on_initialize(self):
self.logger.info(self.app_config.greeting)
Save this as apps/main.py. Then tell Hassette to run it: create hassette.toml in my-hassette/, next to .env:
[hassette.apps.my_app]
filename = "main.py"
class_name = "MyApp"
config = { instance_name = "my_app" }
Each app gets a [hassette.apps.<key>] section. The key, my_app, is a name you choose. filename is the file inside apps/, and class_name is the class to run. Hassette runs only the apps listed here. If you forget the section, startup logs a warning with the section to paste.
MyAppConfig declares your app's settings as typed class attributes. Hassette loads values from environment variables and hassette.toml automatically. App[MyAppConfig] ties the config to the app so self.app_config is always the right type.
Every app inherits five objects from Hassette: self.logger (Python logger), self.bus (listens for things happening in Home Assistant, like a light turning on), self.scheduler (runs functions on a timer), self.api (sends commands to Home Assistant), and self.states (reads current entity states from a local cache). Hassette creates them at startup. You just use them.
5. Run Hassette
hassette run -e .env
Hassette logs each startup step. Two lines matter:
...
2026-01-14T09:12:04.868953 [info ] [WebsocketService] Connected to Home Assistant at ws://homeassistant.local:8123/api/websocket
...
2026-01-14T09:12:04.998186 [info ] [my_app] Hello from Hassette!
The Connected to Home Assistant line confirms your URL and token work. The Hello from Hassette! line comes from your on_initialize method. If you change the greeting field in MyAppConfig and restart, you see your new text. Open a second terminal to check on the running instance:
hassette status
╭─────────────────────── System Status ────────────────────────╮
│ status ok │
│ websocket_connected true │
│ bootstrap_released true │
│ uptime_seconds 4s │
│ entity_count 312 │
│ app_count 1 tracked instance │
│ … │
╰──────────────────────────────────────────────────────────────╯
hassette app
┏━━━━━━━━┳━━━━━━━━━┳━━━━━━━━━━━━━━┳━━━━━━━━━━━┳━━━━━━━━━┳━━━━━━━┳━━━━━━━━━━━━━━━━┳━━━━━━━━━┳━━━━━━━━━━━┳━━━━━━━━━┓
┃ App ┃ Status ┃ Display Name ┃ Instances ┃ Restart ┃ Debug ┃ Invocations/1h ┃ Enabled ┃ Autostart ┃ File ┃
┡━━━━━━━━╇━━━━━━━━━╇━━━━━━━━━━━━━━╇━━━━━━━━━━━╇━━━━━━━━━╇━━━━━━━╇━━━━━━━━━━━━━━━━╇━━━━━━━━━╇━━━━━━━━━━━╇━━━━━━━━━┩
│ my_app │ running │ my_app │ 1 │ │ │ 0 │ True │ True │ main.py │
└────────┴─────────┴──────────────┴───────────┴─────────┴───────┴────────────────┴─────────┴───────────┴─────────┘
websocket_connected: true confirms the Home Assistant connection. my_app shows running. Invocations/1h counts how many times your app's handlers have fired in the last hour. Zero is normal — the app logs a greeting at startup but does not react to anything in Home Assistant yet. The next guide covers that.
Those commands query Hassette's own web API, not Home Assistant. That API has a credential of its own, and HASSETTE__TOKEN is not it. On first start, Hassette wrote a separate token to <data_dir>/.web_api_token (or to web_api.token_file, if you set it). <data_dir> is the directory where Hassette keeps its own files, such as its database. The CLI finds that file and uses it automatically, which is why the commands above needed no setup. Point the CLI at a different instance — a remote host, or a second instance on this machine — and it needs that instance's token instead. See CLI Configuration: Web API Token for how to supply one. An Error 401 names the credential the CLI sent and what to do about it.
6. Open the dashboard
The same running instance serves a web UI. Open http://127.0.0.1:8126/ in a browser.
A login screen asks for a token. Paste in the contents of <data_dir>/.web_api_token (or of web_api.token_file, if you set it) — the same credential the CLI uses. With the default <data_dir>, this prints it:
cat ~/.local/share/hassette/v0/.web_api_token
cat ~/Library/Application\ Support/hassette/v0/.web_api_token
Get-Content "$env:LOCALAPPDATA\hassette\hassette\v0\.web_api_token"
If you changed data_dir, the startup log from step 5 names the file on the line beginning Generated new web API auth_token, written to. The token value itself is never logged.
The dashboard shows app health, per-handler invocation history, structured logs, and the resolved configuration. It covers the same ground as hassette status and hassette app, plus history you can click through. See Web UI for the full tour, including how to change the bind address or run it behind a reverse proxy.
Having trouble?
If Hassette fails to connect, check HASSETTE__BASE_URL in your .env and confirm the token is correct. See Troubleshooting for common issues.
Next steps
- Your First Automation: react to state changes, get typed event data automatically, and schedule recurring jobs
- Web UI: app health, invocation history, and logs in the browser
- Docker Setup: deploy Hassette in production with Docker Compose
