Jump to content

Welcome to Smart Home Forum by FIBARO

Dear Guest,

 

as you can notice parts of Smart Home Forum by FIBARO is not available for you. You have to register in order to view all content and post in our community. Don't worry! Registration is a simple free process that requires minimal information for you to sign up. Become a part of of Smart Home Forum by FIBARO by creating an account.

 

As a member you can:

  •     Start new topics and reply to others
  •     Follow topics and users to get email updates
  •     Get your own profile page and make new friends
  •     Send personal messages
  •     ... and learn a lot about our system!

 

Regards,

Smart Home Forum by FIBARO Team


need to sent two http Commands


meijer

Recommended Posts

Hello all

 

I have a automatic drawer opener.

It has its own website to make configs, but also you can open the draw via a http command

 

 

when I type http://192.168.173.209:81/login 

I get a login screen 

 

when I type 

Please login or register to see this link.

It logs in and shows the webpage of the drawer 

 

When I type 

Please login or register to see this link.

push

The draw will open

 

So i need to sent two 

Http urls

 

Please login or register to see this link.

 (to login)

Please login or register to see this link.

push (to open draw)

 

 

Did some reading but and came up with the following code in a VD:

 


local connection = Net.FHttp("192.168.173.209", 81); 
local command = "/login?pin=hallo"; 
local command2= "/push";
connection.GET(connection, command);
connection.GET(connection, command2);

 

Can see in a debug mode what I sent as command?

I get no error messages but nothing happens 

 

Thanks in advance 

 

Link to comment

HTTP calls in the HC3 are asynchronous. This means that if you run the two requests after each other, the second request will already be executed while the first is not yet ready. To fix this use this code:

 

Please login or register to see this code.

 

Note, this is simplified code as an example...

Edited by Joep
Error in code.
Link to comment
  • Topic Author
  • Please login or register to see this image.

    /monthly_2023_03/image.png.e1f518c2ed6168d2384fea924097b62f.png" />

     

    Thanks Joep,

     

    I get an error message: attempt to index global 'net' (a nil value)

     

    I hoop you can help me

     

    Kind regards

    Gert-jan 

     

     

     

     

     

    Link to comment

    I made an error defining the http module in the wrong scope (local). I edited the code in my previous post.

    Link to comment
  • Topic Author
  • Hello Joep

     

    This was not the solution for me.

    Please login or register to see this image.

    /monthly_2023_03/image.png.969151673c1cbf5579528c9c9f2599b1.png" />

     

    When I change the net.HTTPClient INTO Net.HTTPClient So with a capital N I get a different error

     

    image.png.c0f9a509461ad160ebaddde84cb69a70.png

     

    Could it be that I don't have the net.HTTPClient  class?

     

    I have a HC2

     

     

    Thanks 

     

    Gert-jan

     

     

     

     

    Edited by meijer
    Link to comment
    On 3/16/2023 at 11:51 AM, meijer said:

    I have a HC2

    I gave you code for the HC3. 😀

     

    This is a HTTP call on the HC2:

     

    Please login or register to see this code.

     

    Edited by Joep
    fix: error in success function
    Link to comment
    • 5 weeks later...

    One thing you could try is to print out the commands using the debug function to make sure they're being sent correctly. You can do this by adding the following lines to your code: bash Copy code local connection = Net.FHttp("192.168.173.209", 81) local command = "/login?pin=hallo" local command2 = "/push" print("Sending command 1: " .. command) connection.GET(connection, command) print("Sending command 2: " .. command2) connection.GET(connection, command2) This will print out the commands to the debug console so you can see exactly what's being sent.

    Link to comment

    Join the conversation

    You can post now and register later. If you have an account, sign in now to post with your account.

    Guest
    Reply to this topic...

    ×   Pasted as rich text.   Paste as plain text instead

      Only 75 emoji are allowed.

    ×   Your link has been automatically embedded.   Display as a link instead

    ×   Your previous content has been restored.   Clear editor

    ×   You cannot paste images directly. Upload or insert images from URL.

    ×
    ×
    • Create New...