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


Question

Posted

hi

I am trying to make a Virtual Device button activate a http device. It does not work I put the code below

local http = net. HTTPClient ()
http : request ( 'https://my.zipato.com/zipato-web/remoting/attribute/set?serial=0120EB1A0E019551&apiKey=39d5765a-d4c8-45ed-9b33-801aae520b6c&ep=8e8c9506-8b33-4975-97f2-cb845cbef252&state=0',
    success =  function (response) fibaro: debug (response. data)  end,
    error  =  function (err) fibaro: debug ("Error:"  .. err)  end
})


Please login or register to see this attachment.

Please login or register to see this attachment.

8 answers to this question

Recommended Posts

  • 0
Posted

Hi, try to add "{" after your url and specify method:

Please login or register to see this code.

  • 0
Posted

For an VD you only can use Net.FHttp and not net.HTTPClient, also a VD does not support HTTPS, only a scene does.

So if you make a scene with the code jack.daniels provided and you make a VD that is calling the scene then you can make it work,

 

If you need more help, please let us know.

  • 0
  • Inquirer
  • Posted (edited)

    local http = net.HTTPClient({timeout=2000})
    http:request ( url,https://my.zipato.com/zipato-web/remoting/attribute/set?serial=0540EB1A0E019545122&apiKey=39d5765a-d4c8-45ed-9b33-801aae520b6c&ep=8e8c9506-8b33-4975-97f2-cb845cbef252&state=0
      {
        options={method = 'GET'},
        success =  function (response) fibaro: debug (response. data)  end,
        error  =  function (err) fibaro: debug ("Error:"  .. err)  end
      }
    )


    is this the code i need to copy to mij vd divice. it stil does not work

    Edited by marius de jong
    • 0
    Posted

    Hi @marius de jong,

     

    You have to create a scene with the following code:

    Please login or register to see this code.

    Save the scene and remember the scene ID (can be found on the tab "General" of the scene).

     

    Then in the VD you have to place the following code to the button:

    Please login or register to see this code.

    Don't forget to set it to "LUA code" in the VD, don't leave it to "String".

     

    • Like 1
    • 0
  • Inquirer
  • Posted

    Yes it works :).

    Now i only need to get buttons on my VD it now only shows a light and it is not visible in the scene maker as a device.

     

    image.png.c774622799ed77abc5f6e39e84e28cce.png

    • 0
  • Inquirer
  • Posted (edited)

    i got a button in mij display but the toggle fuction does not work is only goes off does not go back to on when preset again.




    local IconOn = 1001;
    local IconOff = 1002;

    local ThisDevice = fibaro:getSelfId();

    if Status == "IconOff" then
         fibaro:call(ThisDevice, "pressButton", "1");
         fibaro:call(ThisDevice, "setProperty", "currentIcon", IconOn);
         fibaro:debug("turned on light");
     else
         fibaro:call(ThisDevice, "pressButton", "2");
         fibaro:call(ThisDevice, "setProperty", "currentIcon", IconOff);
         fibaro:debug("turned off light");
    end  
    --


    Please login or register to see this attachment.

     

    Please login or register to see this attachment.

    Edited by marius de jong
    • 0
  • Inquirer
  • Posted

    i have it working now. i had to create a global value. "woonkamerlicht"
    and only a 1 button vd

    Please login or register to see this attachment.

     

    local IconOn = 1001;
    local IconOff = 1002;

    local ThisDevice = fibaro:getSelfId();

    local value = fibaro:getGlobalValue('woonkamerlicht')
     
    if (value == '1') then
         fibaro:call(ThisDevice, "setProperty", "currentIcon", IconOn);
         fibaro:setGlobal( 'woonkamerlicht', 2);
         fibaro:startScene(20)
         fibaro:debug("turned on light");
     else
         fibaro:call(ThisDevice, "setProperty", "currentIcon", IconOff);
         fibaro:setGlobal( 'woonkamerlicht', 1);
         fibaro:startScene(23)
         fibaro:debug("turned off light");
    end  
    -

    • 0
    Posted
    On 1/5/2018 at 9:35 AM, boerremk said:

    Hi @marius de jong,

     

    You have to create a scene with the following code:

    Please login or register to see this code.

    Save the scene and remember the scene ID (can be found on the tab "General" of the scene).

     

    Then in the VD you have to place the following code to the button:

    Please login or register to see this code.

    Don't forget to set it to "LUA code" in the VD, don't leave it to "String".

     

     

    Hi.

     

    How can I use this solution in HC3 ???

     

    Please help me.

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