Catalog introspection
Ask the hub which domains, services, parameters and options exist, instead of hard-coding them.
The hub keeps a curated catalog of the services a smart app can invoke, with labels and typed
parameters, so wizard-style apps can offer valid choices at each step. These functions are mostly
used inside a dynamic preferences function.
| Function | Returns |
|---|---|
getActionDomains() | [{ value: 'light', label: 'Light' }, …] |
getServicesForDomain(domain) | [{ value: 'turnOn', label: 'Turn on', description? }, …] ([] for unknown) |
getServiceParameters(domain, service) | [{ key, label, type, required?, min?, max?, options?, description? }] |
getDomainStateOptions() | [{ value: 'light.on', label: … }, …] for every typed-state domain (sensor excluded) |
getEntityDomains() | { Light: 'light', Switch: 'switch', … } |
getEntityFeatures() | feature bitmasks per domain, e.g. .Cover.SET_POSITION |
getHvacModeOptions() / getFanModeOptions() | option lists for climate.setHvacMode / setFanMode |
getPlacePresenceOptions() | one option per place presence entity |
Shapes are on Action catalog types; the catalog content itself is the generated capability reference.
Building an action picker
function serviceOptions() {
const out = [];
for (const d of getActionDomains()) {
for (const s of getServicesForDomain(d.value)) {
out.push({ value: `${d.value}.${s.value}`, label: `${d.label} — ${s.label}`, description: s.description });
}
}
return out;
}Store domain.service strings and split them when you act:
function runAction(row) {
const [domain, service] = row.action.split('.');
const params = {};
for (const p of getServiceParameters(domain, service)) {
if (row[`param_${p.key}`] !== undefined) params[p.key] = row[`param_${p.key}`];
}
new EntityWrapper(row.entity)[service](params);
}Catalog versus routable
The catalog is a curated subset. An integration may implement services the catalog does not list; you can still call them by name on a wrapper. The capability pages show both sets.
Modes
The catalog has no getMode(); read the location mode as an entity:
new EntityWrapper('system.mode').getState(), or offer a mode input and read settings.<key>.