# 【Add-on Guide】Node-red

**URL:** <https://forum.ewelink.cc/t/add-on-guide-node-red/15505>\
**Category:** eWeLink CUBE\
**Created:** [March 21, 2023, 7:32am UTC](https://forum.ewelink.cc/t/add-on-guide-node-red/15505 "2023-03-21T07:32:11Z")\
**Posts on this page:** 16\
**Page:** 1

<div class="post-metadata">

**Author:** ![Teki](https://dub1.discourse-cdn.com/flex005/user_avatar/forum.ewelink.cc/teki/32/1161_2.png) [@Teki](https://forum.ewelink.cc/u/Teki)\
**Post date:** [March 21, 2023, 7:32am UTC](https://forum.ewelink.cc/t/add-on-guide-node-red/15505/1 "2023-03-21T07:32:11Z")

</div>

# Release Note

2023.09.28 Update  
**node-red-contrib-ewelink-cube V1.1.0**

1. The `control-device` node now supports to:  
Change iHost Security Modes  
Adjust System Volume  
Adjust Alarm Volume  
Reverse ON/OFF status of switches/plugs

2. The `event-state` node now supports to:  
Monitor the status of any channel on multiple-channel devices  
Monitor the Security Mode of iHost, and the Alarm status.

3. Optimized the _Register-device_ node and renamed it as _Virtual-device_

4. The ewelink-cube nodes now will automatically search the iHost in LAN

* * *

# Detailed Guide

**How to install Node-RED add-on in CUBE?**

- Tap ‘+’ on the upper right and search for Node-red

- Select noderred/node-red and add it  

- Tap ‘INSTALL’ to install the add-on

- Tap ‘RUN’ to open the settings, select network as ‘Bridge’ and fill in other parameters according to your needs, then tap ‘RUN’  

- Wait a while and open a new browser tab to visit the Node-red page, the default URL is ihost.local:1880 or IP of iHost:1880 (for example 192.168.1.105:1880, you may find the IP on your router’s management page)  

- Click the menu on uper right and select ‘Manage palette’, search **ewelink-cube** and install

---

<div class="post-metadata">

**Author:** ![yitie](https://dub1.discourse-cdn.com/flex005/user_avatar/forum.ewelink.cc/yitie/32/3613_2.png) [@yitie](https://forum.ewelink.cc/u/yitie)\
**Post date:** [April 25, 2023, 6:57am UTC](https://forum.ewelink.cc/t/add-on-guide-node-red/15505/4 "2023-04-25T06:57:44Z")

</div>



---

<div class="post-metadata">

**Author:** ![csongor.varga](https://avatars.discourse-cdn.com/v4/letter/c/ea666f/32.png) [@csongor.varga](https://forum.ewelink.cc/u/csongor.varga)\
**Post date:** [July 6, 2023, 8:56am UTC](https://forum.ewelink.cc/t/add-on-guide-node-red/15505/5 "2023-07-06T08:56:37Z")

</div>

Just a quick question: did anyone try to access the speaker of the iHost form Node-Red? Like playing audio from Node-Red over the iHost speakers?

---

<div class="post-metadata">

**Author:** ![eWeLink](https://dub1.discourse-cdn.com/flex005/user_avatar/forum.ewelink.cc/ewelink/32/395_2.png) [@eWeLink](https://forum.ewelink.cc/u/eWeLink)\
**Post date:** [July 11, 2023, 6:22am UTC](https://forum.ewelink.cc/t/add-on-guide-node-red/15505/6 "2023-07-11T06:22:55Z")

</div>



---

<div class="post-metadata">

**Author:** ![rolandoguedes](https://avatars.discourse-cdn.com/v4/letter/r/ce7236/32.png) [@rolandoguedes](https://forum.ewelink.cc/u/rolandoguedes)\
**Post date:** [February 1, 2024, 2:53pm UTC](https://forum.ewelink.cc/t/add-on-guide-node-red/15505/7 "2024-02-01T14:53:54Z")

</div>

@csongor.varga yes, you can.

Using control-device node to play the internal sounds.

Or if you want a custom sound, you can use the REST API:

Payload:

> msg.payload = {  
> audio\_url: ‘[https://download.samplelib.com/mp3/sample-12s.mp3](https://download.samplelib.com/mp3/sample-12s.mp3)’  
> };
> 
> return msg;

POST Url: http://\< ip \>/open-api/v1/rest/media/audio-player

Only works with urls.

---

<div class="post-metadata">

**Author:** ![csongor.varga](https://avatars.discourse-cdn.com/v4/letter/c/ea666f/32.png) [@csongor.varga](https://forum.ewelink.cc/u/csongor.varga)\
**Post date:** [February 1, 2024, 3:32pm UTC](https://forum.ewelink.cc/t/add-on-guide-node-red/15505/8 "2024-02-01T15:32:49Z")

</div>

Wow thanks. I have to try this out. Maybe I can host the files in a node-red static folder so it can be downloaded locally.

---

<div class="post-metadata">

**Author:** ![csongor.varga](https://avatars.discourse-cdn.com/v4/letter/c/ea666f/32.png) [@csongor.varga](https://forum.ewelink.cc/u/csongor.varga)\
**Post date:** [February 1, 2024, 4:49pm UTC](https://forum.ewelink.cc/t/add-on-guide-node-red/15505/9 "2024-02-01T16:49:48Z")

</div>

> [@rolandoguedes](#):
>
> {  
> audio\_url: ‘[https://download.samplelib.com/mp3/sample-12s.mp3’](https://download.samplelib.com/mp3/sample-12s.mp3%E2%80%99)  
> };

How did you set up the control-device node? For me it ignores the payload, just plays an alarm.

---

<div class="post-metadata">

**Author:** ![rolandoguedes](https://avatars.discourse-cdn.com/v4/letter/r/ce7236/32.png) [@rolandoguedes](https://forum.ewelink.cc/u/rolandoguedes)\
**Post date:** [February 1, 2024, 6:26pm UTC](https://forum.ewelink.cc/t/add-on-guide-node-red/15505/10 "2024-02-01T18:26:31Z")

</div>

```auto
[
    {
        "id": "594490b18b08bc96",
        "type": "group",
        "z": "33295e77705cae31",
        "style": {
            "stroke": "#999999",
            "stroke-opacity": "1",
            "fill": "none",
            "fill-opacity": "1",
            "label": true,
            "label-position": "nw",
            "color": "#a4a4a4"
        },
        "nodes": [
            "aab38c244688cd63",
            "41e07a2c45cfcc9d",
            "3ff0c534c313f4f7",
            "2517bd6dba53e36e",
            "f113aaf8d4ffeffb",
            "a08015c90d109885",
            "7d241de5acc0278d"
        ],
        "x": 174,
        "y": 139,
        "w": 972,
        "h": 142
    },
    {
        "id": "aab38c244688cd63",
        "type": "control-device",
        "z": "33295e77705cae31",
        "g": "594490b18b08bc96",
        "name": "",
        "server": "e37d70fa8f41c384",
        "list": "{\"type\":\"ihost\",\"deviceId\":\"ihost\",\"ihostParams\":{\"ModeType\":\"alarmBell\",\"securityMode\":null,\"systemVolume\":\"\",\"systemVolumeValue\":\"\",\"alarmSound\":\"alert1\",\"alarmVolume\":\"50\",\"armedTime\":\"customize\",\"minute\":\"\",\"second\":\"5\"}}",
        "category": "all",
        "device": "ihost",
        "action": "",
        "x": 1040,
        "y": 180,
        "wires": [
            []
        ]
    },
    {
        "id": "41e07a2c45cfcc9d",
        "type": "function",
        "z": "33295e77705cae31",
        "g": "594490b18b08bc96",
        "name": "function 2",
        "func": "return msg.payload.emeters;",
        "outputs": 1,
        "timeout": 0,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 500,
        "y": 180,
        "wires": [
            [
                "3ff0c534c313f4f7",
                "f113aaf8d4ffeffb"
            ]
        ]
    },
    {
        "id": "3ff0c534c313f4f7",
        "type": "switch",
        "z": "33295e77705cae31",
        "g": "594490b18b08bc96",
        "name": "",
        "property": "power",
        "propertyType": "msg",
        "rules": [
            {
                "t": "gt",
                "v": "3700",
                "vt": "str"
            }
        ],
        "checkall": "true",
        "repair": false,
        "outputs": 1,
        "x": 650,
        "y": 180,
        "wires": [
            [
                "2517bd6dba53e36e"
            ]
        ]
    },
    {
        "id": "2517bd6dba53e36e",
        "type": "delay",
        "z": "33295e77705cae31",
        "g": "594490b18b08bc96",
        "name": "",
        "pauseType": "rate",
        "timeout": "5",
        "timeoutUnits": "seconds",
        "rate": "1",
        "nbRateUnits": "1",
        "rateUnits": "minute",
        "randomFirst": "1",
        "randomLast": "5",
        "randomUnits": "seconds",
        "drop": true,
        "allowrate": false,
        "outputs": 1,
        "x": 850,
        "y": 180,
        "wires": [
            [
                "aab38c244688cd63"
            ]
        ]
    },
    {
        "id": "f113aaf8d4ffeffb",
        "type": "debug",
        "z": "33295e77705cae31",
        "g": "594490b18b08bc96",
        "name": "Power Output",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "true",
        "targetType": "full",
        "statusVal": "",
        "statusType": "auto",
        "x": 680,
        "y": 240,
        "wires": []
    },
    {
        "id": "a08015c90d109885",
        "type": "inject",
        "z": "33295e77705cae31",
        "g": "594490b18b08bc96",
        "name": "",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "",
        "payloadType": "date",
        "x": 280,
        "y": 240,
        "wires": [
            [
                "7d241de5acc0278d"
            ]
        ]
    },
    {
        "id": "7d241de5acc0278d",
        "type": "shelly-gen1",
        "z": "33295e77705cae31",
        "g": "594490b18b08bc96",
        "hostname": "192.168.2.33",
        "description": "",
        "mode": "polling",
        "server": "",
        "outputmode": "event",
        "uploadretryinterval": 5000,
        "pollinginterval": "10000",
        "pollstatus": true,
        "getstatusoncommand": true,
        "devicetype": "Measure",
        "outputs": 2,
        "x": 270,
        "y": 180,
        "wires": [
            [
                "41e07a2c45cfcc9d"
            ],
            []
        ]
    },
    {
        "id": "e37d70fa8f41c384",
        "type": "api-server",
        "name": "Token",
        "ip": "127.0.0.1",
        "ipaddr": "",
        "token": "bef487e7-889e-43ac-8df2-2943ee5957cf"
    }
]

```

---

<div class="post-metadata">

**Author:** ![csongor.varga](https://avatars.discourse-cdn.com/v4/letter/c/ea666f/32.png) [@csongor.varga](https://forum.ewelink.cc/u/csongor.varga)\
**Post date:** [February 1, 2024, 7:49pm UTC](https://forum.ewelink.cc/t/add-on-guide-node-red/15505/11 "2024-02-01T19:49:35Z")

</div>

> [@rolandoguedes](#):
>
> [https://download.samplelib.com/mp3/sample-12s.mp3](https://download.samplelib.com/mp3/sample-12s.mp3)

Sorry not this, the API call version. I tried setting up myself, but I get a error 400, headers.Authorization is invalid. What did you put into the header?

---

<div class="post-metadata">

**Author:** ![csongor.varga](https://avatars.discourse-cdn.com/v4/letter/c/ea666f/32.png) [@csongor.varga](https://forum.ewelink.cc/u/csongor.varga)\
**Post date:** [February 1, 2024, 8:00pm UTC](https://forum.ewelink.cc/t/add-on-guide-node-red/15505/12 "2024-02-01T20:00:26Z")

</div>

OK, I figured it out that I need to call the token generator URL to get a new token. I got it (see the second message in the debug). I added that to the audio-player call header, but I still get an error:

 ![image](https://europe1.discourse-cdn.com/flex005/uploads/ewelinkforum/original/2X/1/17eca52b3619dbb7dbc1ac2ae77891fb20d8e052.png)

---

<div class="post-metadata">

**Author:** ![rolandoguedes](https://avatars.discourse-cdn.com/v4/letter/r/ce7236/32.png) [@rolandoguedes](https://forum.ewelink.cc/u/rolandoguedes)\
**Post date:** [February 1, 2024, 10:56pm UTC](https://forum.ewelink.cc/t/add-on-guide-node-red/15505/13 "2024-02-01T22:56:06Z")

</div>

> [@csongor.varga](#):
>
> added that to the audio-player call header, but I still get an error:

Remove the Header Autenticantion, and pick the option Use Authentication:

 ![image](https://europe1.discourse-cdn.com/flex005/uploads/ewelinkforum/original/2X/5/52ef519969d1a7d1800884af4d1a2f3ccefbfb31.png)

PS: are you using node-red with host or bridge network? If you use host, you can change the API url to 127.0.0.1 (because everytime you reset the ihost, the IP changes, at least to me :D)

---

<div class="post-metadata">

**Author:** ![csongor.varga](https://avatars.discourse-cdn.com/v4/letter/c/ea666f/32.png) [@csongor.varga](https://forum.ewelink.cc/u/csongor.varga)\
**Post date:** [February 2, 2024, 6:45am UTC](https://forum.ewelink.cc/t/add-on-guide-node-red/15505/14 "2024-02-02T06:45:08Z")

</div>

> [@rolandoguedes](#):
>
> emove the Header Autenticantion, and pick the option Use Authe

Thanks it is working now.

About the IP: I set this as a reserver IP address for the mac address of the ihost to ensure it is the same all the time. And when I put 127.0.0.1 or localhost, or ihost.local it is not working. Am I missing something from the host file?

---

<div class="post-metadata">

**Author:** ![csongor.varga](https://avatars.discourse-cdn.com/v4/letter/c/ea666f/32.png) [@csongor.varga](https://forum.ewelink.cc/u/csongor.varga)\
**Post date:** [February 2, 2024, 9:56am UTC](https://forum.ewelink.cc/t/add-on-guide-node-red/15505/15 "2024-02-02T09:56:32Z")

</div>

A slightly different question: did anyone successfully configured a static folder for Node-Red?  
I created a `static` folder in filemanager in the `node-red-files` and also enabled this in the settings.js:

```auto
    httpStatic: 'static/', //single static source
    httpStaticRoot: '/static/',

```

But I am not really sure what is the full path of this folder inside the docker image. Do you know how to find it out?

---

<div class="post-metadata">

**Author:** ![antoniomeluso](https://dub1.discourse-cdn.com/flex005/user_avatar/forum.ewelink.cc/antoniomeluso/32/8328_2.png) [@antoniomeluso](https://forum.ewelink.cc/u/antoniomeluso)\
**Post date:** [November 2, 2024, 4:45pm UTC](https://forum.ewelink.cc/t/add-on-guide-node-red/15505/16 "2024-11-02T16:45:19Z")

</div>

Hi, I wanted to install node red on ihost to create an email or whatsapp sending.  
After downloading nodered/node\_red to run as bridge I have the following error “Failed to run. Please set Network in Optional setting as host”, how to solve  
thanks

---

<div class="post-metadata">

**Author:** ![Teki](https://dub1.discourse-cdn.com/flex005/user_avatar/forum.ewelink.cc/teki/32/1161_2.png) [@Teki](https://forum.ewelink.cc/u/Teki)\
**Post date:** [November 4, 2024, 1:55am UTC](https://forum.ewelink.cc/t/add-on-guide-node-red/15505/17 "2024-11-04T01:55:47Z")

</div>

when you hit the run button, click the ‘option’ to expand menu and select Network as Host.

---

<div class="post-metadata">

**Author:** ![tmalex](https://dub1.discourse-cdn.com/flex005/user_avatar/forum.ewelink.cc/tmalex/32/2966_2.png) [@tmalex](https://forum.ewelink.cc/u/tmalex)\
**Post date:** [January 18, 2025, 10:55pm UTC](https://forum.ewelink.cc/t/add-on-guide-node-red/15505/18 "2025-01-18T22:55:53Z")

</div>

> [@rolandoguedes](#):
>
> msg.payload = {  
> audio\_url: ‘[https://download.samplelib.com/mp3/sample-12s.mp3’](https://download.samplelib.com/mp3/sample-12s.mp3%E2%80%99)  
> };
> 
> return msg;

Can this REST API control the output volume?  
Like:  
{  
“audio\_url”: “…”,  
“volume”: 50  
}
