Docs

Lifecycle

setupEntry, unloadEntry, handleService and optionsUpdated, and the not-ready retry.

Your bundle calls novon.defineIntegration({...}) once at the top level. The hub then drives these hooks for every config entry a person creates; each entry has its own isolate.

HookWhenNotes
setupEntry(ctx) requiredthe entry loads: boot, install, reloadconnect, ctx.entities.add(...), start polling
unloadEntry(ctx)before the entry unloadstimers are cleared for you
handleService(call, ctx)a service call for an entity that has no onService of its owncall = { uniqueId, platform, service, data }
optionsUpdated(ctx, previous)the person changed options-scoped inputsreturn normally to keep running with ctx.entry already updated; when absent the hub reloads the entry

ctx is the novon global typed as NovonSdk: ctx.entry (the config entry), ctx.entities, ctx.http, ctx.kv, ctx.notReady, ctx.sleep.

Not ready

Throw ctx.notReady('Cannot reach device') from setupEntry when the device is temporarily unreachable; the hub marks the entry as retrying and calls setupEntry again with backoff. Any other throw marks the entry failed with the message, visible in the app, until a person reloads it.

async setupEntry(ctx) {
  const res = await novon.http(`http://${ctx.entry.data.host}/status`).catch(() => null);
  if (!res?.ok) throw ctx.notReady(`No answer from ${ctx.entry.data.host}`);
  // …
}

The config entry

interface EntryContext {
  entryId: string;
  title: string;
  domain: string;
  version: string;
  data: Record<string, unknown>;     // inputs scoped 'data' (identity: host, credentials)
  options: Record<string, unknown>;  // inputs scoped 'options' (tunables; editable after install)
}

Read ctx.entry.data for identity and ctx.entry.options for tunables. Treat both as untrusted input: cast and validate.

Reload semantics

Boot, install, a manual reload, a bundle update, and (without optionsUpdated) an options change all run unloadEntry then setupEntry. Entities you added persist across reloads under their uniqueId; re-adding the same ids updates them.

On this page