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 to make Virtual Device work via REST API


Question

Posted

Hi All,\

 

I can make a normal fibaro device turn on and ofrf via rest api, via the url http://<<fibaro internal ip>>:11111/api/devices/<<Device ID>>/action/turnON BUT ...

I want to trigger a virtual device now via same REST API. But the confusion is, Virtual Device has an IP in HC, plus works on port 80, so any idea what would be the URL and syntax if one wants to control Virtual Device via REST API.

 

To the below URL does not work in case of VD, as it works for normal relay devices ...

 

http://<<fibaro internal IP>>/api/devices/<<Virtual Device ID>>/action/turnON

 

this does not work,  ..... 

 

 

any assistance thnx

6 answers to this question

Recommended Posts

  • 0
Posted (edited)

What about /pressButton/4

instead of turnOn

guessing here

Edited by Jamie mccrostie
  • 0
  • Inquirer
  • Posted

    nope didnt work this is what I tried, see if you can recomend any change

     

    http://<<fibaro internal IP>>/api/devices/<<Virtual Device ID>>/pressButton/btnOn

     

    btnOn is the button ID

    • 0
    Posted (edited)

    @sam9s try

     

    http://username:password@ip/api/callAction?deviceID=xxx&name=pressButton&arg1=btnID

     

    ?

    Edited by Sirhideo
    • 0
  • Inquirer
  • Posted (edited)

    No Sirhideo, 

     

    this did not work, however got a perfect 405 OK response in postman, but the light did not turn on. Let me share some more details about the setup. \

     

    1. The virtual device I am trying to control is on Sonoff, running Tasmota firmware with an internal ip and port 80

    2. The other virtual device is on ESP8266, running ESP Easy

    not sure if this makes any difference. But both does not turn on

     

    below is the exact command I am using in postman

     

    http://Username:[email protected]/api/callAction?deviceID=xxx&name=pressButton&arg1=btnOn

     

    btnOn is the button ID

     

    Let me also share screenshots of the settings of the VD

     

    Please login or register to see this link.

     

    Please login or register to see this link.

     

    see if that helps ....

     

     

    Edited by sam9s
    • 0
    Posted (edited)

    @sam9s

     

    I do not know then, I think the most important thing is whether the button is really pressed or not? try make some debug message on your button no?

     

    I use this url all the time to press any VD button via a php server on the same LAN, and the button does its job, working perfectly.  It isn't really important to know what actual device the VD button is linking to,  that's other thing.  The action of the command is to press a button on a particular VD, the result is only pressed, or not pressed.

     

    and did you change the permission of your VD from configuration page so that your HC account can press?

     

    The IP address and port assigned to the VD has nothing to do with the command

     

    http://Username:[email protected]/api/callAction?deviceID=123&name=pressButton&arg1=3

     

    It just press the button number 3 of device ID 123, nothing more, given that your username you use has full control of the VD.

     

    Postman? I don't use this app, try simply use browser... and debug message on your button...

     

    Or have you tried to press the On Off directly from your HC to test the device response?

    Edited by Sirhideo
    • 0
  • Inquirer
  • Posted

    Hi Sirhideo, 

     

    Thanks for the reply, and you are correct even I think that ip and port should not be the issue, as the url, is just pressing the button. Not sure why it is not working.

    You should use post man (its a google plugin) its the best tool for testing Rest API. Anyway I did try using normal browser, and the response I get is .... {}  .. this two braces, but it does not presses the button. 

    This issue is ONLY there for VDs, the regular zwave devices works perfect.

     

    Anyway, after like gazillions attempts and trying my wits off, I just gave up and came up with an alternative way.

     

    I trigger the url for VD via Amazon ioT button that created a lambda function, where I have used ifttt as the trigger url, created a recipie that fires the same URL I want for the VD, and it works perfectly. The only drawback or gripe has I wanted all the controls via Fibaro app and doing this way I am using 3rd party apps to achieve the same.

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