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

change a VD's label with PUT


Question

Posted (edited)

In   FIBARO FGHC REST API ACTIVE DOCUMENTATION   I tried to change the value of a VD's label (Ltest) with PUT.
The body
{
  "properties": {
    "ui.Ltest.value": "XY"
  }
}
doesn't succeed:
Response Body is "no content"
Response Code is 403

 

Which body has to be used?

- - - - - - -

 

today new attempt (as superuser):

with body

{"properties":{"ui.Ltest.value":"YYYYYX"}
}

I get

   Response Code  200

   Response Body: complete body (like GET)

 

   but VD's value has NOT changed !!

 

Somebody knows a solution?

- - - - - - -

 

Background: my raspberry can change a global variable simply by sending {"value":"new value"},

now it should change a VD's label ...

 

Edited by muc
new attempt

3 answers to this question

Recommended Posts

  • 0
Posted
Dnia ‎2017‎ ‎03‎ ‎20 o 00:15, muc napisał:

Background: my raspberry can change a global variable simply by sending {"value":"new value"},

now it should change a VD's label ...

 

How do you change the global variable from raspberry?

  • 0
  • Inquirer
  • Posted (edited)
    2 hours ago, adamkorski said:

     

    How do you change the global variable from raspberry?

     

    with node.js like this

     

    var http= require("http")

    var daten= ...

    var gvDaten= {}
    gvDaten.value= daten      or    = JSON.stringify(daten)
    var datGV= JSON.stringify(gvDaten)

    var optGV= {
      hostname: 'HC2_IP',
      port: 80,
      path: '/api/globalVariables/Global_Var_Name',
      method: 'PUT',
      auth: 'your_IP_adr:your_PW',   //  superuser's  hc2-login
      headers: {
        'Content-Type': 'application/json',
        'Content-Length': Buffer.byteLength(datGV)
      }
    }

    var req = http.request(optGV, function(res){
      console.log(res.statusCode);
      res.setEncoding('utf8')
      var antw= ""
      res.on('data', function(chunk) { antw += chunk })
      res.on('end', function() {
        console.log(antw)

      })
    })
    req.on('error', function(e) {
      console.log("problem:"+e.message);
    })
    req.write(datGV)
    req.end()

     

     

    great surprise:

    a scene with

    --[[

    %% globals

    Global_Var_Name

    --]]

    is NOT started

    ( it can be started by a POST request inside res.on('end', function(){ ... } )

     

    Edited by muc
    hostname: not Raspi_IP but HC2_IP
    • 0
  • Inquirer
  • Posted

    just found:

    a scene with

    --[[

    %% globals

    Global_Var_Name

    --]]

    will start when

    {"value":"1234567890","invokeScenes":true}

    is sent

     

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