Skip to content

aruder77/openhab2-javascript

 
 

Repository files navigation

openHAB 2.x: JSR223 JavaScript Code since 2.4

This is a repository of very experimental JavaScript code that can be used with the SmartHome platform and openHAB 2.x.

Applications

The JSR223 scripting extensions can be used for general scripting purposes, including defining rules with JavaScript Code for openHAB 2 JSR223 Scripting.

Installation

Copy Files into /etc/openhab2/automation/jsr223

Defining Rules

OpenHAB 2 JSR223 Scripting Documentation: JSR223 Scripting and Rule Support.

Further links and information: openHAB 1 Scripted Rule Support.

Rules: Raw ESH API

Simplified with some extra JavaScript Code, found in jslib/JSRule.js:

'use strict';
load('/etc/openhab2/automation/jsr223/jslib/JSRule.js');

JSRule({
    name: "My JS Rule",
    description: "Line:"+__LINE__,
    triggers: [
        TimerTrigger("0/15 * * * * ?")//Enable/Disable Rule
    ],
    execute: function( module, input){
        print("################ module:", module);
        postUpdate(getItem("testItemSwitch"), ON);
        sendCommand(getItem("testItemSwitch"), OFF);
    }
});

jslib/helper.js contains more simplifying and helping functions.

jslib/PersistenceExtensions.js contains more simplifying PersistenceExtensions functions.

jslib/triggersAndConditions.js contains trigger functions.

ActionExamples.js contains examples for default actions like PersistenceExtensions, HTTP, Ping, Audio, Voice, ThingAction.

itemTest.js contains examples for testing Items and Groups.

About

JSR223 JavaScript Code openHAB 2.x automation

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 100.0%