7 Node msg Conventions
zobalogh edited this page 2014-12-10 08:05:48 -08:00

There are a few reserved properties within the structure of the msg objects being passed around in node-RED.

  • msg.payload - contains the main body of the message. For example, the text of a Tweet, the content of a webpage or a sensor reading.

  • msg.title - a title giving a good representation of what the message contains.

  • msg.description - a brief explanation of what data is contained within the message.

  • msg.data - some APIs provide large responses. For example, the Twitter api returns a huge object for each tweet containing many properties beyond just the text. This property can be used to store the original response - allowing access to all of the properties, not just those that get pulled out into msg.payload.

  • msg.location - an object containing properties representing location information.

    • msg.location.lat - Latitude
    • msg.location.lon - Longitude
    • msg.location.name - the name of a location
    • msg.location.city
    • msg.location.country
  • msg.time - a time. The time should be either JavaScript Date object, or a number of milliseconds since epoch.

For Fitness/activity based nodes/flows:

  • msg.payload.id - The ID of the activity in the given fitness system/API
  • msg.payload.type - The type of the activity, example: run/cycle ride
  • msg.payload.duration - Duration of the activity in seconds
  • msg.payload.distance - Distance of activity in metres
  • msg.payload.calories - Calories burned during activity in kilocalories
  • msg.payload.starttime - JavaScript Date object representing the start time of the activity