IoTFlows
  • Welcome to IoTFlows Docs
  • IoTFlows
  • Console
  • REST API
  • Device Management & Secure Remote Access
    • 1. Connect a device to the cloud or create a virtual device
    • 2. SSH to your device over the internet
    • 3. Transfer files to your device over the internet
    • 4. Remotely access Node-RED on your device
    • 5. Create public links for local web-apps
  • Real-Time Data Streams, Alerts, and Actions
    • Create a Device API Key
    • Publish and subscribe to real-time messages with Node-RED
    • Creating an Alert Channel
    • Publish an Alert with Node-RED
    • Define and execute an Action in Node-RED
    • Python real-time SDK
    • Javascript real-time SDK
  • Cloud Node-RED Servers
    • Create a secure Cloud Node-RED Server in five minutes
    • Subscribe to data streams with a Cloud Node-RED Server
    • Integrate data streams to Node-RED dashboard
    • Integrate data streams to Slack
  • IOTFLOWS OVERVIEW
    • IoTFlows Roles and Permissions
    • Adding Team Members
  • Example Projects
    • Raspberry Pi as Gateway
      • Arduino to Raspberry Pi Serial Communication for Ultrasonic Sensor
    • Getting Started with Node-Red Dashboard
      • Installing Node-Red Dashboard
      • Accessing Node-Red Dashboard
      • 1. Creating a Page
      • 2. Adding Gauge Nodes
      • 3. Changing Dashboard Themes
      • 4. Adding Data to Gauge Nodes
      • 5. Adding a Chart Node
      • 6. Adding Data to Chart Node
      • 7. Adding a Template Node
      • 8. Adding Data to Template Node
      • 9. Adding Switch Node
      • 10. Adding Logic to Switch Node
      • 11. Adding a Slider Node
      • 12. Adding a Color Picker Node
      • 13. Adding a Numeric Node
      • 14. Adding a Button Node
      • 15. Adding Logic to a Button Node
      • Node-Red Dashboard Code
    • Publishing Data Streams from Python
    • Ultrasonic Sensor on Raspberry Pi Node-Red
  • General
    • Downloading IoTFlows Node-Red Nodes
    • Publishing Alert from Node-Red Manual
    • Publishing Data Stream from Node-Red Manual
Powered by GitBook
On this page
  • Prerequisites
  • Create an Action
  • Connect to Node-RED
  • Define an Action on your device in Node-RED
  • Execute/Call an Action
  • Execute a Device Action
  • Read Last Status of a Device Action

Was this helpful?

  1. Real-Time Data Streams, Alerts, and Actions

Define and execute an Action in Node-RED

Define Actions on your devices and call them from the cloud. For example, use actions to turn on/off a lock or call a function that reboots your device.

PreviousPublish an Alert with Node-REDNextPython real-time SDK

Last updated 3 years ago

Was this helpful?

Prerequisites

For this section, you'll first need to , , and .

In case you have a Node-RED already installed manually and only need to exchange real-time data without managing your device, you can add manually to your Node-RED. .

Create an Action

From the side navigation tab of the device page, click on Create Action. Set the name, description and hit submit. For this example, we will name the action "Bash Command" since we want to execute a bash command from another device or from the cloud on this device.

Connect to Node-RED

Ensure your device is connected to the cloud by checking if you see the green light on the device page, Enable the Node-RED connection in the Remote Connections tab, and hit Connect.

Define an Action on your device in Node-RED

Double-click on the action start node, and then click on the edit button to add the device API Key credentials if you haven't configured the connection yet.

Next, we will click the refresh button in the Topic and select the Action that we will like to execute, in this case "Bash Command", and click Done.

Connect the action start node to your the function / actuator that needs to be triggered when the action is called. In this case, we will connect it to an exec node to execute a command. Drag and drop an exec code and connect its threads similar to the following figure. Also, double click on the exec node and check mark the Append option to pass the msg.payload (the HTTP request body) to this node. This way, once we execute this Action from the cloud, our command will be executed on the device and its stdout results will be sent back to us.

Execute/Call an Action

You can send a HTTP Post request to execute / call an Action. You can find the action uuid from the right hand side navigation.

Execute a Device Action

POST https://api.iotflows.com/v1/actions/:action_uuid

When executing a device action, the Body of the HTTP request will be sent in a string format to the device action. Once the device sends back the confirmation message, this http request will return a success (200) message back.

Headers

Name
Type
Description

Authorization

string

Basic Authentication (base64-encoded string of client_username:password)

[successful operation] OR [response of the action]

Read Last Status of a Device Action

GET https://api.iotflows.com/v1/actions/:action_uuid

You can read the last status of a device action by sending this request.

Path Parameters

Name
Type
Description

string

Basic base64-encoded string of client_id:password

{
  "action_last_confirmed_status": "string",
  "action_last_confirmed_status_timestamp": "string"
}

IMPORTANT: We strongly recommend that you change the default username and password for Node-RED (admin, password). .

To define an action in Node-RED, drag and drop an action start and an action finish. Every action start node needs to be finished with an action finish node to confirm that the action was properly executed. When an action is triggered with an HTTP request, this will result in an that confirms the request has been fulfilled properly

HTTP response code of 200
connect your device to the cloud
create a remote connection for Node-RED
create a Device API Key
IoTFlows Node-RED Nodes
Learn how to add nodes to Node-RED
Learn how to change the Node-RED credentials