# Http from HC2 to node red

**URL:** <https://discourse.nodered.org/t/http-from-hc2-to-node-red/11572>\
**Category:** General\
**Created:** [26 May 2019 22:44 UTC](https://discourse.nodered.org/t/http-from-hc2-to-node-red/11572 "2019-05-26T22:44:51Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![sucram](https://avatars.discourse-cdn.com/v4/letter/s/977dab/32.png) [@sucram](https://discourse.nodered.org/u/sucram)\
**Post date:** [26 May 2019 22:44 UTC](https://discourse.nodered.org/t/http-from-hc2-to-node-red/11572/1 "2019-05-26T22:44:51Z")

</div>

I wonder if someone can point me in the right direction when i ask;  
When i type [http://127.0.0.1:1880/play](http://127.0.0.1:1880/play) in a browser, i start a service i am using (Node red flow with http end-point).  
The flow is set up, runs when i type in above http , and i just need to send a request from fibaro hc2 , either virtual device or lua scene. This is my first attempt so i really don't know where to start..

Thanks in advance

---

<div class="post-metadata">

**Author:** ![Andrei](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/andrei/32/10446_2.png) [@Andrei](https://discourse.nodered.org/u/Andrei)\
**Post date:** [27 May 2019 00:48 UTC](https://discourse.nodered.org/t/http-from-hc2-to-node-red/11572/2 "2019-05-27T00:48:38Z")

</div>

Did you try using the contrib nodes specific for the device ?

> **[node-red-contrib-fibaro-hc2](https://flows.nodered.org/node/node-red-contrib-fibaro-hc2)**
>
> A Node-RED node bridge to Fibaro HC2

---

<div class="post-metadata">

**Author:** ![sucram](https://avatars.discourse-cdn.com/v4/letter/s/977dab/32.png) [@sucram](https://discourse.nodered.org/u/sucram)\
**Post date:** [27 May 2019 08:41 UTC](https://discourse.nodered.org/t/http-from-hc2-to-node-red/11572/3 "2019-05-27T08:41:11Z")

</div>

Hei, i had the node-red-contrib-fibaro-hc2 running in a flow but was having freezing issues with the server node constantly polling my system , so i am looking at another way to send commands fom hc2 to node red? Thanks for reply

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [27 May 2019 08:46 UTC](https://discourse.nodered.org/t/http-from-hc2-to-node-red/11572/4 "2019-05-27T08:46:41Z")

</div>

Maybe look at the http endpoint section of the cookbook for ideas [https://cookbook.nodered.org](https://cookbook.nodered.org)

---

<div class="post-metadata">

**Author:** ![sucram](https://avatars.discourse-cdn.com/v4/letter/s/977dab/32.png) [@sucram](https://discourse.nodered.org/u/sucram)\
**Post date:** [27 May 2019 11:07 UTC](https://discourse.nodered.org/t/http-from-hc2-to-node-red/11572/5 "2019-05-27T11:07:46Z")

</div>

Thanks for suggestion, but i can't find anything that resolves my problem.  
Just to mention, i have a flow with endpoint and response that is working , but can't send get request from Fibaro hc2 (either virtual device or scene - string or lua).  
Any suggestions or links are extremely welcome.  
Thanks again

 ![55](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/8/845e881ce67defa23ed3c92814c31daeea296bd8.png)

---

<div class="post-metadata">

**Author:** ![Andrei](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/andrei/32/10446_2.png) [@Andrei](https://discourse.nodered.org/u/Andrei)\
**Post date:** [27 May 2019 14:15 UTC](https://discourse.nodered.org/t/http-from-hc2-to-node-red/11572/6 "2019-05-27T14:15:56Z")

</div>

It will be easier to provide some guidance on Node-RED if you clarify some points

What are the nodes that you use on the rightmost side of your flow ? It is not possible to identify them only by the visual. Some kind of gateway perhaps ?

Second question: you want to send an HTTP request from Fibaro to Node-RED in order to trigger a flow. Is this correct ? Normally I would expect a different kind of question: how to send an HTTP from Node-RED to trigger something in the FIbaro device. At the end of the day it is not clear if you are questioning how to configure Fibaro to send the HTTP request or how to configure Node-RED for some other purpose.

---

<div class="post-metadata">

**Author:** ![sucram](https://avatars.discourse-cdn.com/v4/letter/s/977dab/32.png) [@sucram](https://discourse.nodered.org/u/sucram)\
**Post date:** [27 May 2019 14:33 UTC](https://discourse.nodered.org/t/http-from-hc2-to-node-red/11572/7 "2019-05-27T14:33:54Z")

</div>

Hei, the nodes to the right are node-red-contrib-lgtv. Set up and running my lg tv and netflix -youtube- etc, works..  
Correct that i want to send from fibaro to node red , i'm trying to configure fibaro to send HTTP request to node red. If i paste [http://127.0.0.1:1880/play](http://127.0.0.1:1880/play) in a browser the node red flow runs, i'm trying to send the same http from a fibaro lua scene or from a fibaro virtual device , so that the tv turns on when i switch on a light , and off again when i run fibaro scene sleep.  
Hope i have managed to explain myself?  
I really appreciate your help.  
Thanking you

---

<div class="post-metadata">

**Author:** ![Andrei](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/andrei/32/10446_2.png) [@Andrei](https://discourse.nodered.org/u/Andrei)\
**Post date:** [27 May 2019 14:57 UTC](https://discourse.nodered.org/t/http-from-hc2-to-node-red/11572/8 "2019-05-27T14:57:33Z")

</div>

Hi, I understand now. In such a case, we need another Fibaro user to step in to help as this is something specific to the device. I assume you already tried to search on Fibaro support page and forum (if any). Perhaps you could share a link to the device manual?

---

<div class="post-metadata">

**Author:** ![sucram](https://avatars.discourse-cdn.com/v4/letter/s/977dab/32.png) [@sucram](https://discourse.nodered.org/u/sucram)\
**Post date:** [27 May 2019 15:06 UTC](https://discourse.nodered.org/t/http-from-hc2-to-node-red/11572/9 "2019-05-27T15:06:28Z")

</div>

I have searched the fibaro forum , looking at GET API'S but can't find anything that helps me.  
The closest i came was this post 🙂  
 ![23](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/e/e9bc460e616d3c41d614a9574e16f9bf7364f698.png)

Fibaro scenes, as you know, are written in lua and virtual devices are set up as in below picture:

 ![19](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/9/9c15cf132511efba3f558db27c4361472b923898.png)

Sorry i can't be more factual with explanations, i am new to this terminology and send pictures in hope that they might explain my case??

---

<div class="post-metadata">

**Author:** ![Andrei](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/andrei/32/10446_2.png) [@Andrei](https://discourse.nodered.org/u/Andrei)\
**Post date:** [27 May 2019 18:07 UTC](https://discourse.nodered.org/t/http-from-hc2-to-node-red/11572/10 "2019-05-27T18:07:16Z")

</div>

I would be happy seeing you succeed in integrating your Fibaro gateway to Node-RED. Unfortunately, I would not be of much help. I have used Lua 5 years ago while playing with a nodeMCU module and then spend a few days doing some Lua coding for a bioinformatics contest in Rosalind web page. I liked the language but the truth is that I totally forgot everything Lua. I can see, however, in the last picture you shared, that you can select between Lua and String. This probably means (just a guess) that you can configure your virtual device with a TCP port (if not how you are supposed to send out a string)? If this is the case then it may be an alternative (an easier) route in my opinion. You can easily configure a TCP node in Node-RED to trigger flows.

---

<div class="post-metadata">

**Author:** ![Pierrev](https://avatars.discourse-cdn.com/v4/letter/p/eb9ed0/32.png) [@Pierrev](https://discourse.nodered.org/u/Pierrev)\
**Post date:** [28 May 2019 10:41 UTC](https://discourse.nodered.org/t/http-from-hc2-to-node-red/11572/11 "2019-05-28T10:41:16Z")

</div>

Hi Sucram,

I do not see the "/play" in your GET request in Fibaro(picture) .

This example is not specific to Node-Red, but should work.  
local response, status, errorCode = http:GET("/play")  
fibaro:debug(response)  
response = json.decode(response)

fibaro:debug("Current Device Status: "..status)  
fibaro:debug("Error Code: "..errorCode)

if status == "200" then  
fibaro:debug("Device Responded OK")  
else  
fibaro:debug("Device Did Not Respond")  
end

---

<div class="post-metadata">

**Author:** ![sucram](https://avatars.discourse-cdn.com/v4/letter/s/977dab/32.png) [@sucram](https://discourse.nodered.org/u/sucram)\
**Post date:** [28 May 2019 17:53 UTC](https://discourse.nodered.org/t/http-from-hc2-to-node-red/11572/12 "2019-05-28T17:53:12Z")

</div>

Hei Pierrev, i tried above code but no sucess, do i need headers request and response, (Lua).?  
Thanks for reply.

---

<div class="post-metadata">

**Author:** ![Pierrev](https://avatars.discourse-cdn.com/v4/letter/p/eb9ed0/32.png) [@Pierrev](https://discourse.nodered.org/u/Pierrev)\
**Post date:** [28 May 2019 18:49 UTC](https://discourse.nodered.org/t/http-from-hc2-to-node-red/11572/13 "2019-05-28T18:49:56Z")

</div>

Do you get any error in the Debug of the Button on the HC2?

---

<div class="post-metadata">

**Author:** ![sucram](https://avatars.discourse-cdn.com/v4/letter/s/977dab/32.png) [@sucram](https://discourse.nodered.org/u/sucram)\
**Post date:** [28 May 2019 18:52 UTC](https://discourse.nodered.org/t/http-from-hc2-to-node-red/11572/14 "2019-05-28T18:52:29Z")

</div>

I get this;  
[DEBUG] 20:52:13: 2019-05-28 20:52:13.033253 [fatal] Unknown exception: /opt/fibaro/scenes/435.lua:1: attempt to index global 'http' (a nil value)  
the exact url is; [http://127.0.0.1:1880/lgtv/youtube](http://127.0.0.1:1880/lgtv/youtube)

---

<div class="post-metadata">

**Author:** ![Pierrev](https://avatars.discourse-cdn.com/v4/letter/p/eb9ed0/32.png) [@Pierrev](https://discourse.nodered.org/u/Pierrev)\
**Post date:** [28 May 2019 19:00 UTC](https://discourse.nodered.org/t/http-from-hc2-to-node-red/11572/15 "2019-05-28T19:00:20Z")

</div>

127.0.0.1? This means you are executing command on HC2. Should be Node-Red IP

---

<div class="post-metadata">

**Author:** ![Pierrev](https://avatars.discourse-cdn.com/v4/letter/p/eb9ed0/32.png) [@Pierrev](https://discourse.nodered.org/u/Pierrev)\
**Post date:** [28 May 2019 19:02 UTC](https://discourse.nodered.org/t/http-from-hc2-to-node-red/11572/16 "2019-05-28T19:02:28Z")

</div>

127.0.0.1 is local loopback IP

---

<div class="post-metadata">

**Author:** ![sucram](https://avatars.discourse-cdn.com/v4/letter/s/977dab/32.png) [@sucram](https://discourse.nodered.org/u/sucram)\
**Post date:** [28 May 2019 19:04 UTC](https://discourse.nodered.org/t/http-from-hc2-to-node-red/11572/17 "2019-05-28T19:04:02Z")

</div>

Not so sure what you mean? I will have to google this, sorry i really am a newbie !!  
127.0.0.1 is IP for my node red flow.  
BTW i am executing all commands on the same network, ie  
from hc2 to ned red on same machine.

Reading a little now, do you mean i should use Ip localhost:1880?

---

<div class="post-metadata">

**Author:** ![Pierrev](https://avatars.discourse-cdn.com/v4/letter/p/eb9ed0/32.png) [@Pierrev](https://discourse.nodered.org/u/Pierrev)\
**Post date:** [28 May 2019 19:08 UTC](https://discourse.nodered.org/t/http-from-hc2-to-node-red/11572/18 "2019-05-28T19:08:01Z")

</div>

What is the IP address of your HC2? Your Node-Red PC should have IP in the same range. 127.0.0.1 can only be accessed locally. not through network

---

<div class="post-metadata">

**Author:** ![sucram](https://avatars.discourse-cdn.com/v4/letter/s/977dab/32.png) [@sucram](https://discourse.nodered.org/u/sucram)\
**Post date:** [28 May 2019 19:09 UTC](https://discourse.nodered.org/t/http-from-hc2-to-node-red/11572/19 "2019-05-28T19:09:29Z")

</div>

HC2 is 192.168.10.154

---

<div class="post-metadata">

**Author:** ![Pierrev](https://avatars.discourse-cdn.com/v4/letter/p/eb9ed0/32.png) [@Pierrev](https://discourse.nodered.org/u/Pierrev)\
**Post date:** [28 May 2019 19:10 UTC](https://discourse.nodered.org/t/http-from-hc2-to-node-red/11572/20 "2019-05-28T19:10:28Z")

</div>

Then your Node-red PC should have IP address assigned in the same range.

[Next page](https://discourse.nodered.org/t/http-from-hc2-to-node-red/11572.md?page=2)
