homematic-js-xmlapi
A nodejs module for connecting a Homematic CCU with an installed XML-API addon.
The module addresses the XML API and provides the required interfaces and data types in JS. It is released as npm module under homematic-js-xmlapi
Interfaces currently implemented
- devicelist.cgi
- state.cgi
- statelist.cgi
- statechange.cgi
- sysvar.cgi
- sysvarlist.cgi
- version.cgi
Usage
Install
npm install homematic-js-xmlapi
Basic Usage
; // initialise the API Connection;; // get all devices xmlApi.getDeviceList.then; // get single state value xmlApi.getState'1481'.then;
Example of the update implementation for receiving the data without using DeviceManager
;
More Examples
More examples and details in exampe.ts
You can also check my own project for detailed usage example and inspiration https://github.com/jenszech/hm-node-runner
Dokumentation
Klassen
XmlApi
The XmlApi class provides the XML connector for the homematic xml addon. The class provides a separate function for each call, which returns a corresponding JS data object.
Constructor usage
;const xmlApi = "1.1.1.1" 80;
Api functions
; // Get XML Addon Verion// return Promise<number | null>xmlApi; // Get all devices ...// return Promise<Device[] | null>xmlApi; // Get a single device state ... // return Promise<Device[] | null>xmlApi; // Get all device states ...// return Promise<Device[] | null> xmlApi; // Get a single SystemVariable value ... // return Promise<SystemVariable[] | null>xmlApi; // Get all SystemVariable values ...// return Promise<SystemVariable[] | null> xmlApi;
DeviceManager
Constructor usage
;const devMgr = ;
Api functions
// Add or Update a single Device// Parameter: DevicedevMgr; // Add or Update a list of Devices// Parameter: Device[]devMgr; // Get actual count of known devicesdevMgr; // Get the actual cached device with given device name// Parameter: name: string // return Device | nulldevMgr; // Get the actual cached Channel with given Channel name// Parameter: name: string // return Channel | nulldevMgr; // Get the actual cached Datapoint with given DataType from given Channel// Parameter: channel : Channel// Parameter: type : DataType // return Channel | nulldevMgr; // print a complete list of all kown devices to console devMgrprintDeviceList // print a complete list of all kown devices grouped and counted by deviceType to consoledevMgr;
SystemVariableManager
Constructor usage
;const sysMgr = ;
Api functions
// Add or Update a single Variable// Parameter: SystemVariablesysMgr; // Add or Update a list of variables// Parameter: SystemVariable[]sysMgr; // Get actual count of known variablessysMgr; // Get the actual cached device with given variable name// Parameter: name: string // return SystemVariable | nullsysMgr; // print a complete list of all kown variables to console sysMgr;
Data Object
The library automatically converts the XML response into different JS data objects. The following data types are provided:
Device name: string; iseId: string; unreach: boolean; stickyUnreach: boolean; configPending: boolean; address: string | null; deviceType: string | null; channel: Map<string Channel> = ;
Channel name: string; iseId: string; address: string | null; dataPoint: Map<DataType DataPoint> = ;
DataPoint name: string; iseId: string; type: DataType; value: string; valueType: ValueType; timestamp: Date | null;
SystemVariable name: string; iseId: string; value: string | number | boolean | null; valueList: string; valueType: number; timestamp: Date | null;
Development and build pipeline
Release a new version
npm version major|minor|patch
npm publish
Further documentation
Homematic XML-API CCU Addon
https://github.com/jens-maus/XML-API
Step by step: Building and publishing an NPM Typescript package.
https://itnext.io/step-by-step-building-and-publishing-an-npm-typescript-package-44fe7164964c
License
See the LICENSE file for license rights and limitations (MIT).