Entities
Each kind of entity has the same four things: a hook and a headless component in @dashhaus/core, a tile in
@dashhaus/orb and a module in @dashhaus/field. The hook is the one implementation; the other three are it, drawn
or not.
| Kind | Home Assistant | Hook | Component | Orb | Field |
|---|---|---|---|---|---|
| Light | light.* | useHaLight | HaLight | HaLightTile | HaLightModule |
| Toggle | input_boolean.*, switch.* | useHaToggle | HaToggle | HaToggleTile | HaToggleModule |
| Cover | cover.* | useHaCover | HaCover | HaCoverTile | HaCoverModule |
| Sound | switch.*, with its volume number.* found beside it | useHaSound | HaSound | HaSoundTile | HaSoundModule |
| Climate | climate.* | useHaClimate | HaClimate | HaClimateTile | HaClimateModule |
| Humidifier | humidifier.* | useHaHumidifier | HaHumidifier | HaHumidifierTile | HaHumidifierModule |
| Fan | fan.* | useHaFan | HaFan | HaFanTile | HaFanModule |
| Sensor | sensor.*, with its device's humidity and battery sensors | useHaSensor | HaSensor | HaSensorTile | HaSensorModule |
| Weather | weather.*, with its air-quality sensor and sun.sun | useHaWeather | HaWeather | HaWeatherTile | HaWeatherModule |
| Guest Wi-Fi | sensor.*_voucher, with its join QR code image and what refreshes it and makes a new one | useHaGuestWifi | HaGuestWifi | HaGuestWifiTile | HaGuestWifiModule |
| Alarm | alarm_control_panel.* | useHaAlarm | HaAlarm | HaAlarmTile | HaAlarmModule |
| Lock | lock.*, with its device's battery sensor | useHaLock | HaLock | HaLockTile | HaLockModule |
| Owlet | sensor.*_sleep_state, with its heart rate, oxygen, charging and base station sensors | useHaOwlet | HaOwlet | HaOwletTile | HaOwletModule |
What every hook returns
Section titled “What every hook returns”useHa<Name>(entityId, options) returns:
entity: the normalized model. It is always there, even before Home Assistant has delivered the entity or while it is unavailable: itsstateis then"unavailable", and its fields are what’s known.history: today, hour by hour, from Home Assistant’s recorder and every change since. A lock has none: it shows its last change.actions: what the entity can do, for a control. An optional handler (a light’sonKelvinChange, a cover’sonSetPosition) is left out when the entity can’t use it, so test the handler before drawing its control. Sensors and the weather have no actions; the weather addshourlyanddailyforecasts.
Every hook takes name and area to override what Home Assistant says, history and loadHistory to supply or skip
today’s read, and, for a control, onActionError (Action errors).
Calls are a request, not a result
Section titled “Calls are a request, not a result”An action sends one Home Assistant service call and returns. The entity changes when Home Assistant reports that it changed, through the store, never before: a light shows on because it is on. So a control drawn on a hook is never optimistic, and a call Home Assistant refuses never leaves the screen out of step.
An entity id from the wrong domain, or one that isn’t an entity id at all, gets a console warning in development naming the hook. It is almost always a typo, and otherwise the card would only ever say unavailable.