Docs
Preferences

Inputs to globals

Which input types become variables in your code, in what shape, and how to read the rest.

Before every handler the hub builds a small bootstrap script that assigns preference values to globals named after each input's key. Not every type is hydrated.

TypeGlobal value
entity (single)an EntityWrapper for the picked entity, or undefined
entity with multiple: trueone pick → a single EntityWrapper; two or more → an array-like proxy of wrappers whose service calls fan out to every member
number, booleanthe literal value
string, text, password, email, time, date, enuma string
array, thermostatSchedulea JSON array of row objects
domain, mode, hub, app, accountUserEmail, accountUserPhone, accountUserId, objectnot hydrated — read settings[key]

The table is generated from the runtime on Input types.

Rules of thumb

  • Unset is undefined. Inputs without a value are undefined, not their default. Guard: typeof offAfterMinutes === 'number' ? offAfterMinutes : 1.

  • Normalise multi-selects when you iterate. The proxy answers Array.isArray and fans out service calls, but a single pick is a lone wrapper:

    function lightList() {
      return Array.isArray(lights) ? lights : lights ? [lights] : [];
    }

    If all you do is call a service, lights.turnOn() already handles both shapes.

  • settings has everything. It is the raw object the installer saved, including types that are not hydrated. settings.recipients for an accountUserId input, settings.mode for a mode input.

  • Keys are identifiers. key: 'off-after' cannot become a variable; use camelCase.

  • Names must not collide with the global functions (schedule, state, location, settings, …).

Checking what you got

function installed() {
  console.log('settings', JSON.stringify(settings));
  console.log('sensor', motionSensor?.entityId, 'lights', getEntityIds(lights));
}

On this page