Http from HC2 to node red

I wonder if someone can point me in the right direction when i ask;
When i type 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

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

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

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

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

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.

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 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

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?

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 :slight_smile:
23

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

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??

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.

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

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

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

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

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

127.0.0.1 is local loopback IP

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?

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

HC2 is 192.168.10.154

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