Deploy Home Assistant | (Just Updated) Smart Home Automation Hub, REST API and Owner Login Generated

Home Assistant smart home hub with REST API, owner login preset

Deploy Home Assistant | (Just Updated) Smart Home Automation Hub, REST API and Owner Login Generated

Just deployed

/config

Deploy and Host Home Assistant on Railway

Built for an LLM agent to deploy and use. The deploy form has no fields to fill: the owner password is generated, the owner account is created at first boot before the public listener exists, and the whole configuration sits on a volume. Home Assistant is the open-source smart home automation hub: it connects thousands of devices and services, runs automations, and exposes every entity through a REST and WebSocket API.

About Hosting Home Assistant

This template runs one service, homeassistant, the upstream Home Assistant 2026.11.2 image (pinned by digest) through a thin wrapper, with a volume at /config that holds the configuration, the user database, the recorder database and every integration's state, so everything survives redeploys. The server listens on Railway's injected PORT, and the healthcheck is GET /auth/providers.

What the wrapper fixes. A fresh upstream Home Assistant sits in onboarding: the first visitor to the public URL creates the owner account, so a deploy form left empty hands the instance to whoever finds the URL first. The wrapper completes onboarding through Home Assistant's own API on loopback only, as the owner admin with the generated HASS_ADMIN_PASSWORD, stops that instance, and only then starts Home Assistant on the public port. It also writes the listen port and reverse-proxy trust into /config/.storage/http on every boot: without that, Home Assistant ignores Railway's PORT, and answers 400 to every request that Railway's edge forwards.

Using it. Sign in to the web interface as admin with HASS_ADMIN_PASSWORD, or call the REST API with a token obtained through the login flow shown below. Keep HASS_ADMIN_PASSWORD stable: it is only used at the first boot to create the owner, and later changes do not rename or re-password that user (change it in Home Assistant's profile page instead). Devices on your home network are not reachable from Railway; use cloud integrations, MQTT, webhooks or a VPN.

Agent contract

  • Public URL: https://RAILWAY_PUBLIC_DOMAIN (the generated domain of the homeassistant service)
  • Private URL: http://homeassistant.railway.internal:8080
  • Credentials: the variable HASS_ADMIN_PASSWORD on the homeassistant service is the password of the owner admin; add a HASS_ADMIN_USERNAME variable before the first deploy to use another owner name
  • Auth: sign in through POST /auth/login_flow and POST /auth/token, then send Authorization: Bearer ACCESS_TOKEN on every API call. A write with no token answers 401, a write with a wrong token answers 401, and the onboarding sign-up route answers 404 (the owner already exists).
  • Health: GET /auth/providers returns 200
#!/bin/sh
# needs: RAILWAY_PUBLIC_DOMAIN, HASS_ADMIN_PASSWORD (variables of the homeassistant service); also curl and sed. Sets one throwaway sensor state.
R="https://$RAILWAY_PUBLIC_DOMAIN"; C="$R/"; U="${HASS_ADMIN_USERNAME:-admin}"; J="Content-Type: application/json"
n=0; until [ "$(curl -s -o /dev/null -w '%{http_code}' "$R/auth/providers")" = 200 ]; do n=$((n+1)); [ "$n" -le 90 ] || break; sleep 5; done
curl -s -o /dev/null -w "health: %{http_code}\n" "$R/auth/providers"
# sign in as the owner with the generated password: login flow, then exchange the code for an access token
F=$(curl -s -X POST -H "$J" -d "{\"client_id\":\"$C\",\"handler\":[\"homeassistant\",null],\"redirect_uri\":\"$C\"}" "$R/auth/login_flow" | sed -n 's/.*"flow_id":"\([^"]*\)".*/\1/p')
CODE=$(curl -s -X POST -H "$J" -d "{\"client_id\":\"$C\",\"username\":\"$U\",\"password\":\"$HASS_ADMIN_PASSWORD\"}" "$R/auth/login_flow/$F" | sed -n 's/.*"result":"\([^"]*\)".*/\1/p')
T=$(curl -s -X POST -d grant_type=authorization_code -d "code=$CODE" -d "client_id=$C" "$R/auth/token" | sed -n 's/.*"access_token":"\([^"]*\)".*/\1/p')
A="Authorization: Bearer $T"
# read with the token
curl -s -o /dev/null -w "read config: %{http_code}\n" -H "$A" "$R/api/config"
# write with the token: set a sensor state, read it back
curl -s -o /dev/null -w "write state: %{http_code}\n" -X POST -H "$J" -H "$A" -d '{"state":"agent-contract-ok"}' "$R/api/states/sensor.agent_contract"
if curl -s -H "$A" "$R/api/states/sensor.agent_contract" | grep -q agent-contract-ok; then echo "read back: found"; else echo "read back: MISSING"; fi
# refusals: no token, wrong token, public sign-up
curl -s -o /dev/null -w "write without key: %{http_code}\n" -X POST -H "$J" -d '{"state":"x"}' "$R/api/states/sensor.agent_contract"
curl -s -o /dev/null -w "write wrong key: %{http_code}\n" -X POST -H "$J" -H "Authorization: Bearer not-the-token" -d '{"state":"x"}' "$R/api/states/sensor.agent_contract"
curl -s -o /dev/null -w "public signup: %{http_code}\n" -X POST -H "$J" -d "{\"client_id\":\"$C\",\"name\":\"Intruder\",\"username\":\"intruder\",\"language\":\"en\"}" "$R/api/onboarding/users"

Expected output against a fresh deploy (measured on a Railway deploy of this template):

health: 200
read config: 200
write state: 201
read back: found
write without key: 401
write wrong key: 401
public signup: 404

The refusals are the contract: write without key: 401, write wrong key: 401 and public signup: 404 (no second user can register). The first four lines show the owner login works for reads and writes.

Why Deploy Home Assistant on Railway?

Railway is a singular platform to deploy your infrastructure stack. Railway will host your infrastructure so you don't have to deal with configuration, while allowing you to vertically and horizontally scale it.

By deploying Home Assistant on Railway, you are one step closer to supporting a complete full-stack application with minimal burden. Host your servers, databases, AI agents, and more on Railway.

  • Agent-ready - no deployer fields, a contract block, and one script that proves the instance is healthy, the owner login can read and write, and unauthenticated writes and sign-ups are refused.
  • Setup done for you - the owner account is created from a generated variable before the public listener exists, so nobody can claim the instance.
  • Works behind Railway's edge - the listen port and proxy trust are set, so the public URL serves the dashboard instead of a 400 page.
  • Data survives redeploys - users, automations, dashboards and history live on a volume.
  • Pinned - the upstream image is pinned by digest and the wrapper by tag and digest.

Common Use Cases

  • Cloud-hosted smart home hub - run automations, dashboards and cloud integrations without a Raspberry Pi at home.
  • Home automation API for an AI agent - read and set entity states and call services over the REST API.
  • Webhook and MQTT automation host - react to events from services and devices that can reach the public URL.
  • Testing and developing integrations and blueprints - a disposable, reproducible Home Assistant instance.

Dependencies for Home Assistant Hosting

  • The homeassistant service with its volume, created by the template. A custom domain is optional.

Deployment Dependencies


Template Content

More templates in this category

View Template
Rocky Linux
Hosted Rocky Linux 9 workspace with SSH and persistent storage. 🚀

codestorm
51
View Template
Foundry Virtual Tabletop
Self-hosted virtual tabletop for role-playing games (license required)

Lucas
71
View Template
NEW
Double Commander in your browser
The Double Commander file manager in the cloud, from any device

Nermin Sabanovic
0