declare const LIBRARY_NAME: "nodehomematic"; /** * Value conversion + validation between the CCU wire representation and the * library's JS-facing {@link HmValue} domain. * * The CCU speaks a small set of {@link ParameterType}s. Inbound values arrive as * loosely-typed XML-RPC scalars (numbers, strings, booleans); outbound writes * must be coerced and validated against the parameter metadata before hitting * the wire. This module is pure: it never touches the network. */ /** The JS-facing value of a data point. */ type HmValue = boolean | number | string | null; /** * Public, transport-agnostic types exposed by the library's facade. No internal * transport/central types leak through these shapes: a consumer sees only * plain, serialisable data + the {@link HmValue} domain. */ /** A public snapshot of a single data point. */ interface HmDataPoint { /** Stable unique id (the dpk encoded as a lowercased string). */ readonly id: string; /** Parameter name, e.g. `STATE`. */ readonly parameter: string; /** Parameter value type, e.g. `BOOL`, `FLOAT`, `ENUM`. */ readonly type: string; /** Current value (`null` until the first event). */ readonly value: HmValue; readonly unit?: string; readonly readable: boolean; readonly writable: boolean; readonly hasEvents: boolean; readonly valueList?: readonly string[]; readonly min?: number; readonly max?: number; } /** A public snapshot of a single channel. */ interface HmChannel { readonly address: string; readonly index: number; readonly type?: string; /** * CCU user-given channel name from JSON-RPC `Device.listAllDetail`. * `null` when the CCU has none or the name read failed — never the address. */ readonly name: string | null; readonly dataPoints: readonly HmDataPoint[]; } /** One direct device link from XML-RPC `getLinks` (`SENDER` / `RECEIVER` / `NAME`). */ interface HmChannelLink { readonly sender: string; readonly receiver: string; readonly name: string; } /** * Central-link flag plus the direct links of one channel. * `central` is `getMetadata("reportValueUsageData").PRESS_SHORT > 0`, not a * peer inside `links`. */ interface HmChannelLinkState { readonly central: boolean; readonly links: readonly HmChannelLink[]; } /** * What one key press does on a switch actuator link. `none` is * `PROFILE_ACTION_TYPE_INACTIVE` (the press is ignored). */ type HmLinkPressAction = 'toggle' | 'on' | 'off' | 'none'; /** The short and long press actions of a key → switch actuator link. */ interface HmSwitchLinkActions { readonly short: HmLinkPressAction; readonly long: HmLinkPressAction; } /** A link whose receiver paramset matches the switch catalogue exactly. */ interface HmSwitchLinkProfile extends HmSwitchLinkActions { readonly kind: 'switch'; } /** * A key → switch link whose receiver paramset matches no catalogue profile * (a timer, a delay, an expert setting). It is never rewritten by * `setLinkProfile`. */ interface HmCustomLinkProfile { readonly kind: 'custom'; } /** The resolved profile of a key → switch actuator link. */ type HmLinkProfile = HmSwitchLinkProfile | HmCustomLinkProfile; /** One direct link with its CCU name, description and resolved profile. */ interface HmLink { readonly sender: string; readonly receiver: string; /** `NAME` from `getLinks`; `""` when the CCU sent none. */ readonly name: string; /** `DESCRIPTION` from `getLinks` verbatim; `""` when the CCU sent none. */ readonly description: string; /** * The switch profile, or `null` when the link is not a `KEY_TRANSCEIVER` → * `SWITCH_VIRTUAL_RECEIVER` link between two known channels (no catalogue * applies). */ readonly profile: HmLinkProfile | null; } /** A device or channel address with the name the CCU now holds for it. */ interface HmNamedObject { readonly address: string; readonly name: string; } /** Options of `renameDevice`. */ interface HmRenameDeviceOptions { /** Also rename every channel to `:`. */ readonly renameChannels: boolean; } /** The names the CCU applied after `renameDevice` (it may adjust them to stay unique). */ interface HmDeviceRename { readonly device: HmNamedObject; /** Renamed channels; empty when `renameChannels` was `false`. */ readonly channels: readonly HmNamedObject[]; } /** A CCU room with its member channels. */ interface HmRoom { /** ReGa object id of the room. */ readonly id: string; readonly name: string; /** Member channel addresses (`DEVICE:index`). */ readonly channels: readonly string[]; } /** Key press parameters a key event program listens to. */ type HmKeyEventParameter = 'PRESS_SHORT' | 'PRESS_LONG'; /** Input of {@link Homematic.ensureKeyEventProgram}. */ interface HmKeyEventProgramInput { /** Program name; the program is found by it. */ readonly name: string; /** Key channels (`DEV:1`), all on one interface. */ readonly channelAddresses: readonly string[]; /** Defaults to `PRESS_SHORT` and `PRESS_LONG`. */ readonly parameters?: readonly HmKeyEventParameter[]; } /** Result of {@link Homematic.ensureKeyEventProgram}. */ interface HmKeyEventProgramResult { readonly programId: string; /** `true` when the program did not exist before. */ readonly created: boolean; } /** A key event program as found on the CCU. */ interface HmKeyEventProgram { readonly programId: string; readonly channelAddresses: string[]; } /** * One section of {@link HmKeyEventDiagnosis}. A section that could not be read * is `{ ok: false, error }`; it never fails the whole diagnosis. */ type HmDiagnosisSection = { readonly ok: true; readonly data: T; } | { readonly ok: false; readonly error: string; }; /** A VALUES / MASTER paramset as the interface returned it (parameter name -> raw value). */ type HmParamsetValues = Readonly>; /** Central link of one channel: XML-RPC `getMetadata(ch, "reportValueUsageData")`. */ interface HmKeyCentralLink { /** The `PRESS_SHORT` usage counter, or `null` when the metadata has none. */ readonly pressShortCount: number | null; /** `pressShortCount > 0` (aiohomematic `Channel._has_central_link`). */ readonly active: boolean; } /** The device's maintenance channel (`:0`) values that tell whether it is reachable and configured. */ interface HmKeyDeviceMaintenance { /** Address of the maintenance channel, `:0`. */ readonly channelAddress: string; /** `null` when the parameter is absent from the answer. */ readonly configPending: unknown; readonly unreach: unknown; readonly rssiDevice: unknown; readonly rssiPeer: unknown; readonly updatePending: unknown; } /** What THIS client received for one parameter, from the library's own data points. */ interface HmKeyParameterClientState { readonly parameter: string; /** Whether the library has a data point for it. */ readonly known: boolean; /** Epoch ms of the last event applied to the data point, `null` when none arrived. */ readonly lastEventAt: number | null; /** The data point's current value (`null` until the first event). */ readonly value: unknown; } /** Events THIS client received for one channel. */ interface HmKeyChannelClientState { readonly channelAddress: string; /** `PRESS_SHORT`, `PRESS_LONG`, `PRESS_LONG_RELEASE` first, then every other data point. */ readonly parameters: readonly HmKeyParameterClientState[]; } /** XML-RPC view of one key channel. */ interface HmKeyChannelXmlRpc { readonly centralLink: HmDiagnosisSection; /** `getLinks(ch, 0)`. */ readonly directLinks: HmDiagnosisSection; /** `getParamset(ch, "VALUES")`. */ readonly values: HmDiagnosisSection; /** `getParamset(ch, "MASTER")`, raw: the key settings. */ readonly master: HmDiagnosisSection; } /** One key channel in {@link HmKeyEventDiagnosis}. */ interface HmKeyChannelDiagnosis { readonly address: string; /** Channel type from the device description, e.g. `KEY_TRANSCEIVER`. */ readonly type: string | null; readonly xmlRpc: HmKeyChannelXmlRpc; readonly client: HmKeyChannelClientState; } /** One ReGa data point of a key channel (`.:.PRESS_SHORT` ...). */ interface HmKeyRegaDatapoint { /** The ReGa name, `..`. */ readonly name: string; /** Whether the CCU has such a data point; `false` is why no program can use it. */ readonly exists: boolean; readonly id: string | null; /** `Value()` as ReGa prints it (a boolean is `"true"` / `"false"`). */ readonly value: string | null; /** `Timestamp()` as epoch ms: the last time the CCU UPDATED the data point (any event, even an unchanged value). */ readonly timestamp: number | null; /** `LastTimestamp()` as epoch ms: the update before `timestamp`. */ readonly lastTimestamp: number | null; } /** The ReGa channel object of a key channel and its key data points. */ interface HmKeyRegaChannel { readonly address: string; /** `false` when ReGa has no channel with that address. */ readonly found: boolean; readonly id: string | null; readonly name: string | null; readonly visible: boolean | null; /** `Enabled()`; `null` when ReGa answered nothing. */ readonly enabled: boolean | null; /** `ReadyConfig()`; `null` when ReGa answered nothing. */ readonly readyConfig: boolean | null; /** `LastDPActionTime`: the last time any data point of the channel was acted on, epoch ms. */ readonly lastActionAt: number | null; readonly datapoints: readonly HmKeyRegaDatapoint[]; } /** A CCU program whose condition references one of the key data points. */ interface HmKeyRegaProgram { readonly id: string; readonly name: string; readonly active: boolean | null; /** `Internal()`: a system program the WebUI hides. */ readonly internal: boolean | null; /** `ProgramLastExecuteTime`, epoch ms; `null` when it never ran. */ readonly lastExecutedAt: number | null; /** The key data point names its conditions reference. */ readonly datapoints: readonly string[]; } /** A CCU program whose conditions reference key channels, from {@link Homematic.keyProgramReferences}. */ interface HmKeyProgramReference { readonly id: string; readonly name: string; /** `Active()`; `null` when ReGa answered nothing. */ readonly active: boolean | null; /** The key channel addresses (`:`) the conditions reference, each once. */ readonly channels: readonly string[]; } /** What the CCU's ReGa knows about the key channels. */ interface HmKeyRegaState { readonly channels: readonly HmKeyRegaChannel[]; /** Empty when no program references a key data point. */ readonly programs: readonly HmKeyRegaProgram[]; } /** The ReGa part of the diagnosis: unavailable (no WebUI credentials, script failure) or read. */ type HmKeyRegaDiagnosis = { readonly available: true; readonly state: HmKeyRegaState; } | { readonly available: false; readonly reason: string; }; /** Connection health of the device's interface, from the library's own tracker. */ interface HmKeyInterfaceClientState { readonly interfaceId: string; /** Connection state, e.g. `CONNECTED`. */ readonly state: string; /** Epoch ms of the latest event of ANY kind received on the interface, `null` when none. */ readonly lastEventAt: number | null; /** The callback is alive: no silence beyond the warn interval. */ readonly callbackAlive: boolean; } /** Result of {@link Homematic.diagnoseKeyEvents}. */ interface HmKeyEventDiagnosis { readonly deviceAddress: string; readonly interfaceId: string; /** Epoch ms the diagnosis was taken. */ readonly takenAt: number; /** The maintenance channel `:0` over XML-RPC. */ readonly maintenance: HmDiagnosisSection; /** Events this client received on the maintenance channel. */ readonly maintenanceClient: HmKeyChannelClientState; /** Key channels found on the device (empty when it has none). */ readonly channels: readonly HmKeyChannelDiagnosis[]; /** ReGa data points and programs for the key channels. */ readonly rega: HmKeyRegaDiagnosis; readonly interfaceClient: HmKeyInterfaceClientState; } /** A public snapshot of a single device. */ interface HmDevice { readonly address: string; readonly type: string; /** * CCU user-given device name from JSON-RPC `Device.listAllDetail`. * `null` when the CCU has none or the name read failed — never the address. */ readonly name: string | null; readonly rooms?: readonly string[]; readonly functions?: readonly string[]; /** Installed firmware version, e.g. `1.18.24` (CCU descriptor `FIRMWARE`). */ readonly firmware?: string; /** Latest firmware available, e.g. `1.18.24` (CCU descriptor `AVAILABLE_FIRMWARE`). */ readonly availableFirmware?: string; /** Whether a firmware update can be installed (CCU descriptor `UPDATABLE`). */ readonly updatable?: boolean; /** Firmware update lifecycle state, e.g. `UP_TO_DATE` (CCU descriptor `FIRMWARE_UPDATE_STATE`). */ readonly firmwareUpdateState?: string; readonly channels: readonly HmChannel[]; } /** * A public snapshot of a CCU system variable (hub layer). Immutable; values are * parsed into the {@link HmValue} domain. `writable` reflects the `HAHM` * extended-sysvar marker — only writable variables may be set. */ interface HmSysVar { readonly id: string; readonly name: string; /** Normalised value type, e.g. `FLOAT`, `LOGIC`, `LIST`, `STRING`. */ readonly type: string; readonly value: HmValue; readonly unit?: string; readonly writable: boolean; readonly isInternal: boolean; readonly valueList?: readonly string[]; readonly min?: number; readonly max?: number; } /** A public snapshot of a CCU program (rule/automation). Immutable. */ interface HmProgram { readonly id: string; readonly name: string; readonly isActive: boolean; readonly isInternal: boolean; readonly lastExecuteTime?: string; } /** * A reference to a data point, accepted by the facade's read/write methods. * Either the stable string id, or a structured `{ device, channel, parameter }` * locator (channel as the numeric index or full channel address). */ type DataPointRef = string | { readonly device: string; readonly channel: number | string; readonly parameter: string; }; /** * A single device-configuration parameter (MASTER paramset), with the metadata * a configuration UI needs to render a form field for it. */ interface HmConfigParam { readonly parameter: string; readonly type: string; readonly min?: number; readonly max?: number; readonly default?: HmValue; readonly unit?: string; readonly valueList?: readonly string[]; /** Raw CCU `FLAGS` bitmask. */ readonly flags: number; /** True when `OPERATIONS & WRITE` is set. */ readonly writable: boolean; } /** The MASTER configuration parameters of a single channel. */ interface HmChannelConfig { readonly channelAddress: string; readonly params: HmConfigParam[]; } /** A climate (thermostat / heating-group) snapshot. */ interface HmClimate { readonly kind: 'climate'; /** Owning device address, e.g. `VCU0000001`. */ readonly device: string; /** Primary channel address, e.g. `VCU0000001:1`. */ readonly channel: string; readonly currentTemperature: number | null; readonly targetTemperature: number | null; readonly currentHumidity: number | null; readonly minTemp: number; readonly maxTemp: number; readonly targetTemperatureStep: number; readonly mode: 'auto' | 'heat' | 'off'; readonly preset: 'boost' | 'away' | 'week_program' | 'none'; readonly activity: 'heating' | 'idle' | 'off'; } /** An on/off switch snapshot. */ interface HmSwitch { readonly kind: 'switch'; readonly device: string; readonly channel: string; readonly isOn: boolean; } /** A dimmable light snapshot. */ interface HmLight { readonly kind: 'light'; readonly device: string; readonly channel: string; readonly isOn: boolean; /** Brightness 0..255, or `null` when unavailable. */ readonly brightness: number | null; } /** A cover/blind snapshot. */ interface HmCover { readonly kind: 'cover' | 'blind'; readonly device: string; /** The channel this entity is COMMANDED on. */ readonly channel: string; /** * Every channel the entity touches, command and status alike. * * An HmIP cover reports its position on the SHUTTER_TRANSMITTER channel and * is commanded on a SHUTTER_VIRTUAL_RECEIVER, so a consumer filtering * `valueChanged` by {@link channel} alone drops exactly the reports it wants. */ readonly channels: readonly string[]; /** * The subset of {@link channels} the entity READS from, when that differs * from where it is commanded. * * A consumer watching raw parameter events needs this and not just the * union: `LEVEL` exists on BOTH an HmIP cover's channels, so accepting both * and taking the last arrival lets the receiver's commanded extreme * overwrite the transmitter's real position. Take a parameter from a status * channel when it is available there. */ readonly statusChannels: readonly string[]; /** Position 0..100, or `null` when unavailable. */ readonly currentPosition: number | null; readonly isClosed: boolean; /** What the cover is doing right now, from its travel data point. */ readonly travel: 'opening' | 'closing' | 'stable' | 'unknown'; /** Slat tilt 0..100 (blinds only), or `null` when unavailable. */ readonly currentTiltPosition?: number | null; } /** A lock snapshot. */ interface HmLock { readonly kind: 'lock'; readonly device: string; readonly channel: string; readonly isLocked: boolean; } /** * A custom-entity snapshot — a discriminated union keyed by `kind`. An immutable * view of the entity's current state; issue commands through the facade methods. */ type HmCustomEntity = HmClimate | HmSwitch | HmLight | HmCover | HmLock; /** One radio gateway behind a BidCos interface (the CCU's own radio or a LAN gateway). */ interface HmRadioGateway { readonly address: string; readonly description: string | null; /** Duty cycle in percent (0..100), or `null` when not reported. */ readonly dutyCycle: number | null; readonly connected: boolean | null; readonly isDefault: boolean; readonly firmware: string | null; readonly type: string | null; } /** A CCU interface (BidCos-RF, HmIP-RF, VirtualDevices, ...) and its radio health. */ interface HmInterfaceInfo { /** Interface name as the CCU spells it, e.g. `HmIP-RF`. */ readonly name: string; /** XML-RPC port of the interface service, or `null` when unknown. */ readonly port: number | null; /** The CCU's short description of the interface, or `null`. */ readonly info: string | null; /** Whether the interface service / radio is reachable; `null` when it could not be told. */ readonly connected: boolean | null; /** Duty cycle in percent (0..100); `null` when the CCU did not report one. */ readonly dutyCycle: number | null; readonly firmware: string | null; readonly type: string | null; /** Radio gateways (BidCos only; empty for other interfaces). */ readonly gateways: readonly HmRadioGateway[]; } /** BidCos pairing flavour: `normal`, or `secure` (also teaches the HomeMatic Secure key). */ type HmInstallModeKind = 'normal' | 'secure'; /** Input of {@link Homematic.setInstallMode}. */ interface HmInstallModeRequest { /** Interface name, e.g. `HmIP-RF`. Must be one of the facade's configured interfaces. */ readonly interface: string; readonly on: boolean; /** Pairing window length in seconds (1..3600, default 60). Ignored when `on` is false. */ readonly seconds?: number; /** BidCos only. Defaults to the CCU's own default (normal). */ readonly mode?: HmInstallModeKind; } /** * Bit flags of {@link Homematic.deleteDevice}. OR them together, e.g. * `HM_DELETE_FLAGS.RESET | HM_DELETE_FLAGS.FORCE`. */ declare const HM_DELETE_FLAGS: { /** 0x01: reset the device to factory settings while removing it. */ readonly RESET: 1; /** 0x02: remove it even when it is not reachable. */ readonly FORCE: 2; /** 0x04: remove it the next time it is reachable. */ readonly DEFER: 4; }; /** A single active service message (`Servicemeldung`). */ interface HmServiceMessage { /** ReGa object id; pass to {@link Homematic.acknowledgeServiceMessage}. */ readonly id: string; /** Name of the alarm object as the CCU shows it, or `null`. */ readonly name: string | null; /** Device address (without the channel), or `null` when the message has no device. */ readonly address: string | null; /** Channel index the message came from (`0` = maintenance), or `null`. */ readonly channel: number | null; /** Message kind, e.g. `UNREACH`, `LOWBAT`, `CONFIG_PENDING`, `STICKY_UNREACH`. */ readonly type: string | null; /** When it came in, epoch milliseconds, or `null` when the CCU reported none. */ readonly timestamp: number | null; /** Whether the CCU lets an operator acknowledge it (sticky messages; the rest clear themselves). */ readonly acknowledgeable: boolean; } /** What the CCU says about itself. Each field is `null` when it did not answer. */ interface HmCcuInfo { /** Firmware version, e.g. `3.75.7`. */ readonly version: string | null; /** Raw `PRODUCT=` of the CCU's `/VERSION`, e.g. `ccu3`, `raspberrymatic`, `ova` (OpenCCU as a VM). */ readonly product: string | null; /** Derived family: `ccu3`, `openccu` (OpenCCU / RaspberryMatic, any platform) or `unknown`. */ readonly productFamily: 'ccu3' | 'openccu' | 'unknown'; /** Raw `PLATFORM=` of `/VERSION`, e.g. `ova`, `rpi4`. */ readonly platform: string | null; readonly serial: string | null; readonly hostname: string | null; } /** A channel that belongs to a {@link HmGroup}. */ interface HmGroupMember { /** Channel address, e.g. `000A9D89A7AF25:1`. */ readonly address: string; /** Channel type, e.g. `WALLMOUNTED_THERMOSTAT`. */ readonly type: string; } /** A heating group as the WebUI's "Gruppen" page shows it (read-only here). */ interface HmGroup { readonly id: number; readonly name: string; /** Group type id: `hmip.heating.group` (HmIP) or `HomeMatic.heating`. */ readonly type: string; readonly typeLabel: string | null; /** The virtual device that operates the group (`INT0000001`), when named. */ readonly deviceAddress: string | null; readonly forbidSingleOperation: boolean; readonly members: readonly HmGroupMember[]; } /** Input of {@link Homematic.createGroup}. */ interface HmGroupCreate { /** Group name (a `"` is replaced by `'`, as the WebUI does). */ readonly name: string; /** Group type id, e.g. `hmip.heating.group` or `HomeMatic.heating`. */ readonly type: string; /** Member channel addresses, e.g. `000A9D89A7AF25:1`. */ readonly members: readonly string[]; } /** Input of {@link Homematic.updateGroup}; at least one field is required. */ interface HmGroupUpdate { readonly name?: string; /** The full new member list (not a delta). */ readonly members?: readonly string[]; } /** * {@link ClimateEntity} — the climate custom-entity family, covering HmIP * thermostats (eTRV / wall thermostats / temperature+humidity sensors) and the * HmIP-HEATING groups, which share the same IP-thermostat semantics. * * Like every {@link CustomEntity} it owns no value state: getters read the * underlying {@link GenericDataPoint}s by {@link Field} role, and commands route * converted writes through the injected writer. Fields: * SETPOINT → SET_POINT_TEMPERATURE, TEMPERATURE → ACTUAL_TEMPERATURE, * HUMIDITY → HUMIDITY, SET_POINT_MODE (0 AUTO / 1 MANU / 2 AWAY), * CONTROL_MODE (the write/action mode dp: 0 AUTO / 1 MANU), BOOST_MODE, * ACTIVE_PROFILE (week-program index), LEVEL (valve %), STATE (valve open). */ /** Supported high-level operating modes. */ type ClimateMode = 'auto' | 'heat' | 'off'; /** * The public event map emitted by the {@link TypedEventEmitter} on the facade. * * Each key is an event name; its value type is the payload delivered to * listeners. `ready` has no payload (`void`) — see {@link TypedEventEmitter} * for the ergonomic `emit('ready')`-with-no-argument handling. */ /** Payload of a global `valueChanged` event. */ interface ValueChangedEvent { /** Stable data-point id (dpk encoded). */ readonly dpId: string; /** Device address, e.g. `VCU0000001`. */ readonly device: string; /** Channel address, e.g. `VCU0000001:1`. */ readonly channel: string; /** Parameter name, e.g. `STATE`. */ readonly parameter: string; /** New converted value. */ readonly value: HmValue; /** Previous converted value. */ readonly prevValue: HmValue; /** Epoch-ms timestamp of the change. */ readonly ts: number; } /** Payload of a device add/remove event. */ interface DeviceEvent { readonly device: string; } /** Payload of an interface connection-state change. */ interface ConnectionEvent { readonly interfaceId: string; readonly state: string; } /** The typed map of public events to their payloads. */ type HomematicEventMap = { valueChanged: ValueChangedEvent; deviceAdded: DeviceEvent; deviceRemoved: DeviceEvent; connection: ConnectionEvent; ready: void; error: Error; }; /** * {@link Homematic} — the public, transport-agnostic facade of the library. * * It wraps the internal {@link CentralUnit} (Phase 1 transport + Phase 2 device * graph + reconnection) and exposes a clean, event-driven surface: a global * `valueChanged` stream, lifecycle events, immutable device snapshots, a * validated `setValue`, and device-configuration (MASTER paramset) building * blocks. No transport/central/model types leak through its signatures. * * On {@link Homematic.start} it builds the domain model from the central's * registry, indexes every {@link GenericDataPoint} by id, and subscribes to the * central's {@link EventBus}, re-emitting each internal event as a typed public * event through the {@link TypedEventEmitter}. */ /** Local callback-server binding for the facade. */ interface HomematicCallback { readonly host: string; readonly port: number; } /** WebUI credentials for JSON-RPC name/room metadata. */ interface HomematicCredentials { readonly username: string; readonly password: string; } /** Cache directory / toggle. */ interface HomematicCache { readonly dir?: string; readonly enabled?: boolean; } /** Construction options for {@link Homematic}. */ interface HomematicOptions { /** CCU host name or IP. */ readonly host: string; /** Interface names, e.g. `'HmIP-RF'`, `'BidCos-RF'`. */ readonly interfaces: readonly string[]; readonly credentials?: HomematicCredentials; readonly callback: HomematicCallback; readonly cache?: HomematicCache; readonly tls?: boolean; /** Logical central name; defaults to `'nodehomematic'`. */ readonly centralName?: string; } declare class Homematic { #private; /** * Build a facade that owns a real {@link CentralUnit} for `options`. (Tests * inject a pre-built central / transport stubs through the non-exported * {@link createHomematicForTest}, which never widens this public signature.) */ constructor(options: HomematicOptions); /** Subscribe to a public event. Returns an unsubscribe function. */ on(event: K, listener: (payload: HomematicEventMap[K]) => void): () => void; /** Subscribe to a public event for a single delivery. */ once(event: K, listener: (payload: HomematicEventMap[K]) => void): () => void; /** Remove a previously-registered public event listener. */ off(event: K, listener: (payload: HomematicEventMap[K]) => void): void; /** Start the central, build the model from its registry, and subscribe. */ start(): Promise; /** Stop the central and clear all subscriptions and the model index. */ stop(): Promise; /** * An immutable snapshot of every known device. The `rooms`/`functions` carried * by each device are the union of the model's own metadata and the hub's * channel-address-keyed ReGa mapping (Phase 5), aggregated to the device. */ devices(): HmDevice[]; /** * Re-read device and channel names from the CCU WebUI, so a rename made on * the CCU (or a name given after pairing) shows in `devices()`. Keeps the * names it has when there are no WebUI credentials or the read fails. */ refreshNames(): Promise; /** Current value of a data point (resolving the ref). */ getValue(ref: DataPointRef): HmValue; /** * Validate + convert `value` against the data point's metadata (throwing * BEFORE any network call on an invalid value), then write it to the CCU. */ setValue(ref: DataPointRef, value: HmValue): Promise; /** * Trigger a firmware update for a device by its address (e.g. `001B9D89A09163`). * * Resolves the interface owning the device (the same routing used by * {@link Homematic.setValue}) and dispatches the standard XML-RPC * `installFirmware(address)` command on it. The promise resolves once the CCU * accepts the request — the actual flash runs asynchronously on the device and * its progress is reflected later by the descriptor's `firmwareUpdateState`. * Throws {@link ValidationError} for an unknown device, or a typed transport * error (e.g. `ClientError`) if the CCU/interface rejects the call (which the * caller can surface as "firmware update not supported"). */ installFirmware(deviceAddress: string): Promise; /** * Direct links of one channel, plus whether it has a central link. * * `links` is XML-RPC `getLinks(address, 0)` (`SENDER`, `RECEIVER`, `NAME`), * as read by aiohomematic `LinkCoordinator.get_device_links` * (`aiohomematic/central/coordinators/link.py`). `central` is * `Channel._has_central_link` (`aiohomematic/model/device.py`): * `getMetadata(address, "reportValueUsageData")` with `PRESS_SHORT > 0`. * A metadata fault yields `central: false` and does not fail the call; a * `getLinks` fault is a {@link ClientError}. */ getChannelLinkState(channelAddress: string): Promise; /** * Create the central link for one channel so the CCU pushes `PRESS_*` to * this client. Idempotent: when a central link already exists this returns * without a second call. * * Protocol: aiohomematic `Channel.create_central_link` * (`aiohomematic/model/device.py`) → `CcuBackend.report_value_usage` * (`aiohomematic/client/backends/ccu.py`) sends * `reportValueUsage(channelAddress, "PRESS_SHORT", 1)` on that channel's * interface. HmIP-RF and BidCos-RF use this same call; it is not `addLink` * to a central address. The value id and ref counter are * `REPORT_VALUE_USAGE_VALUE_ID` (`"PRESS_SHORT"`) and `1` in * `aiohomematic/const.py`. A `false` result or an XML-RPC fault is a * {@link ClientError}. * * aiohomematic only does this for channels with key-press events. This * method does it for any known channel address. */ createCentralLink(channelAddress: string): Promise; /** * Remove the central link for one channel. Idempotent: when none exists this * returns without a call. * * Protocol: aiohomematic `Channel.remove_central_link` * (`aiohomematic/model/device.py`) sends * `reportValueUsage(channelAddress, "PRESS_SHORT", 0)`. That method also * skips the call when JSON-RPC `Channel.hasProgramIds` is true * (`client/json_rpc.py` `has_program_ids`); this method does not, and clears * the link whenever the metadata counter is `> 0`. A `false` result or an * XML-RPC fault is a {@link ClientError}. */ removeCentralLink(channelAddress: string): Promise; /** * Make the CCU USE the given keys so a HmIP device sends their presses to the * access point: create the program `input.name`, or rewrite its conditions to * exactly `channelAddresses` x `parameters` (default short and long press). * Idempotent by name. The program has no destination; it exists only so the * CCU subscribes to the key data points (ReGa scripts and their eq-3/occu * sources: `central/rega/key-event-program.ts`). All channels must be on one * interface and the CCU must have their data points; a missing one is a * {@link ValidationError} naming it. Two programs with the same name are a * {@link ValidationError} listing their ids (`deleteProgram(id)` removes one). * Needs WebUI credentials. */ ensureKeyEventProgram(input: HmKeyEventProgramInput): Promise; /** Delete the key event program `name`; `removed: false` when it does not exist. A duplicate name is a {@link ValidationError}. Needs WebUI credentials. */ removeKeyEventProgram(name: string): Promise<{ removed: boolean; }>; /** * Delete one CCU program by its ReGa id (digits only). `removed: false` when * the id is missing or is not a program — nothing is deleted then. This is * the way out of two programs that share a name. Needs WebUI credentials. */ deleteProgram(programId: string): Promise<{ removed: boolean; }>; /** The key event program `name` and the channels it listens to, or `null`. A duplicate name is a {@link ValidationError}. Needs WebUI credentials. */ getKeyEventProgram(name: string): Promise; /** * The CCU programs whose conditions reference a key data point of any of * `keyAddresses` (`PRESS_SHORT` / `PRESS_LONG` / `PRESS_LONG_RELEASE`), in * ONE ReGa scan of all programs (chunked at 100 channels). It covers a * program written by hand on the CCU as well as one this library created. * Rejects (never answers `[]`) when the CCU cannot be read, so a caller can * tell "unknown" from "none". An address of no known device is a * {@link ValidationError}. Needs WebUI credentials. */ keyProgramReferences(keyAddresses: readonly string[]): Promise; /** * Read-only diagnosis of "why does a key of this device not deliver * `PRESS_SHORT` to this client?": for the device's key channels it collects * the XML-RPC side (central link, direct links, VALUES, MASTER, and the * maintenance channel `:0`), the ReGa side (channel and key data point * objects with their last update, and the programs that reference them; * needs WebUI credentials, otherwise `rega.available` is `false`) and what * this client itself received. Each section fails on its own with * `{ ok: false, error }`. Sources and semantics: `key-event-diagnosis.ts`. * Throws {@link ValidationError} for an unknown device or before `start()`. */ diagnoseKeyEvents(deviceAddress: string): Promise; /** * Create a direct link from `sender` to `receiver` (XML-RPC * `addLink(sender, receiver, name, description)` on the sender's interface, * as eq-3/occu `WebUI/www/api/methods/interface/addlink.tcl` forwards it). * Idempotent: when `getLinks(sender)` already lists the pair this returns * without a call and leaves the existing name and description unchanged. * The sender must be a known channel; a fault is a {@link ClientError}. */ addLink(sender: string, receiver: string, name?: string, description?: string): Promise; /** * Remove the direct link from `sender` to `receiver` (XML-RPC * `removeLink(sender, receiver)`, eq-3/occu `interface/removelink.tcl`). * Idempotent: when `getLinks(sender)` does not list the pair this returns * without a call — removing a link that does not exist is not an error. */ removeLink(sender: string, receiver: string): Promise; /** * Every direct link of a device or channel (XML-RPC `getLinks(address, 0)`; * a device address lists the links of all its channels) with `name`, * `description` and the resolved switch `profile`. The profile is read with * `getParamset(receiver, sender)` for each `KEY_TRANSCEIVER` → * `SWITCH_VIRTUAL_RECEIVER` link between known channels and is `null` for any * other link (see {@link Homematic.getLinkProfile}). A failed read is a * {@link ClientError}. */ listLinks(deviceOrChannelAddress: string): Promise; /** * The switch profile of one existing link: short and long press each * `toggle | on | off | none`, or `{ kind: 'custom' }` when the receiver * paramset matches no catalogue entry exactly (catalogue and sources: * `src/api/link-profile.ts`, from eq-3/occu * `WebUI/www/config/easymodes/SWITCH_VIRTUAL_RECEIVER/KEY_TRANSCEIVER.tcl`). * `null` when the link is not `KEY_TRANSCEIVER` → `SWITCH_VIRTUAL_RECEIVER`. * An unknown link is a {@link ValidationError}. */ getLinkProfile(sender: string, receiver: string): Promise; /** * Write a catalogue profile to a key → switch link: ONE * `putParamset(receiver, sender, values)` with exactly the parameters the * two actions define (`none` writes only `PROFILE_ACTION_TYPE = 0`). Refused * with a {@link ValidationError}, before any write, when the link does not * exist, is not `KEY_TRANSCEIVER` → `SWITCH_VIRTUAL_RECEIVER`, or currently * reads `custom` — a custom link is never rewritten. */ setLinkProfile(sender: string, receiver: string, actions: HmSwitchLinkActions): Promise; /** * Rename a device and, with `renameChannels`, every channel of it to * `:` (the CCU's own channel-name pattern). ReGa script * over `ReGa.runScript` doing what JSON-RPC `Device.setName` / * `Channel.setName` do (eq-3/occu `WebUI/www/api/methods/device/setname.tcl`). * Resolves with the names the CCU stored (it keeps names unique); `devices()` * shows them from then on. Needs WebUI credentials. */ renameDevice(address: string, name: string, options: HmRenameDeviceOptions): Promise; /** Rename one channel (as JSON-RPC `Channel.setName`); resolves with the stored name. Needs WebUI credentials. */ renameChannel(address: string, name: string): Promise; /** * Every CCU room with its member channel addresses, read live (ReGa walk of * `ID_ROOMS`, as JSON-RPC `Room.getAll`). `HmDevice.rooms` is the snapshot * taken at `start()`. Needs WebUI credentials. */ listRooms(): Promise; /** Create an empty room (eq-3/occu `rega/esp/rooms.fn` `createRoomRetId`); a duplicate name is refused. Needs WebUI credentials. */ createRoom(name: string): Promise; /** Rename a room by its id (`rooms.fn` `changeRoomName`). Needs WebUI credentials. */ renameRoom(roomId: string, name: string): Promise; /** Delete a room by its id (`rega/esp/system.fn` `DeleteObject`). Needs WebUI credentials. */ deleteRoom(roomId: string): Promise; /** Add a channel to a room (as JSON-RPC `Room.addChannel`, by address). Needs WebUI credentials. */ addChannelToRoom(roomId: string, channelAddress: string): Promise; /** Remove a channel from a room (as JSON-RPC `Room.removeChannel`, by address). Needs WebUI credentials. */ removeChannelFromRoom(roomId: string, channelAddress: string): Promise; /** * Every interface the CCU offers (BidCos-RF, HmIP-RF, VirtualDevices, ...) * with connection state, duty cycle, firmware and type where the CCU reports * them. A value the CCU did not answer is `null`, never `0`. Needs a started * facade. * * CCU methods: JSON-RPC `Interface.listInterfaces` / `Interface.isPresent` * (eq-3/occu `WebUI/www/api/methods/interface/`), XML-RPC * `listBidcosInterfaces` on BidCos-RF, JSON-RPC `Interface.getDutyCycle` * (RaspberryMatic / OpenCCU only) for the HmIP access point. */ listInterfaces(): Promise; /** * Open (default 60 s, 1..3600) or close the pairing window of a configured * interface. XML-RPC `setInstallMode`; `mode: 'secure'` (BidCos only) also * teaches the HomeMatic Secure key. */ setInstallMode(request: HmInstallModeRequest): Promise; /** Seconds left of an interface's pairing window (`null` when the CCU's answer was unusable). XML-RPC `getInstallMode`. */ getInstallMode(interfaceName: string): Promise; /** * Remove a device from its interface (XML-RPC `deleteDevice`). `flags` is an OR * of {@link HM_DELETE_FLAGS}: `RESET` (0x01, factory reset), `FORCE` (0x02, * remove even when unreachable), `DEFER` (0x04, remove when next reachable); * `0` is a plain removal. The model drops the device once the CCU reports it * through the `deleteDevices` callback. Throws {@link ValidationError} for an * unknown device or invalid flags. */ deleteDevice(deviceAddress: string, flags?: number): Promise; /** * The CCU's active service messages (UNREACH, LOWBAT, CONFIG_PENDING, * STICKY_UNREACH, ...). Needs WebUI credentials. ReGa script over * `ReGa.runScript` (eq-3/occu `WebUI/www/rega/esp/system.fn`, `ID_SERVICES`). */ serviceMessages(): Promise; /** Acknowledge a service message by its `id` (ReGa `AlReceipt`, as the WebUI does). Needs WebUI credentials. */ acknowledgeServiceMessage(id: string): Promise; /** * Version, product (CCU3 / RaspberryMatic / OpenCCU), serial and hostname. * Needs WebUI credentials. JSON-RPC `CCU.getVersion`, `CCU.getSerial` * (eq-3/occu `WebUI/www/api/methods/ccu/`) plus a ReGa read of `/VERSION`. */ ccuInfo(): Promise; /** * The CCU's heating groups ("Gruppen"): HmIP heating groups and HomeMatic * heating groups with their member channels. Writes are separate and * undocumented: {@link Homematic.createGroup}, `updateGroup`, `deleteGroup`. * JSON-RPC `CCU.getHeatingGroupList` (eq-3/occu * `WebUI/www/api/methods/ccu/getheatinggrouplist.tcl`). Needs WebUI credentials. */ groups(): Promise; /** * Create a heating group (`type` e.g. `hmip.heating.group`, `members` channel * addresses). Resolves with the group as read back from the CCU; a write the * read-back does not show rejects with `GroupWriteVerificationError`. * * UNDOCUMENTED and firmware-dependent: no CCU API exists for this, so the call * reproduces the WebUI's own HMServer page requests (eq-3/occu * `HMserver/opt/HMServer/pages/GroupEditPage.ftl`, `GroupListPage.ftl`). * Needs WebUI credentials. */ createGroup(input: HmGroupCreate): Promise; /** Rename a group and/or replace its member list (same caveats as {@link Homematic.createGroup}). */ updateGroup(id: number, patch: HmGroupUpdate): Promise; /** Delete a group, verified by the read-back (same caveats as {@link Homematic.createGroup}). */ deleteGroup(id: number): Promise; /** * The MASTER configuration parameters of a channel, with the metadata needed * to render a form. Empty array when nothing is known for the channel. */ getConfigParams(channelAddress: string): HmConfigParam[]; /** Read and convert the current MASTER configuration values of a channel. */ getConfig(channelAddress: string): Promise>; /** * Validate + convert every value against its MASTER spec (throwing BEFORE any * network call on an invalid/unknown parameter), then write them all in ONE * `putParamset`. */ setConfig(channelAddress: string, values: Record): Promise; /** * An immutable snapshot of every known system variable (empty when no hub / * credentials). Refreshed at {@link Homematic.start} and {@link Homematic.refreshHub}. */ systemVariables(): HmSysVar[]; /** Read a single system variable's current value by name. Throws if no hub. */ getSystemVariable(name: string): Promise; /** * Write a system variable by name. Validates against the snapshot BEFORE any * network call: an unknown or read-only variable throws {@link ValidationError} * (no write is attempted). Throws if no hub. */ setSystemVariable(name: string, value: HmValue): Promise; /** * An immutable snapshot of every known program (empty when no hub). Refreshed * at {@link Homematic.start} and {@link Homematic.refreshHub}. */ programs(): HmProgram[]; /** Execute a program, resolved by id or name from the snapshot. Throws if no hub. */ runProgram(idOrName: string): Promise; /** Enable/disable a program, resolved by id or name. Throws if no hub. */ setProgramActive(idOrName: string, active: boolean): Promise; /** Re-fetch the system-variable and program snapshots from the hub. Throws if no hub. */ refreshHub(): Promise; /** * An immutable snapshot of every live custom entity (Climate / Switch / Light * / Cover / Lock), each mapped to its public {@link HmCustomEntity} shape by * reading the entity's current getters. No functions leak into the snapshot; * issue commands through the typed command methods below. */ customEntities(): HmCustomEntity[]; /** Set a climate entity's target temperature (clamped to its range). */ climateSetTemperature(device: string, channel: string | number, temperature: number): Promise; /** Set a climate entity's operating mode. */ climateSetMode(device: string, channel: string | number, mode: ClimateMode): Promise; /** Enable or disable a climate entity's boost mode. */ climateSetBoost(device: string, channel: string | number, on: boolean): Promise; /** Turn a switch entity on. */ switchTurnOn(device: string, channel: string | number): Promise; /** Turn a switch entity off. */ switchTurnOff(device: string, channel: string | number): Promise; /** Turn a light entity on (full brightness, or `brightness` 0..255 when given). */ lightTurnOn(device: string, channel: string | number, brightness?: number): Promise; /** Turn a light entity off. */ lightTurnOff(device: string, channel: string | number): Promise; /** Set a light entity's brightness (0..255). */ lightSetBrightness(device: string, channel: string | number, brightness: number): Promise; /** Open a cover entity fully. */ coverOpen(device: string, channel: string | number): Promise; /** Close a cover entity fully. */ coverClose(device: string, channel: string | number): Promise; /** Stop a cover entity where it is. */ coverStop(device: string, channel: string | number): Promise; /** Move a cover entity to `position` (0..100). */ coverSetPosition(device: string, channel: string | number, position: number): Promise; /** Lock a lock entity. */ lockLock(device: string, channel: string | number): Promise; /** Unlock a lock entity. */ lockUnlock(device: string, channel: string | number): Promise; /** Release a lock entity's latch (open). */ lockOpen(device: string, channel: string | number): Promise; } /** * Error taxonomy for the transport layer, ported from aiohomematic's exception * hierarchy. All errors extend {@link BaseHomematicError}. Mapping helpers turn * raw XML-RPC faults, JSON-RPC errors and low-level transport failures into the * appropriate typed error. */ /** Root of the library error hierarchy. */ declare class BaseHomematicError extends Error { constructor(message?: string); } /** * A login was not sent because the previous ones failed and the backoff window * is still open. Nothing reached the CCU. `retryAt` (epoch ms, on the session * manager's clock) is when the next real attempt may go out. */ declare class LoginBackoffError extends BaseHomematicError { /** When the next real login attempt may go out (epoch ms). */ readonly retryAt: number; /** Consecutive failed logins so far. */ readonly failures: number; constructor(retryAt: number, failures: number); } /** * The CCU answered with an HTTP 5xx (typically 503 while it is still booting). * Transient: the call may succeed once the CCU is up. */ declare class BackendUnavailableError extends BaseHomematicError { /** The HTTP status code the CCU answered. */ readonly status: number; constructor(status: number, message: string); } export { BackendUnavailableError, type ConnectionEvent, type DataPointRef, type DeviceEvent, HM_DELETE_FLAGS, type HmCcuInfo, type HmChannel, type HmChannelConfig, type HmChannelLink, type HmChannelLinkState, type HmClimate, type HmConfigParam, type HmCover, type HmCustomEntity, type HmCustomLinkProfile, type HmDataPoint, type HmDevice, type HmDeviceRename, type HmDiagnosisSection, type HmGroup, type HmGroupCreate, type HmGroupMember, type HmGroupUpdate, type HmInstallModeKind, type HmInstallModeRequest, type HmInterfaceInfo, type HmKeyCentralLink, type HmKeyChannelClientState, type HmKeyChannelDiagnosis, type HmKeyChannelXmlRpc, type HmKeyDeviceMaintenance, type HmKeyEventDiagnosis, type HmKeyEventParameter, type HmKeyEventProgram, type HmKeyEventProgramInput, type HmKeyEventProgramResult, type HmKeyInterfaceClientState, type HmKeyParameterClientState, type HmKeyProgramReference, type HmKeyRegaChannel, type HmKeyRegaDatapoint, type HmKeyRegaDiagnosis, type HmKeyRegaProgram, type HmKeyRegaState, type HmLight, type HmLink, type HmLinkPressAction, type HmLinkProfile, type HmLock, type HmNamedObject, type HmParamsetValues, type HmProgram, type HmRadioGateway, type HmRenameDeviceOptions, type HmRoom, type HmServiceMessage, type HmSwitch, type HmSwitchLinkActions, type HmSwitchLinkProfile, type HmSysVar, type HmValue, Homematic, type HomematicCache, type HomematicCallback, type HomematicCredentials, type HomematicEventMap, type HomematicOptions, LIBRARY_NAME, LoginBackoffError, type ValueChangedEvent };