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


  • 0

Question

Posted

How to use HTTP POST to push a new variable value to fibaro?

HC2 = Net.FHttp("192.168.0.8",80);

HC2:setBasicAuthentication("admin", "admin");

local payload = '{"id": 2, "tracking": 60}';

response ,status, errorCode = HC2:PUT("/api/users", payload);

if tonumber(status) == 200 then

fibaro:debug("GPS was set to = 60");

fibaro:setGlobal("DEAN", "HOME");

else

fibaro:debug("Status = "..status);

fibaro:debug("Error code = "..errorCode);

end

if fibaro can push it surely tasker can?

below is what i want to send via tasker http post...

curl --request PUT 'http://admin:[email protected]:80/api/globalVariables' \

--data 'name=DEAN&value=HOME'

8 answers to this question

Recommended Posts

  • 0
Guest merylion
Posted

Hi,

I am launching JS scriptlet with HTTP PUT request

I have not found HTTP PUT as a task.

Works perfect

Best Regards

Marcin

  • 0
  • Inquirer
  • Posted
    Hi,

    I am launching JS scriptlet with HTTP PUT request

    I have not found HTTP PUT as a task.

    Works perfect

    Best Regards

    Marcin

    Can you advise? JS scriplet?

    • 0
    Posted

    I use a php script to send data to hc2 via cURL, so it is possible for sure. But you need to ensure that you include the correct headers otherwise the HC2 won't accept the request. Also make sure to use the PUT method, not POST as it will replace the entire destination, thus erasing the other globals.

    • 0
  • Inquirer
  • Posted

    Dalle correct headers? this is all new to me? any advice or small example?

    • 0
    Posted

    I uploaded a package in a post called "Cross platform tablet interface" which is basically a php-package for a tablet interface. If you download the package, there is a script called "globaloutput.php" - this is the script I use to update globals on the HC2 and it includes the headers. You need to describe in the http-request that the receiver must accept the data package (the body) in the form of json, if you don't state this in your post, the receiver will just accept it as plain text and it wont know what to do with the response - this is the function of the header. It would be the same as opening an HTML-document in a browser without the browser knowing what to do with it, then it will just show the code, instead of the text and pictures you've included.

    Off the top of my head, I think the headers should look something like this:

    Please login or register to see this code.

    And then it really should work through cURL

    • 0
  • Inquirer
  • Posted

    I shall try now

    Please login or register to see this image.

    /emoticons/default_smile.png" alt=":)" srcset="https://forum.fibaro.com/uploads/emoticons/[email protected] 2x" width="20" height="20" /> your a good man! Thank you...

    [ Added: 2014-08-06, 10:04 ]

    Or lady?

    Please login or register to see this image.

    /emoticons/default_icon_wink.gif" alt=";-)" />

    • 0
    Posted
    I shall try now

    Please login or register to see this image.

    /emoticons/default_smile.png" alt=":)" srcset="https://forum.fibaro.com/uploads/emoticons/[email protected] 2x" width="20" height="20" /> your a good man! Thank you...

    [ Added: 2014-08-06, 10:04 ]

    Or lady?

    Please login or register to see this image.

    /emoticons/default_icon_wink.gif" alt=";-)" />

    HOW DARE YOU CALL ME A LADY

    Please login or register to see this image.

    /emoticons/default_icon_mrgreen.gif" alt=":mrgreen:" />

    Your welcome

    Please login or register to see this image.

    /emoticons/default_icon_wink.gif" alt=";-)" />

    • 0
  • Inquirer
  • Posted

    nailed it with restask and put command

    Please login or register to see this image.

    /emoticons/default_smile.png" alt=":)" srcset="https://forum.fibaro.com/uploads/emoticons/[email protected] 2x" width="20" height="20" /> thank you so much!

    Join the conversation

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

    Guest
    Answer this question...

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