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

help changin color text or incon in VD button


xantony

Question

Hello,

 

i am not into coding but i guess i need some help. I have a virtual device with 2 buttons, very simple, light1 on /light1 off . i would prefer to have just one toggle button. is it possible? moreover i need to find a way to express the status of the device. I am wondering if there is any way to i.e. change the color of the text into yellow in order to indicate the loght is ON.

 

could please anyone instruct me on how to do such a toggle button with a simple example ( if possible)

 

Thanks

Link to comment
Share on other sites

8 answers to this question

Recommended Posts

  • 0

Cannot be done... Easy

Please login or register to see this image.

/emoticons/default_smile.png" alt=":)" srcset="https://forum.fibaro.com/uploads/emoticons/[email protected] 2x" width="20" height="20" />

Link to comment
Share on other sites

  • 0
  • Inquirer
  • so i cannot create a virtual device with 4 toggle buttons and a way to show wether the button are pressed or not???? really???

    Link to comment
    Share on other sites

    • 0

    only if you add a label with the status maybe? so labels + button below... press button change label according to status but i do not think you can have the button change status/appearance!

    Link to comment
    Share on other sites

    • 0
  • Inquirer
  • thanks laurenamckay,

     could you please make an example? as i said i am not familiar with coding (LUA) but i want to make something very easy, on/off toggle button ( for lights) and viewing the status of the lamp ( whether is turned on or off) by wiewing the VD button. I would do the same for rollershutter but i thing it's not easy to show on the label the shutter level. I would be happy to learn how to do a light on/off toggle button that show me the status somehow.

     

    thanks for your help.

    Link to comment
    Share on other sites

    • 0

    Hi Xantony,

    I'm like you when it comes to the coding, but with some time and research you'll get the hang of it. Your idea is simple but what I find is that the learning curve (for coding in general) is quite high before you can get started on even simple things... but once you are there a world of opportunity opens :0)

     

    I'm sure there are much better ways of doing it (I'd love to see what more experienced coders can suggest), but here's what put together and that can get you started.

     

    In the example I have a Light switch with the ID 42 (you find the ID by navigating to it and looking at the URL...), a Virtual Device with ID 62 with a button and, as you can't change the text of a button, I added a Label with an ID called Light1. So adjust these in the code below to whatever you have in your setup.

     

    LUA code for the button:

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

    -- First check if the light is on or off so we can toggle it
    if (( tonumber(fibaro:getValue(42, "value")) > 0 ))
     
      -- When it is ON, we'll turn it OFF and change the Label to say OFF
    then
    fibaro:call(42, "turnOff");
    fibaro:call(62, "setProperty", "ui.Light1.value", "OFF");
     
      -- If it is OFF, we'll turn it ON and change the Label to say ON
    else
    fibaro:call(42, "turnOn");
    fibaro:call(62, "setProperty", "ui.Light1.value", "ON");
    end
     
    -- ------------------------------------------ --
     
    I have struggled hard to start to get the hang of it and know how helpful it is to get some examples to copy, paste and adjust rather than starting from scratch.
    Cheers
    Thor
    • Thanks 1
    Link to comment
    Share on other sites

    • 0
  • Inquirer
  • thor, i can't express my gratitude to people like you that understand and share! thank you! I appreciate a lot

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