npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@mensch-und-maschine/node-red-contrib-modelsphere-sensor

v1.0.1

Published

Node-RED node for sending sensor data to the Modelsphere REST API

Readme

@mensch-und-maschine/node-red-contrib-modelsphere-sensor

npm version npm downloads license Node-RED

A Node-RED package for sending sensor data to the Modelsphere platform via its REST API.

Developed and maintained by Mensch und Maschine Deutschland GmbH.


Features

  • 🔐 Secure authentication via API-Key → Bearer Token exchange (JWT)
  • 🔄 Automatic token renewal before expiry (configurable buffer window)
  • 📡 Flexible value mapping – read from msg.*, flow/global context, static values, or JSONata expressions
  • 🔁 Retry with exponential backoff and jitter on transient errors
  • 💾 Offline buffer – persists unsent data locally (JSONL) and replays when the connection is restored
  • 🏗️ Hub selection – loads available hubs directly from the API into a dropdown

Installation

Via Node-RED Palette Manager

Search for node-red-contrib-modelsphere-sensor and click Install.

Via npm

cd ~/.node-red
npm install @mensch-und-maschine/node-red-contrib-modelsphere-sensor

Manual (local development)

cd ~/.node-red
npm install /path/to/modelsphere-sensor

Restart Node-RED after installation.


Nodes

modelsphere-config – Server Connection

A shared configuration node that holds all connection and authentication settings. Multiple sensor nodes can share one config.

| Field | Description | |---|---| | Server-URL | Base URL of the Modelsphere backend, e.g. https://bimrepo-dev.mumiver.se | | API-Key | Stored encrypted. Used for POST /api/auth/token-exchange | | Timeout (ms) | HTTP request timeout in milliseconds (default: 5000) | | Hub-ID | Target hub – loaded from GET /api/hubs via the dropdown | | Token renewal (s) | Seconds before expiry at which a new token is fetched proactively (default: 30) | | Max. retries | Number of retry attempts after a failed request (default: 3) | | Base delay (ms) | Wait time before the first retry – doubles with each attempt (default: 2000) | | Max. delay (ms) | Upper limit for retry delay (default: 30000) | | Buffer enabled | Enable local offline buffer | | Max. entries | Maximum number of buffered entries – oldest are discarded when full (default: 1000) | | Flush interval (s) | Seconds between automatic replay attempts (default: 60) | | Buffer path | Directory for buffer files (default: ~/.node-red/modelsphere-buffer) |

Test button

Click Verbindung testen to verify Server-URL and API-Key without deploying.

Hub selection

Click the button next to the Hub-ID dropdown to authenticate and load all available hubs from GET /api/hubs.


modelsphere-sensor – Virtual Sensor

Sends a measurement to the Modelsphere API whenever a message arrives.

Endpoint: POST /api/hubs/<hubId>/sensordata

| Field | Description | |---|---| | Server | Reference to a modelsphere-config node | | Sensor Key | Unique identifier for the sensor (key in the payload) | | Sensor Name | Display name of the sensor (name in the payload) | | Value | Source of the measurement value (see Value mapping) | | Data type | auto (detected), numeric, boolean, text, event, or json | | Unit | Optional unit, e.g. °C, %, hPa, kWh |

Value mapping

The Value field uses Node-RED's typed input and supports:

| Type | Example | |---|---| | msg | msg.payload, msg.temperature, msg.data.value | | flow | Flow context variable | | global | Global context variable | | str | Fixed string | | num | Fixed number | | bool | true / false | | json | {"state": "on"} | | jsonata | $number(msg.temp) * 1.8 + 32 | | env | Environment variable |

Message overrides

The following msg properties override the node configuration at runtime:

| Property | Type | Description | |---|---|---| | msg.sensorKey | string | Overrides the configured sensor key | | msg.sensorName | string | Overrides the configured sensor name | | msg.unit | string | Overrides the configured unit | | msg.timestamp | string | ISO-8601 timestamp – auto-generated if absent | | msg.meta | object | Additional metadata, e.g. { location: "Hall A" } |

Output message

On success, the node forwards the message with:

| Property | Type | Description | |---|---|---| | msg.payload | object | JSON response from the Modelsphere API | | msg.statusCode | number | HTTP status code | | msg.modelsphereRequest | object | The exact payload that was sent |


API Payload Format

POST /api/hubs/<hubId>/sensordata

{
  "key":       "sensor-001",
  "name":      "Temperature Entrance",
  "timestamp": "2026-04-14T10:00:00.000Z",
  "type":      "numeric",
  "value":     23.5,
  "unit":      "°C",
  "meta": {
    "location":    "Hall A",
    "description": "Temperature measurement"
  }
}

Authentication Flow

API-Key
  │
  ▼
POST /api/auth/token-exchange
  │
  ▼
Bearer JWT (cached, auto-renewed)
  │
  ▼
POST /api/hubs/<hubId>/sensordata
  Authorization: Bearer <token>
  • On HTTP 401 or 403, the token cache is cleared and a single re-authentication attempt is made automatically.
  • On other 4xx errors (except 429), the request fails permanently without retry.
  • On 5xx errors or network failures, the retry mechanism with exponential backoff kicks in.

Offline Buffering

When the Modelsphere API is unreachable, measurements are written to a local JSONL file. Once the connection is restored, buffered entries are replayed in order.

~/.node-red/modelsphere-buffer/
  └── buffer_<sensorKey>.jsonl

The buffer size is capped at Max. entries – once full, the oldest entry is discarded (FIFO).


Requirements

  • Node-RED >= 2.0.0
  • Node.js >= 14.0.0

License

MIT