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

How can I set the value of a global variable with a REST API call?


norman

Question

Hi!

 

Is there any way to set data from another device to HC2 with REST API call?

Is there any way to set the value of a global variable via a REST API call?

 

I tried to PUT "1234" to "http://<hc2-server>/api/globalVariables/TglAusgabe" - but I get response code 500.

 

Thanks, Norman

Please login or register to see this attachment.

Link to comment
Share on other sites

7 answers to this question

Recommended Posts

  • 1
  • Inquirer
  • Hi!

     

    >> Are you using the administrator user for this to work ?

    Yes, unfortunately. It just seems to be possible to set variables as an administrator.

     

    >> And are you able to set a global variable from a http.put from your own software ?

    I call the Fibaro API from a camera and with the standard possibilities of this camera I can only send http.get.

    So I wrote a PHP script as middleware that forward the call with authentication, path, parameters etc.

    But I can also set http.get parameters (method and body) to make a http.put, http.push or http.delete. Body has to be url-encoded JSON.

    The script needs an apache server with php support (a2enmod rewrite is necessary).

     

    .htaccess

    Please login or register to see this code.

    index.php

    Please login or register to see this code.

    Norman

    Edited by norman
    Link to comment
    Share on other sites

    • 1

    I think this might work. Restricted users can be given or denied access to scenes. Scenes accept an argument, for instance a json payload. Then that scene can write to the global variable. It is one-way only though...

    Link to comment
    Share on other sites

    • 0

    Hey Norman,

     

    you need to put json content to the api, not just the content.

     

    Please login or register to see this code.

    Bye

    Neospin

     

    PS: Schau mal unter

    Please login or register to see this link.

    da findest Du einiges an Content zum Home Center 2

     

    Link to comment
    Share on other sites

    • 0

    A couple of quick questions.

    Are you using the administrator user for this to work ?

    And are you able to set a global variable from a http.put from your own software ?

    Link to comment
    Share on other sites

    • 0

    Cool! I had similar thoughts on having a middle man to do stuff against the home center 2. This was a nice solution. As I mentioned in an earlier post I managed to get it to work. What I could wish for is that Fibaro would create a better user management. It would be great to have a REST API only user.

     

    Regards Par

    Edited by parper
    Link to comment
    Share on other sites

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