Jump to content
  • 0

help changin color text or incon in VD button




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)



Link to post
Share on other sites

8 answers to this question

Recommended Posts

  • 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 post
Share on other sites
  • 0

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 post
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
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
fibaro:call(42, "turnOn");
fibaro:call(62, "setProperty", "ui.Light1.value", "ON");
-- ------------------------------------------ --
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.
Link to post
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.

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