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.
| Type | Global value |
|---|---|
entity (single) | an EntityWrapper for the picked entity, or undefined |
entity with multiple: true | one pick → a single EntityWrapper; two or more → an array-like proxy of wrappers whose service calls fan out to every member |
number, boolean | the literal value |
string, text, password, email, time, date, enum | a string |
array, thermostatSchedule | a JSON array of row objects |
domain, mode, hub, app, accountUserEmail, accountUserPhone, accountUserId, object | not hydrated — read settings[key] |
The table is generated from the runtime on Input types.
Rules of thumb
-
Unset is
undefined. Inputs without a value areundefined, not theirdefault. Guard:typeof offAfterMinutes === 'number' ? offAfterMinutes : 1. -
Normalise multi-selects when you iterate. The proxy answers
Array.isArrayand 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. -
settingshas everything. It is the raw object the installer saved, including types that are not hydrated.settings.recipientsfor anaccountUserIdinput,settings.modefor amodeinput. -
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));
}