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

Playing around with virtual device


Guest Lode

Question

Guest Lode

Has anybody already been playing around with the "Main loop" thing in the new virtual devices ?

I tried a lot but i don't understand it i think.

Example :

I made a virtual device to arm my camera.

Buttontext : "Arm camera"

Is it possible that once the button is pressed to change the buttontext in : "Disarm camera".

That's what you can do with the main loop or am i wrong ?

Link to comment
Share on other sites

7 answers to this question

Recommended Posts

  • 0
Guest Kuuno
  • Inquirer
  • same for me, in another post i wrote:

    --------------------------

    for me it doesnt work

    in api have: "{"id":164,"name":"Yamaha sw","

    and in lua code i have:

    fibaro:debug(fibaro:getValue(164, "ui.button1.value"))

    fibaro:call(164, "setProperty", "ui.button1.value", "test")

    debug returns "" (empty) every time

    --------------------------

    Link to comment
    Share on other sites

    • 0

    I didn't try, but I think main loop, is to refresh the value for the slider.

    Exemple with xbmc, you can return the volume with api for the slider, so slider do not have value 0.

    Link to comment
    Share on other sites

    • 0
    Guest Lode
  • Inquirer
  • Main loop

    In main loop you can enter LUA code to be executed each second. You can use it e.g. for refreshing a virtual device´s elements. Examples of use: fibaro:call(1170, ˝setProperty˝, ˝ui.Label1.value˝, ˝program 1˝); - sets virtual device ID 1170 Label1 content to program 1 value. fibaro:call(1170, ˝setProperty˝, ˝ui.Slider1.value˝, ˝45˝); - sets virtual device ID 1170 Slider1 to the value of 45.

    To me it doesn't seem they're only taking about the slider.......

    Link to comment
    Share on other sites

    • 0
    Guest Lode
  • Inquirer
  • same for me, in another post i wrote:

    --------------------------

    for me it doesnt work

    in api have: "{"id":164,"name":"Yamaha sw","

    and in lua code i have:

    fibaro:debug(fibaro:getValue(164, "ui.button1.value"))

    fibaro:call(164, "setProperty", "ui.button1.value", "test")

    debug returns "" (empty) every time

    --------------------------

    I did the same thing and debug returns the correct string but you have to name it "Label1"

    Very odd......the button is not updated by the new string.

    Is this a bug or am i doing something wrong ?

    Link to comment
    Share on other sites

    • 0

    Kuuno,

    in api have: "{"id":164,"name":"Yamaha sw","

    and in lua code i have:

    fibaro:debug(fibaro:getValue(164, "ui.button1.value"))

    fibaro:call(164, "setProperty", "ui.button1.value", "test")

    debug returns "" (empty) every time

    for buttons you can't send a text, that is job for labels

    you must create device with label + button and then

    Please login or register to see this code.

    Link to comment
    Share on other sites

    • 0
    Guest Lode
  • Inquirer
  • aha.....now i got it !!!

    Please login or register to see this image.

    /emoticons/default_icon_biggrin.gif" alt=":-D" />

    Thx Andrew.

    [ Added: 2013-08-29, 18:38 ]

    I understand how labels are used now but i still don't understand how to implement that in your virtual device.

    What i mean is that you can update your labels in your code of the virtual device just as well.

    The main loop runs every second.

    Maybe a nice example will explane more.......

    Please login or register to see this image.

    /emoticons/default_icon_biggrin.gif" alt=":-D" />

    Link to comment
    Share on other sites

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