TypeScript helper library for jsscripting with IntelliSense support in Visual Studio Code

With openHAB 3.1 and 3.2 the jsscripting automation is the way to go with JavaScript. I’ve updated my library from 2018 to reflect the latest developments. You can use TypeScript or JavaScript to write your own rules. I use Visual Studio Code to used the IntelliSense feature provided by my library with many type definitions for the openHAB 3.2 core.

If you mean that there is already a library, yes, that is correct. A part of the library is also based on the library that is now included in openHAB 3.2.
My variant, however, had TypeScript as its target and only offers the basic functionalities. Nothing is wrapped, but instead the native openHAB Java objects are always used. Just a slightly different approach. But we are already discussing whether TypeScript could be an option for the standard library. Until then I use this library for myself and maybe others are interested.


Just install the library from github with npm within the automation/js folder.

npm install csowada/openhab-jsscripting-base --no-save


const {getLogger, createRule, TimeOfDayTrigger, postUpdate, DateTimeType} = require("openhab-jsscripting-base");
const logger = getLogger("my-logger");

const rule0 = createRule({
    name: "Set todays date",
    description: "Set the new date after midnight",
    tags: ["Date", "Today"],
    triggers: [
    execute: (action, input) => {
        postUpdate("Today", new DateTimeType());

More details on github

1 Like