Node-RED node to connect to Particle Devices, either via local cloud, or the Particle.io cloud. This can be used to connect to the Particle Core/Photon, call functions, read variables or listen to Server-Sent-Events (SSEs).
npm install node-red-contrib-particle
Three separate nodes are provided to interact with Particle Devices โ call a function, read a variable and subscribe to SSEs. The nodes have both INPUT and OUTPUTs โ sending appropriate messages (e.g. msg.payload, msg.name) to the INPUT allows you to change the parameters dynamically.
Where appropriate, the OUTPUT provides returned data from the Particle cloud after the query has been made.
Following are the return values:
Function call
- msg.raw contains the raw JSON string returned
- msg.payload contains the return value of the function
- msg.id contains the device id
Read a Variable
- msg.raw contains the raw JSON string returned
- msg.payload contains the value of the variable
- msg.id contains the core id
Subscribe to Server-Sent Events (SSEs)
- msg.raw contains the raw JSON string returned
- msg.evtname contains the event name published
- msg.payload the event data
- msg.id contains the core id
- msg.published_at contain the published date and time
There are current limitations with the local cloud package from Particle, which prevents any subscription of device-specific and device-and-event-specific events. Effectively, if you are attempting to subscribe to a local cloud, you are currently only able to listen in on the public firehose (ALL SSEs), or on the event-specific public firehose.
An equivalent of such requests using the RESTful API will resemble:
http://particlecloud.local:8080/v1/events/&access_token=123456789abcdef123456789abcdef123456789a
http://particlecloud.local:8080/v1/events/someEvent&access_token=123456789abcdef123456789abcdef123456789a
This is a forked project that built off @krvarma's node-red-contrib-sparkcore initial work (0.0.12).
Copyright 2015 Chuan Khoo (node-red-contrib-particle 0.0.2) for local cloud SSE (limited) support, configuration node implementation, renaming to Particle, implementation of separate nodes for clarity, and cosmetic fixes.
Copyright 2014 Krishnaraj Varma (node-red-contrib-sparkcore 0.0.12)