Home Assistant dashboard on iPhone and iPad
Updated
Build a live Home Assistant dashboard on iPhone and iPad with Routix Dash: sensors, lights and plugs over WebSocket, updated the moment they change.
The app keeps one connection open to Home Assistant and switches devices with a tap. There is nothing to install on the Home Assistant side. Use it when you want a small, fast panel of the things you check most, designed exactly the way you like, next to data from other sources such as MQTT devices or web APIs.
How it works
Home Assistant gives every device a name called an entity ID, for example light.kitchen or sensor.living_room_temperature.
The app talks to Home Assistant over its WebSocket API, the same live connection the Home Assistant app uses:
- The app opens the connection and logs in with a token you create.
- It asks Home Assistant to follow the entities you choose. Home Assistant answers with their current state, then sends every change as it happens. Nothing is checked on a timer.
- When you tap a toggle, the app sends a command over the same connection, such as "turn on
light.kitchen".
If the connection drops, the app reconnects, logs in and asks again on its own.
1. Create a token in Home Assistant
In Home Assistant, open your profile (your name at the bottom of the side bar) → Security. Under Long-lived access tokens, tap Create token, give it a name such as Routix Dash, and copy the token. It is shown only once.
Keep this token private: anyone who has it can control your home. You can delete it on the same page at any time, and the app then loses access.
2. Store the token in the app
In Routix Dash, open the menu → Data → ENV variables and add a variable with the key ha_token and the token as its value.
Why a variable? The login message below uses {{ env.ha_token }} instead of the token itself, so the token stays hidden and is kept in one place.
3. Find your devices
You need the entity ID of each device you want on the dashboard. The quickest place to find them is in Home Assistant: Settings → Developer tools → States. In older versions, Developer tools is in the side bar.
The page lists every entity with its ID, its current state and its details. Type in Filter entities, for example light. for all lights or temperature for temperature sensors, and tap the copy button next to an ID.
The State column is what the app shows as the state, and the details on the right, such as brightness or unit_of_measurement, are the attributes you can show too.
You can also find a device under Settings → Devices & services → Entities: open it, then its settings, to see the Entity ID.
4. Create the connection
Open the menu → WebSocket connections → Add WebSocket connection:
- Name —
Home Assistant - URL — the address of Home Assistant with
/api/websocketat the end, for examplews://homeassistant.local:8123/api/websocket. If you open Home Assistant withhttps://, writewss://instead ofws://. - Transport — WebSocket
Tap the save tick. The login comes in step 6, once the app has somewhere to put what Home Assistant sends.
5. Keep the state of every device
Home Assistant sends the full state of each entity once, and after that only what changed. A short script puts these messages together, so the app always has the current state of every entity you follow.
Open the menu → Data sources → Add data source:
- Set Name to
Home Assistant. - Set Data source type to WebSocket and Connection to
Home Assistant. Leave Message events empty. - Under Data transformers pipe, tap Add... → JavaScript and paste:
const ha = vars.ha || {};
const ev = value.event || {};
for (const [id, s] of Object.entries(ev.a || {})) {
const [domain, name] = id.split(".");
ha[domain] = ha[domain] || {};
ha[domain][name] = { state: s.s, attributes: s.a || {} };
}
for (const [id, change] of Object.entries(ev.c || {})) {
const [domain, name] = id.split(".");
const entity = ha[domain]?.[name];
const add = change["+"];
if (!entity || !add) continue;
if (add.s !== undefined) entity.state = add.s;
Object.assign(entity.attributes, add.a || {});
}
vars.ha = ha;
return ha;
Tap the save tick.
You don't need to change the script. In short: it keeps one table of states (vars.ha), fills it from the first message, updates it with each change, and ignores other messages. The entity ID becomes a path you can read, so the state of light.kitchen is value.light.kitchen.state and its brightness is value.light.kitchen.attributes.brightness.
6. Log in and follow your devices
Open the menu → WebSocket connections → Home Assistant → Events → On connected. These actions run every time the connection opens, including after a reconnect.
Tap Add... → WebSocket send, choose the Home Assistant connection, and set Payload to the login message:
{"type": "auth", "access_token": "{{ env.ha_token }}"}
Tap Add... → WebSocket send again, with this Payload. List the entity IDs from step 3:
{"id": 1, "type": "subscribe_entities", "entity_ids": ["light.kitchen", "sensor.living_room_temperature"]}
Tap the save tick. The connection opens again with the new actions, and the Home Assistant data source fills with the state of the devices you listed.
To add a device later, add its entity ID to this list. "id": 1 is a number Home Assistant uses to match its answers to requests; leave it as it is.
7. Show a sensor
On a data section, tap Add data piece manually and pick Design your own data piece. Set Home Assistant as the root data source.
Tap Add component and choose Label. Turn Inherited off, then under Data transformers pipe tap Add... → Simple expression and enter:
value?.sensor?.living_room_temperature?.state
The ?. keeps the Label empty, rather than showing an error, until the first state arrives.
To show the unit too, choose JavaScript instead of Simple expression and enter:
const t = value?.sensor?.living_room_temperature;
return t ? t.state + " " + t.attributes.unit_of_measurement : "";
For a gauge, add a Dial gauge, set Default value to {{ value?.sensor?.living_room_temperature?.state }}, and set Minimum, Maximum and Suffix (for example °C) to suit the sensor.
Tap the save tick.
8. Switch a light
Add a data piece with Home Assistant as its root data source, tap Add component and choose Toggle. Set:
- Default value —
{{ value?.light?.kitchen?.state }}, so the toggle follows the light - On value —
on - Off value —
off
Open Events → On tap. A new Toggle already has Apply value there. It flips 1 and 0, so tap it and change Value to {{ value == "on" ? "off" : "on" }}. The toggle then flips between on and off and passes the new state to the next action.
Tap Add... below it and choose JavaScript. This builds the command for Home Assistant:
vars.ha_id = (vars.ha_id || 1) + 1;
return {
id: vars.ha_id,
type: "call_service",
domain: "light",
service: "turn_" + value,
target: { entity_id: "light.kitchen" }
};
The new state fills in turn_on or turn_off. Home Assistant needs a larger id on every command than on the one before, so the first line counts up.
Tap Add... → WebSocket send, choose the Home Assistant connection and leave Payload empty: the action then sends the command the script built.
Tap the save tick and try it. The light switches, and the toggle also follows changes made anywhere else, such as in the Home Assistant app or by an automation, right away.
Switches and plugs work the same way: add their entity ID to the list in step 6, and in the script write domain: "switch" and their entity ID.
When something is wrong
- Nothing shows and the connection keeps disconnecting. Home Assistant did not accept the token: the data source shows the message
auth_invalid. Checkha_token. The app keeps trying, so it connects once the token is right. - The connection does not open at all. The phone cannot reach Home Assistant, or the address is wrong. Check that URL ends with
/api/websocket. Then open the address in Safari on the phone without/api/websocketand withhttp://instead ofws://(https://instead ofwss://): it should show the Home Assistant sign-in page. - One device stays empty. Its entity ID is missing from the list in step 6, or is spelled differently from Developer tools → States.
- A tap does nothing. Check the Value of Apply value in step 8, and the entity ID in the script.
Tips
- Away from home.
homeassistant.localworks only on your home network. Away from home, use the address you use for remote access in URL, or connect through a VPN. - Use wss when you can. On a plain
ws://address, others on the same network can read the token. - A self-signed certificate. Turn on Allow bad certificates on the connection.
- One connection for everything. Every data piece can use the same
Home Assistantdata source; each component picks its own entity withvalue?.domain?.name. - Devices that also speak MQTT. If your devices publish to an MQTT broker, such as through the Mosquitto add-on, the app can also subscribe to them directly. See MQTT dashboard for iPhone and iPad.
- Let the AI assistant do the typing. Describe the data piece you want, with the entity ID, and the AI assistant builds it.