Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 0 additions & 19 deletions .eslintrc.json

This file was deleted.

5 changes: 4 additions & 1 deletion .github/workflows/ci-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ on:
- 'main'

jobs:
lint-and-build:
build:
runs-on: ubuntu-latest
strategy:
fail-fast: false
Expand All @@ -31,5 +31,8 @@ jobs:
- name: Lint
run: npm run lint

- name: Test
run: npm run test

- name: Build
run: npm run build
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
.DS_Store
node_modules
dist
node_modules
test_coverage
yarn.lock
.eslintcache
.tsbuildinfo
Expand Down
42 changes: 41 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ Custom n8n node for interacting with the openHAB REST API, with optional myopenH
- Inspect things and their status.
- List, trigger, enable/disable rules.
- Fetch system info for quick health checks.
- Trigger workflows from openHAB events.
- Works against local openHAB or remotely through `myopenhab.org`.

## Requirements
Expand Down Expand Up @@ -42,6 +43,8 @@ Custom n8n node for interacting with the openHAB REST API, with optional myopenH

## Usage

### openHAB node

1. Add the **openHAB** node to a workflow.
2. Set credentials:
- **Local**: Base URL (e.g., `http://localhost:8080`) + API token.
Expand All @@ -53,7 +56,7 @@ Custom n8n node for interacting with the openHAB REST API, with optional myopenH
- **System**: system info.
4. Execute the node; outputs are JSON objects ready for downstream n8n steps.

### Usage examples
#### Usage examples

1. Read a light state:
- Resource: `Item`
Expand All @@ -69,6 +72,42 @@ Custom n8n node for interacting with the openHAB REST API, with optional myopenH
- Operation: `Run`
- Rule UID: `evening_scene`

### openHAB Trigger node

1. Add the **openHAB Trigger** node to a workflow to listen for openHAB events and start workflows when they arrive.
2. Set credentials:
- **Local**: Base URL (e.g., `http://localhost:8080`) + API token.
- **Cloud (myopenHAB)**: Choose “myopenHAB Account” in credentials and enter your myopenHAB login and set **openHAB API Token (optional)** to send `X-OPENHAB-TOKEN`.
3. Filter events by:
- **Topic**: Comma-separated topic filters (supports `*` wildcard or RegEx and exclusions with `!`), e.g. `openhab/items/*/command,!openhab/items/MyItem/*` to listen for command to all Items except `MyItem`.
- **Type**: Comma-separated event types to include, e.g. `ItemCommandEvent,ItemStateChangedEvent,ItemStateUpdatedEvent`.
- **Source**: Comma-separated event sources to exclude, e.g. `org.openhab.ui=>org.openhab.core.io.rest,`. The node’s own source is always excluded to prevent loops.

The trigger emits incoming events with the following properties:

- `type`: event type
- `topic`: event topic
- `payload`: parsed JSON payload (if possible)
- `source`: event source (if present)
- `rawPayload`: raw payload string
- `receivedAt`: ISO timestamp

Example event:

```json
{
"type": "ItemCommandEvent",
"topic": "openhab/items/Florian_Licht/command",
"payload": {
"type": "OnOff",
"value": "ON"
},
"source": "org.openhab.ui=>org.openhab.core.io.rest",
"rawPayload": "{\"type\":\"OnOff\",\"value\":\"ON\"}",
"receivedAt": "2026-04-20T19:12:18.056Z"
}
```

### Notes

- Authentication is applied through the credential type (used by `httpRequestWithAuthentication`), so each request automatically uses the selected auth mode.
Expand All @@ -79,6 +118,7 @@ Custom n8n node for interacting with the openHAB REST API, with optional myopenH
## Development

- Lint: `npm run lint`
- Test: `npm run test`
- Build: `npm run build`
- TypeScript config targets Node 18+.

Expand Down
4 changes: 2 additions & 2 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ import parserTs from '@typescript-eslint/parser';

export default [
{
ignores: ['dist', 'node_modules'],
ignores: ['dist', 'node_modules', 'test_coverage']
},
{
files: ['**/*.ts'],
languageOptions: {
parser: parserTs,
parserOptions: {
project: './tsconfig.json',
project: './tsconfig.eslint.json',
sourceType: 'module',
},
},
Expand Down
3 changes: 2 additions & 1 deletion index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { openHAB } from './nodes/openHAB/openHAB.node';
import { openHABTrigger } from './nodes/openHABTrigger/openHABTrigger.node';
import { openHABApi } from './credentials/openHABApi.credentials';

export const nodes = [openHAB];
export const nodes = [openHAB, openHABTrigger];
export const credentials = [openHABApi];
25 changes: 25 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
module.exports = {
preset: 'ts-jest',
testEnvironment: 'node',
testMatch: ['**/*.test.ts'],

// Automatically clear mock calls, instances, contexts and results before every test
clearMocks: true,

// Indicates whether the coverage information should be collected while executing the test
collectCoverage: true,

// An array of glob patterns indicating a set of files for which coverage information should be collected
collectCoverageFrom: ['util/**/*.ts'],

// The directory where Jest should output its coverage files
coverageDirectory: 'test_coverage',

// An array of regexp pattern strings used to skip coverage collection
// coveragePathIgnorePatterns: [
// "/node_modules/"
// ],

// Indicates which provider should be used to instrument code for coverage
coverageProvider: 'v8',
};
Loading
Loading