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

Question about API to use with external application iRule


Question

Posted

Hello everyone,

 

I am trying to build a remote controller for my HC2, a simple one using simple api commands into irule. My goal is to, simply, switch light on and off and run and sto scenes. I am not into coding at all and i am just learning what i need to get where i want to. The question is simple ( I guess) : up to now i succeded in making my button to turn on my lights (callAction/api/?deviceID=55&name=turnOn), at the same time i realized i have to make a second button to turn them off !!! Simple question fo the experts : what command line should i use to make a toggle command on my buttons to ON/OFF a device or a scene each time button is pressed???

 

thanks for your help.

 

Antonio

7 answers to this question

Recommended Posts

  • 0
Posted

There is no way to toggle devices state directly with an HTTP call, you have to check device state first and the apply proper command.

  • 0
Posted

Or to do it via scene/VD, where the logic will be like IF ON, Then OFF ELSE ON

  • 0
Posted

Or to do it via scene/VD, where the logic will be like IF ON, Then OFF ELSE ON

 

Exactly, and then activate that with HTTP call.

  • 0
  • Inquirer
  • Posted

    that's a pity, it means i have to write a scene for every single device! can i do it a block scene or do i have to code it in lua? if yes could you please help me with a simple example?

     

    thanks again for your suggestion!

    antonio

    • 0
    Posted

    If you are using your irule application, i would suggest getting all the device status, depending on the status, allowing which button(on/off) to appear.

     

    or likewise, adding an if else to check if status is on, off, status is off, on ,doesn't hurt.

    • 0
  • Inquirer
  • Posted

    ok Malvin, thanks for your explanantion. i've got the concept but i am at zero level in coding! could please give an example of two option in terms of api command?

     

    A) how i get device status/button on-off appers

    B) if/else example

     

    sorry for bothering but there is barely nothing to learn on-line irule+HC2

     

    antonio

    • 0
    Posted

    can try using http api to get the device information, device status will be in it.

     

    after that using the device status, use if else to toggle among the status.

     

    its hard to give an example as i do not have irule with me and im not sure which one are you looking at.

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