Tools for the openHAB JavaScript Automation Add-On.

Overview

openHAB JS Automation Tools

This library provides some utilites for the openHAB JS Scripting Add-On. The JavaScript Add-On is using the NodeJS version found in openhab/openhab-addons/bundles/org.openhab.automation.jsscripting/pom.xml (currently v12.16.1).

Please note that it depents on the openHAB JavaScript Library, which is included in the JS Scripting Add-On by default. Therefore it is not listed in the dependencies of this package.

js-semistandard-style npm version

Table of Contents


Installation

  • Install the openHAB JavaScript binding, a version of the openHAB library will be automatically installed and available to all javascript rules by default.
  • Go to the javascript user scripts directory: cd $OPENHAB_CONF/automation/js
  • Run npm i florianh-openhab-tools (you may need to install npm)

Scene Engine

Call scene by sending a command to the sceneItem.

When a member of the scene changes it's state, the rule will check whether a defined scene is matching the current states and which scene.

It creates a full rule with triggers and actions out of your scene definition.

The sceneItem

Must be a Number item. You can assign a scene to every positive integer value, except to 0.

0 is the value the Item gets when no match with a scene is found on members change.

Scene definition

Scene defintion works with an array of objects.

const scenes = [ // For each sceneItem one object.
  { // Object of the first sceneItem.
    selectorItem: 'scene call item name',
    selectorStates: [ // For each numeric state of the sceneItem one object.
      { // Object for the value 1 of the sceneItem.
        selectorValue: 1,
        sceneTargets: [ // Target states of items in the scene. Parameters explained later.
          { item: 'Florian_Licht', value: 'ON', required: true },
          { item: 'Florian_LED_Stripes', value: 'OFF', required: false }
        ] 
      },
      { // Object for the value 15 of the sceneItem.
        selectorValue: 15,
        sceneTargets: [ // Target states of items in the scene. Parameters explained later.
          { item: 'Florian_LED_Stripes', value: 'ON', required: true }
        ]
      }
    ]
  }
];

sceneTargets' parameters

Identifier Purpose Type Required
item Name of a scene member. String yes
value Target state of that member. String yes
required Whether that member must match the target state when the scene is checked. Boolean no, defaults to true

Scene rule

NOTE: The sceneEngine was developed for file-based JavaScript rules, therefore create a script in the directory $OPENHAB_CONF/automation/js and not in the UI.

require('florianh-openhab-tools').rules.getSceneEngine(scenes, engineId);
Parameter Purpose required
scenes The scene definition array of objects. yes
engineId The id of the scene engine, used in description. yes

Group Utilities

The Group Utilities provide a number of functions on groups, e.g. arithmetic operations like min/max and count operations.

For supported methods look at the GroupUtils JSDoc.

These are a GraalJS compatible fork of the my original groupUtils from rkoshak/openhab-rules-tools.

Examples

const { itemutils } = require('florianh-openhab-tools');
// The name of the member with the maximum state.
itemutils.getGroup(group).membersMax.name;
// The sum of states.
itemutils.getGroup(group).membersSum;
// Count how many members are on.
itemutils.getGroup(group).membersCount(item => item.state === 'ON');
Comments
  • build(deps): bump minimist from 1.2.5 to 1.2.6

    build(deps): bump minimist from 1.2.5 to 1.2.6

    Bumps minimist from 1.2.5 to 1.2.6.

    Commits

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    • @dependabot use these labels will set the current labels as the default for future PRs for this repo and language
    • @dependabot use these reviewers will set the current reviewers as the default for future PRs for this repo and language
    • @dependabot use these assignees will set the current assignees as the default for future PRs for this repo and language
    • @dependabot use this milestone will set the current milestone as the default for future PRs for this repo and language

    You can disable automated security fix PRs for this repo from the Security Alerts page.

    dependencies 
    opened by dependabot[bot] 1
  • Adapt to `timerMgr` Duration strings now only support ISO standard

    Adapt to `timerMgr` Duration strings now only support ISO standard

    Since timerMgr is now using openhab-js's time.toZDT, the accepted duration strings have changed. This change breaks the usage of timerMgr in this library.

    See https://github.com/openhab/openhab-js#time for more information about which duration strings are supported.

    bug 
    opened by florian-h05 0
  • [rules] Add heatalarm & frostalarm to alerting rules

    [rules] Add heatalarm & frostalarm to alerting rules

    Improvements

    • the heat-/frostalarm rule from https://github.com/florian-h05/openhab-conf/blob/937fa27c6ad5a77098930568dabfcad242da8ae6/automation/js/Alerting_frost-heatalarm.js

    Breaking changes

    • Rainalarm was moved from rulesx to rulesx.alerting
    enhancement 
    opened by florian-h05 0
  • [rulesx] Add rainalarm rule

    [rulesx] Add rainalarm rule

    This PR adds:

    • a function to itemutils that determines the level of openess for an roofwindow
    • the rainalarm rule from https://github.com/florian-h05/openhab-conf/blob/ec37483cb8b2332e5e89706ca987eb0315af7703/automation/js/Alerting.js to the rulesx namespace
    enhancement 
    opened by florian-h05 0
  • alarmClock: Catch NaN for hour/minute

    alarmClock: Catch NaN for hour/minute

    Fixes #9 where uninitialised hour/minute Items were parsed as NaN in the cron expression and led to errors in openhab-core.

    Initialises hour/minute in case their are NaN with default value.

    Additional refactorings were made.

    opened by florian-h05 0
  • alarmClock: Uninitialized hour/minutes Items are uncaught

    alarmClock: Uninitialized hour/minutes Items are uncaught

    When the hour or minute Item is unitialized, getClockRule() generates a cron expression like 0 NaN NaN ? * MON *, which leads to openHAB errors.

    To avoid that, hour and minute must be checked for NaN. getClockRule() may initialize hour/minute with a default value as the user cannot set those values in the openHAB iOS app or MainUI and needs either an Android device or the REST API in that case.

    bug enhancement 
    opened by florian-h05 0
  • sceneEngine.js: Introduce conditions & Refactorings

    sceneEngine.js: Introduce conditions & Refactorings

    Additions

    Introduce conditionFn which allows to use a expression to evaluate whether a scene target is valid now.

    Breaking Changes

    • Create one scene engine rule per controller Item and not one rule for multiple (should increase performance as rule triggers are more fine grained).
    • Refactoring/Renaming of the sceneDefinition.
    opened by florian-h05 0
  • Move from GitHub packages to npm

    Move from GitHub packages to npm

    … because installing package from GitHub Packages only works well when you are signed in. Now, I have an npm org @hotzware to publish packages under scope.

    Signed-off-by: Florian Hotze [email protected]

    opened by florian-h05 0
Releases(v1.4.0)
  • v1.4.0(May 16, 2022)

    What's Changed

    • alarmClock.: Always format time string as HH:mm.
    • sceneEngine: Introduce conditions & Update sceneDefinition in #8.
    • dimmer: Apply workaround to avoid never ending dimmers.
    • alarmClock: Catch NaN for hour/minute in #10.

    Breaking Changes

    • sceneEngine: New sceneDefiniton as described in README/JSDoc in #8.

    Full Changelog: https://github.com/florian-h05/openhab-js-tools/compare/v1.3.3...v1.4.0

    Source code(tar.gz)
    Source code(zip)
  • v1.3.3(Apr 1, 2022)

    Patch Release

    The following improvements were made: Component | Description -|- dimme.js | Use Map instead of Object for cache. dimme.js | Allow overwriting existing dimmers dimme.js | Check params for type. sceneEngine.js | Exclude Items (scene members) not required from triggers. Dev dependency minimist | Bump from 1.2.5 to 1.2.6 due to security vulnerability.

    Full Changelog: https://github.com/florian-h05/openhab-js-tools/compare/v1.3.2...v1.3.3

    Source code(tar.gz)
    Source code(zip)
  • v1.3.2(Feb 13, 2022)

    Patch Release

    The following fixes were made: Feature | Description -|- dimmer | Fix issues with cancellation & cache handling. dimmer | Add docs for script unloading. general | Update logger ids for new package scope.

    Full Changelog: https://github.com/florian-h05/openhab-js-tools/compare/v1.3.0...v1.3.2

    Source code(tar.gz)
    Source code(zip)
  • v1.3.1-1(Feb 12, 2022)

  • v1.3.0(Feb 12, 2022)

    Feature Release

    The following new features were added: Feature | Description -|- itemutils| Add dimmer module to dim items step-by-step to target state by @florian-h05 in https://github.com/florian-h05/openhab-js-tools/pull/4.

    The following improvements were made: Feature | Description -|- Logging | Changed log levels & identifiers. JSDoc comments | Fixed issues with wrong tags. openhab-js | Bump development dependency to v1.2.2, but use v1.2.1 for production (openHAB 3.2.0 stable is on v1.2.1).

    Full Changelog: https://github.com/florian-h05/openhab-js-tools/compare/v1.2.6...v1.3.0

    Source code(tar.gz)
    Source code(zip)
  • v1.2.6(Jan 16, 2022)

    Patch Release

    The following improvements were made: Feature | Description -|- sceneEngine | Refactoring to decrease size.

    Full Changelog: https://github.com/florian-h05/openhab-js-tools/compare/v1.2.5...v1.2.6

    Source code(tar.gz)
    Source code(zip)
  • v1.2.5(Jan 10, 2022)

  • v1.2.4(Jan 10, 2022)

    Patch Release with breaking changes

    Please note that the package has moved from npm to GitHub.

    The following fixes were made: Feature | Description -|- sceneEngine | Sent the first matching scene to the selector (instead of the last). sceneEngine | Check all scenes of a selectorItem on change of any member. This allows to recognize a matching scene even when the rule trigger is no member of this scene.

    Full Changelog: https://github.com/florian-h05/openhab-js-tools/compare/v1.2.3...v1.2.4

    Source code(tar.gz)
    Source code(zip)
  • v1.2.3(Dec 22, 2021)

    Patch Release

    The following fixes & improvements were made: Feature | Description -|- alarmClock | On module call, only create the alarm clock if switchItem is ON. alarmClock | Fix bad style of Time string: when minutes < 10, the 0 before the minute was missing. alarmClock | Fix errors at module call.

    Full Changelog: https://github.com/florian-h05/openhab-js-tools/compare/v1.2.2...v1.2.3

    Source code(tar.gz)
    Source code(zip)
  • v1.2.2(Dec 21, 2021)

    Patch Release

    The following fixes were made: Feature | Description -|- itemutils | Fix wrong path.

    Full Changelog: https://github.com/florian-h05/openhab-js-tools/compare/v1.2.1...v1.2.2

    Source code(tar.gz)
    Source code(zip)
  • v1.2.1(Dec 21, 2021)

    Patch Release

    The following fixes were made: Feature | Description -|- alarmClock | Post time string to Item.

    Full Changelog: https://github.com/florian-h05/openhab-js-tools/compare/v1.2.0...v1.2.1

    Source code(tar.gz)
    Source code(zip)
  • v1.2.0(Dec 21, 2021)

    Feature Release

    The following new features were added: Feature | Description -|- alarmClock | Provides an alarm clock that is configured via Items.

    Breaking Changes

    Following changes were made: Feature | Description -|- sceneEngine | Moved from namespace rules to namespace rulesx. LICENSE | Changed from MIT to EPL-2.0.

    Full Changelog: https://github.com/florian-h05/openhab-js-tools/compare/v1.1.2...v1.2.0

    Source code(tar.gz)
    Source code(zip)
  • v1.1.2(Dec 20, 2021)

    Breaking Changes

    Following changes were made: Feature | Description -|- sceneEngine| Moved from namespace sceneEngine to namespace rules. groupUtils| Moved from namespace itemUtils to itemutils.

    Full Changelog: https://github.com/florian-h05/openhab-js-tools/compare/v1.1.1...v1.1.2

    Source code(tar.gz)
    Source code(zip)
  • v1.1.1(Dec 19, 2021)

    Patch Release

    The following improvements were made: Feature | Description -|- GroupUtils | Changed namespace items to itemUtils. README | Add examples for GroupUtils.

    Full Changelog: https://github.com/florian-h05/openhab-js-tools/compare/v1.1.0...v1.1.1

    Source code(tar.gz)
    Source code(zip)
  • v1.1.0(Dec 19, 2021)

    Feature Release

    The following new features were added: Feature | Description -|- GroupUtils | Added the GroupUtils and it‘s docs.

    The following improvements were made: Feature | Description -|- Infrastructure | Change node version to the node version GraalJS uses. README | Added a note about the node version used in GraalJS. JSDoc | Fix comments to not duplicate docs of classes.

    Full Changelog: https://github.com/florian-h05/openhab-js-tools/compare/v1.0.5...v1.1.0

    Source code(tar.gz)
    Source code(zip)
  • v1.0.5(Dec 18, 2021)

    Patch Release

    The following improvements were made: Feature | Description -|- scriptEngine | sceneTargets‘ required defaults to true. README | Improve scriptEngine docs README | Add badges scriptEngine | Reduce logging. README | Fix scriptEngine example. scriptEngine | Solve issue with ItemStateChangeTrigger multiple times for one item. scriptEngine | Limit logging by disabling parts of. DEBUG level does not work as it is set for JSScripting. scriptEngine | Fixes an issue, where a selectorItem was updated to 0 when a member of another selectorItem changed.

    Full Changelog: https://github.com/florian-h05/openhab-js-tools/compare/v1.0.0...v1.0.5

    Source code(tar.gz)
    Source code(zip)
  • v1.0.0(Dec 18, 2021)

    The first release of the openhab-js-tool.

    New Features: | Feature | Description | | - | - | | scriptEngine | Creates a rule for providing scenes. |

    Full Changelog: https://github.com/florian-h05/openhab-js-tools/commits/v1.0.0

    Source code(tar.gz)
    Source code(zip)
Owner
Florian Hotze
🏠 smart home fan @openhab
Florian Hotze
Hemsida för personer i Sverige som kan och vill erbjuda boende till människor på flykt

Getting Started with Create React App This project was bootstrapped with Create React App. Available Scripts In the project directory, you can run: np

null 4 May 3, 2022
Kurs-repo för kursen Webbserver och Databaser

Webbserver och databaser This repository is meant for CME students to access exercises and codealongs that happen throughout the course. I hope you wi

null 14 Jan 3, 2023
A new generation GUI automation framework for Web and Desktop Application Testing and Automation.

Clicknium-docs Clicknium is a new generation GUI automation framework for all types of applications. It provides easy and smooth developer experience

null 109 Dec 19, 2022
This repo contains utility tools for manipulating files, process images and automation.

utility-tools-cli This repo contains utility tools which makes life lil bit easier. Features Rename Files in a Folder with the convention you want. Re

Wasim Raja 4 Nov 4, 2022
This is college project in which me and my team create a website that provide the tools for basic text modification and add todos also we add blog init.

Getting Started with Create React App This project was bootstrapped with Create React App. Available Scripts In the project directory, you can run: np

Ayush 4 Jun 9, 2022
🛠 Solana Web3 Tools - A set of tools to improve the user experience on Web3 Solana Frontends.

?? Solana Web3 Tools - A set of tools to improve the user experience on Web3 Solana Frontends.

Holaplex 30 May 21, 2022
Annotation tools for the web. Select text, images, or (nearly) anything else, and add your notes.

Annotator Annotator is a JavaScript library for building annotation applications in browsers. It provides a set of interoperable tools for annotating

Open Annotation 2.6k Dec 23, 2022
Solana blockchain candy machine app boilerplate on top of Metaplex Candy Machine. NextJS, Tailwind, Anchor, SolanaLabs.React, dev/mainnet automation scripts.

NFT Candy Factory NOTE: This repo will prob only work on unix-based environments. The NFT Candy Factory project is designed to let users fork, customi

Kevin Faveri 261 Dec 30, 2022
This repository contains a basic example on how to set up and run test automation jobs with CircleCI and report results to Testmo.

CircleCI test automation example This repository contains a basic example on how to set up and run test automation jobs with CircleCI and report resul

Testmo 2 Dec 23, 2021
A demo for E2E build piplelines in Design Systems using monorepo's and automation :zap:.

Design System Pipelines demo What is it? A working demonstration for end-to-end build piplelines in Design Systems using Primer Primitives, Primer CSS

Rez 7 Oct 20, 2022
Automation scripts I use for my Bitburner gameplay videos.

Bitburner Automation Note: I release a new piece of code when I finish a video segment in the series. If it's a multi-part series, the scripts will no

Chris Rabe 68 Dec 25, 2022
BI, API and Automation layer for your Engineering Operations data

Faros Community Edition Faros Community Edition (CE) is an open-source engineering operations platform that connects the dots between all your operati

Faros AI 272 Dec 23, 2022
BBGO Karma Bot - BBG token distribution automation

BBGO Karma Bot - BBG token distribution automation Requirement node 16 yarn pm2 mongodb Setup Note that while setting a secret is optional on GitHub,

StarCrypto 3 Dec 15, 2022
Service Installer for VMware Tanzu is a one-click automation solution that enables VMware field engineers to easily and rapidly install, configure, and operate VMware Tanzu services across a variety of cloud infrastructures.

Service Installer for VMware Tanzu Service Installer for VMware Tanzu seeks to provide a one-click automation solution to enable our VMware engineers

VMware Tanzu 42 Dec 1, 2022
Campus hiring and training automation platform.

⚡ Supported Use Cases Student register themselves on the portal Student fills details in their academic profile Student opt for campus hiring / intern

null 7 Aug 24, 2022
Android ROM device support and bringup tool, designed for maximum automation and speed.

adevtool Android ROM device support and bringup tool, designed for maximum automation and speed. Features This tool automates the following tasks for

Danny Lin 186 Dec 21, 2022
Minimalistic, opinionated, and predictable release automation tool.

Release Minimalistic, opinionated, and predictable release automation tool. General idea Think Prettier but for automated releases: minimalistic, opin

Open Source: JavaScript 173 Dec 18, 2022
A revolutionary open-source automation tool

DopplerTask - Task Automation DopplerTask is a revolutionary open-source software that allows you to easily automate tasks. Whether it’s a bunch of ba

DopplerTask 364 Dec 31, 2022
Boilerplate project to run MOBILE Test Automation with WebdriverIO v7, Mocha, Appium, Allure reporting and Momentum Suite cloud device farm support

WebdriverIO Mocha Appium Momentumsuite WebdriverIO Integration with local or Momentum Suite real mobile farm devices Supports Native or Hybrid Android

Momentum Suite 21 Dec 5, 2022