How-To Guides
DeviceHub Guides

Use the Manage Topic to Stop a Device

2min

Notes:

  • You need to follow the following guidelines for topic names: Subject-Based Messaging.
  • When publishing structured data such as JSON, you must convert to a byte array (string) first. To do this in a flow, you can use the json node.

The Manage topic allows you to control the status of a DeviceHub device.

User Scenario

You'd like to remotely disconnect a PLC from Manufacturing Connect Edge.

Set Up and Use the Manage Topic

To set up and use the Manage topic:

  1. Follow the steps to Connect a Device. For this user scenario, a Simulator Generator device is used.
  2. Navigate to DeviceHub.
  3. In the Generator device tile, click the Action menu, click Copy Topics, and then select the Manage topic. This will copy the Manage status topic. You will refer to this topic later on.

    Copy the manage topic
    Copy the manage topic
    
  4. Navigate to Flows Manager.
  5. For a Flows Manager, click the Go To Flow Definition icon. The Flow canvas opens in a new browser tab.

    Go To Flow Definition icon
    Go To Flow Definition icon
    
  6. On the Flow canvas, copy the DataHub Publish node and inject node onto the canvas. Then, connect the two nodes.

    The nodes needed for the manage topic
    The nodes needed for the manage topic
    
  7. Double-click the DataHub Publish node.
    • In the Topic field, paste the Manage topic you copied in step 3.
    • If needed, configure the Datahub Subscribe connection. See the Step 3: Configure Connector Nodes section in Create a Flow to learn more.
    • Click Done.
  8. Double-click the inject node. The Edit inject node dialog box displays.
  9. For msg.payload, select string.

    Select a string payload
    Select a string payload
    
  10. For msg.payload, enter {"command" : "stop"}.

    Command to stop device
    Command to stop device
    
  11. Click Done, and then click Deploy.
  12. Click the inject button. This triggers the payload message you configured for the node.

    The inject button
    The inject button
    
  13. Return to the Manufacturing Connect Edge browser window and navigate to DeviceHub. The device now shows a Stopped status.

    Stopped status
    Stopped status
    

To restart the device, you can use the following command: {"command" : "start"}.