Connect Shelly Sensors to Node-Red (via Cloud)

Requirements

  • node-red-contrib-shelly

  • Shelly sensor (1st or 2nd generation)

Install the Library

From Manage palette in node-red, install the before mentioned library node-red-contrib-shelly.

Once installed, you will have three new nodes that you can use. The one we’ll use in this tutorial is shelly cloud.

  1. Add the shelly cloud node to the flow and open it. You will need to configure the server first:

    shellyCloudSettings
    shellyCloudSettingsServer
  2. To find the Server URI and Authentication Key, you will need to open the Shelly mobile app:

    • Navigate to Settings and find Autorization cloud key

    • Press on Autorization cloud key and then Get key

    • You will be provided with the unique ID and server credentials.

      ShellyCloudMobileCloudKey

      Copy (or save) them, return back to the node-red flow, and paste them in the empty fields

Retrieve the data

To retrieve and see the data in the output console, you will need to add a debug node, an inject node, and one change node, like shown on the image:

shellyCloudNodeRedFlow

You now only need to modify the change node:

  1. When you open it, you will need to put the rule value to Set, and you should also set it to the value of JSON.

    shellyCloudEditChangeNode
  2. Then you will need to fill in the JSON text. In this tutorial, we want to retrieve all the data from the device on the cloud, so our JSON will look something like this:

    {
        "type": "status",
        "id": "123456abcdef",
        "channel": 0
    }
  3. The id property can again be found in the Shelly mobile app.

    • Open the app and find your device.

    • Click on the device and go to settings (the wheel on the bottom of the menu)

    • There you will find a section named Device information. Under it, there is the Device Id and Device Channel, which you can copy to the before-mentioned JSON file.

      shellyCloudDeviceInformation

After you’ve done all of this, you can deploy the app, and you should see the retreived data in the debug console:

shellyCloudDebugConsoleResults

For more information you can visit node-red-contrib-shelly docs