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

node-red-contrib-greennode

v1.0.0

Published

Node-RED节点用于数据映射和MQTT发布

Readme

GreenNode - Node-RED 数据映射节点

简介

GreenNode 是一个用于 Node-RED 的数据映射节点,它可以将输入的 JSON 数据映射到预定义的字段结构,并通过 MQTT 发布映射后的数据。

功能特性

  • 🔄 数据映射: 将任意 JSON 数据映射到预定义的5个字段
  • 🎯 拖拽界面: 直观的拖拽式字段映射配置
  • 📡 MQTT 发布: 自动将映射后的数据发布到 MQTT broker
  • 🌐 多语言支持: 支持中文和英文界面
  • 实时处理: 支持实时数据流处理

预定义字段

节点支持以下5个预定义字段的映射:

  • timestamp - 时间戳
  • temp - 温度
  • pressure - 压力
  • ordernumber - 订单号
  • id - ID

安装方法

  1. 将整个 greennode 文件夹复制到 Node-RED 的 node_modules 目录下
  2. 重启 Node-RED 服务
  3. 在节点面板的 "function" 分类中找到 "数据映射节点"

使用方法

1. 配置节点

  1. 拖拽 "数据映射节点" 到工作流中
  2. 双击节点打开配置界面
  3. 配置以下参数:
    • 名称: 节点的显示名称
    • MQTT Broker: 选择已配置的 MQTT broker
    • MQTT 主题: 指定发布数据的主题

2. 设置字段映射

  1. 点击 "测试映射" 按钮查看示例数据
  2. 将左侧的源字段拖拽到右侧对应的目标字段
  3. 确保所有5个预定义字段都有映射
  4. 点击 "完成" 保存配置

3. 连接和部署

  1. 将数据源连接到节点的输入端口
  2. 将节点的输出端口连接到其他节点(可选)
  3. 部署流程

输入数据格式

节点接受包含任意字段的 JSON 对象,例如:

{
  "device_id": "sensor001",
  "temperature": 25.5,
  "humidity": 60,
  "pressure": 1013.25,
  "timestamp": "2024-01-01T12:00:00Z",
  "order_id": "ORD123456",
  "status": "active"
}

输出数据格式

映射后的数据将包含5个预定义字段:

{
  "timestamp": "2024-01-01T12:00:00Z",
  "temp": 25.5,
  "pressure": 1013.25,
  "ordernumber": "ORD123456",
  "id": "sensor001"
}

状态指示

节点状态栏会显示以下信息:

  • 🟢 绿色圆点: MQTT 已连接,数据处理正常
  • 🟡 黄色圆环: MQTT 重连中或断开连接
  • 🔴 红色圆环: MQTT 连接失败或处理错误

错误处理

节点会自动处理以下错误情况:

  • 输入数据格式错误
  • MQTT 连接失败
  • 字段映射缺失
  • 网络连接问题

配置示例

基本配置

// 节点配置
{
  "name": "传感器数据映射",
  "mqttConfig": "mqtt-broker-config",
  "mqttTopic": "sensors/data",
  "fieldMappings": {
    "timestamp": "timestamp",
    "temp": "temperature",
    "pressure": "pressure",
    "ordernumber": "order_id",
    "id": "device_id"
  }
}

测试数据

// 输入测试数据
{
  "device_id": "sensor001",
  "temperature": 25.5,
  "pressure": 1013.25,
  "timestamp": "2024-01-01T12:00:00Z",
  "order_id": "ORD123456"
}

依赖项

  • Node-RED
  • MQTT.js (^4.3.7)

许可证

MIT License

支持

如有问题或建议,请提交 Issue 或联系开发者。

更新日志

v1.0.0

  • 初始版本发布
  • 支持基本数据映射功能
  • 支持 MQTT 发布
  • 支持拖拽式字段映射界面
  • 支持中英文界面