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

Changing label of Virtual device with HTTP command


Question

Posted

Hi,

 

I have a HC2, and I am looking for the HTTP command for changing the value of a Virtual Device.

 

I found all kind of HTTP commands to turn devices on and off, or to start a scene, but i can't find the command to put a value in a label of a virtual device.

 

I think it has to be something like:

http://<ip-address>/api/callAction?deviceID=<virtualdeviceid>&name=

 

Can anyone help me?

 

7 answers to this question

Recommended Posts

  • 0
Posted

@RonOud

 

Check out the following posts:

 

  • 0
  • Inquirer
  • Posted

    @Barlow

     

    Thanks for the response.

     

    I checked both posts, but I only see solutions for changing the label of a VD with Lua code from within the HC2.

     

    I'm looking for a http command which I can use to change a label of a VD from outside the HC2, the same way as I can turn on a device with a http command from outside HC2 (http://<ip-address>/api/callAction?deviceID=<virtualdeviceid>&name=turnOn)

     

     

    • 0
    Posted (edited)

    I do not know a direct api call for your Problem. But you could create a scene with the LUA code for changing the label in it and execute it with a http request as a workaround.

    The problem will be... you cannot push values to use as Label.

    Edited by StefanS
    • 0
    Guest skarotech
    Posted (edited)

    Yes, you can do it via HTTP post command,

     

    create a string like so

    {"args":["ui.XXXX.value","123456"]}

     

    where XXXX is the name of the label, and 123456 is the text you want on the label, then do a post of the string to 

     

    http://#fibaro_ip#/api/devices/#fibaro_id#/action/setProperty

     

    You can also do the same for sliders

     

    {"args":["X","#device_value#"]}

     

    where X is the position number of the slider in the VD, and the post to

     

    http://#fibaro_ip#/api/devices/#fibaro_id#/action/setSlider

    Edited by skarotech
    • 0
  • Inquirer
  • Posted

    @skarotech

     

    I don't know understand the part with creating a string how it is constructed.

     

    I tried it with a piece of PHP code like this:

     

          $url = 'http://<ipadress>/api/devices/<deviceid>/action/setProperty';
          $myvars = ???????

          $ch = curl_init( $url );
          curl_setopt( $ch, CURLOPT_POST, 1);
          curl_setopt( $ch, CURLOPT_POSTFIELDS, $myvars);
     

    But how exactly must the piece of string look like?

     

     

     

     

     

     

    • 0
    Guest skarotech
    Posted

    @RonOud

     

    {"args":["ui.XXXX.value","123456"]} is a JSON object, you will need to create this in PHP as JSON, then send it as a string

     

    see 

    Please login or register to see this link.

    • 0
  • Inquirer
  • Posted (edited)

    @skarotech

     

    I'm terrible with JSON. I have tried several things to get the string layout via a JSON object, but with no succes.

    Somehow I have to put 2 values 

     

          $data = array(
              (object)array(
                  'args' => 'ui.zon.value' , '123456',
                ),
              );

          $myvars = json_encode($data);
          echo "$myvars";
     

    The output of the variabele is: [{"args":"ui.zon.value","0":"123456"}]

     

    When I try this:

     

          $data = array(
              (object)array(
                  'args' => 'ui.zon.value' ,
                  'args' => '123456',
                ),
              );

          $myvars = json_encode($data);
          echo "$myvars";
     

    The output of the variabele is offcourse:  [{"args":"123456"}]

    The second overwrite the first one.

     

    Can you (or anyone else) help me to get this correct.

     

     

     

    Edited by RonOud

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