Skip to content

HakusaiTH/n8n-Netpie

Repository files navigation

n8n-NETPIE

Community node for n8n to read from and publish to NETPIE.

  • 2 nodes included: NETPIE Read (Shadow β†’ Get) and NETPIE Send (Message β†’ Publish)
  • Uses header auth: Authorization: Device <clientId>:<token>
  • Follows n8n UX guidelines (Resource + Operation, clean copy, Title Case)
  • Includes Simplify output and Options β†’ Timeout

Example n8n workflow using NETPIE Read and NETPIE Send


πŸ“¦ Installation

A) Install via Community Nodes (recommended)

  1. In n8n go to Settings β†’ Community Nodes
  2. Click Install, search for your package name (e.g. n8n-nodes-netpie)
  3. Restart n8n if prompted

B) Install from npm into the custom folder

mkdir -p ~/.n8n/custom
cd ~/.n8n/custom
npm init -y
npm i n8n-nodes-netpie
n8n start

Requires n8n v1+ and Node.js 18+ (Node 20+ recommended).


πŸ” Credentials (NETPIE API)

Create a new credential: NETPIE API

Field Description
Client ID Device client ID from NETPIE
Token Device token (stored securely as a password field)

The node automatically sends:

Authorization: Device <clientId>:<token>
Accept: application/json

NETPIE credential tested successfully


🧩 Nodes

1) NETPIE Read

Reads a device shadow value by alias.

  • Resource: Shadow
  • Operation: Get

Parameters

Name Type Required Example Description
Alias String βœ… led Shadow alias to retrieve
Simplify Boolean – true Return compact { alias, value }
Options β†’ Timeout Number – 15000 Request timeout in milliseconds

Output (Simplify = On)

{
  "alias": "led",
  "value": {
    "deviceid": "10e2968a-...",
    "data": { "Temperature": 25.62, "Timestamp": "00:10:37" },
    "rev": 1466,
    "timestamp": 1760932094846,
    "modified": 1760932094849
  }
}

NETPIE Read node output


2) NETPIE Send

Publishes a message to a topic.

  • Resource: Message
  • Operation: Publish

Parameters

Name Type Required Example Description
Topic String βœ… led Topic to publish to
Payload String βœ… ledon Message payload (JSON string allowed)
Simplify Boolean – true Return { published, topic, result }
Options β†’ Content Type Options – text/plain application/json
Options β†’ Timeout Number – 15000 Request timeout in milliseconds

Output (Simplify = On)

{ "published": true, "topic": "led", "result": "ok" }

NETPIE Send node output


πŸš€ Example Workflow

  1. NETPIE Read β€” Shadow:Get (alias=led)
  2. NETPIE Send β€” Message:Publish (topic=led, payload=ledon)

Click Execute workflow and inspect the node outputs.


πŸ›  Local Development

# Build the package
npm run build

# Link locally
npm link
cd ~/.n8n/custom
npm init -y
npm link n8n-nodes-netpie
n8n start

Ensure your package.json includes:

{
  "files": ["dist", "README.md", "LICENSE"],
  "n8n": {
    "nodes": [
      "dist/nodes/NetpieRead/NetpieRead.node.js",
      "dist/nodes/NetpieSend/NetpieSend.node.js"
    ],
    "credentials": ["dist/credentials/NetpieApi.credentials.js"]
  }
}

πŸ“‘ API Reference (quick)

  • Base: https://api.netpie.io/v2/device

  • Read shadow: GET /shadow/data?alias=<alias>

  • Publish message: PUT /message?topic=<topic>

    • Header: Content-Type: text/plain or application/json
    • Body: payload (valid JSON if application/json)

πŸ” Troubleshooting

  • 401/403 Unauthorized Verify Client ID and Token belong to the correct device and are active.

  • 404 alias not found Make sure the device shadow actually contains the alias you are querying.

  • Invalid JSON payload When Content Type = application/json, the Payload must be valid JSON (e.g. {"cmd":"ledon"}).

  • Timeouts Increase Options β†’ Timeout and confirm the NETPIE service is reachable from your n8n host.


πŸ§‘β€πŸ’» Maintainer

Developed by Phoovadet Noobdev


πŸ“ License

MIT License

About

Community node for n8n to read from and publish to NETPIE.

Resources

License

Code of conduct

Stars

0 stars

Watchers

0 watching

Forks

Packages

 
 
 

Contributors