Skip to content

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.

KindHome AssistantHookComponentOrbField
Lightlight.*useHaLightHaLightHaLightTileHaLightModule
Toggleinput_boolean.*, switch.*useHaToggleHaToggleHaToggleTileHaToggleModule
Covercover.*useHaCoverHaCoverHaCoverTileHaCoverModule
Soundswitch.*, with its volume number.* found beside ituseHaSoundHaSoundHaSoundTileHaSoundModule
Climateclimate.*useHaClimateHaClimateHaClimateTileHaClimateModule
Humidifierhumidifier.*useHaHumidifierHaHumidifierHaHumidifierTileHaHumidifierModule
Fanfan.*useHaFanHaFanHaFanTileHaFanModule
Sensorsensor.*, with its device's humidity and battery sensorsuseHaSensorHaSensorHaSensorTileHaSensorModule
Weatherweather.*, with its air-quality sensor and sun.sunuseHaWeatherHaWeatherHaWeatherTileHaWeatherModule
Guest Wi-Fisensor.*_voucher, with its join QR code image and what refreshes it and makes a new oneuseHaGuestWifiHaGuestWifiHaGuestWifiTileHaGuestWifiModule
Alarmalarm_control_panel.*useHaAlarmHaAlarmHaAlarmTileHaAlarmModule
Locklock.*, with its device's battery sensoruseHaLockHaLockHaLockTileHaLockModule
Owletsensor.*_sleep_state, with its heart rate, oxygen, charging and base station sensorsuseHaOwletHaOwletHaOwletTileHaOwletModule

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: its state is 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’s onKelvinChange, a cover’s onSetPosition) 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 adds hourly and daily forecasts.

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).

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.