[SOLVED]Toggle on off button

Posted on
Mon Sep 02, 2013 6:16 am
mattggarland offline
Posts: 49
Joined: Jan 06, 2013

[SOLVED]Toggle on off button

I'm wanting a variable based display of a button i.e.
if variable is value 1 then button is green
if variable is value 2 then button is red

or something along the lines of
if variable is value 1 then button caption is some text
if variable is value 2 then button caption is some other text

does anyone know if there is a way to do this??

Along the same lines, does anyone know if there is a way to go to a specific control page based on a variable
i.e.
on button press (
if variable is value 1 then go to some control page
if variable is value 2 then go to some other control page
)

thanks
M

Posted on
Mon Sep 02, 2013 8:52 am
kw123 offline
User avatar
Posts: 8366
Joined: May 12, 2013
Location: Dallas, TX

Re: Toggle on off button

as for the button colors: just did this yesterday:

duplicate
image files (and there are several directories for variables, devices .. make sure you pick the right one)
.....green+on.png --> greenred.png
..... red+on.png --> greenred+on.png
then pick ....greenred in your control page that will show green for off and red for on
- and if you want it green=on, red =off rename the other way around
green+on.png--> greenred+on.png and
red+on.png-->greenred.png

hope that helps

Karl

Posted on
Mon Sep 02, 2013 4:59 pm
jay (support) offline
Site Admin
User avatar
Posts: 18220
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Toggle on off button

Caption text isn't dynamic, but of course you can just directly display the value of the variable...

There is currently no way to navigate to a control page based on a variable value though that's been requested before and it on our list of things to consider in future versions.

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Wed Jan 08, 2014 9:45 pm
thomasw offline
Posts: 135
Joined: Feb 13, 2011

Re: Toggle on off button

Hi there,
I found this question while looking for something else. But, I did set this up back in 2010 and am still using it on indigo touch.
I don't remember the details, but Matt and/or Jay helped me back then. I have a power button image in Control Pages screen of Indigo Touch.
If it sees that the variable for my alarm is "true", the button is Green in color. If it sees that the variable for my alarm is "false",
the button is Red in color. I hope you have this figured out by now? Just wanted to let you know that YES, it can be done.

Posted on
Tue Feb 04, 2014 12:37 pm
pgershon offline
Posts: 509
Joined: Jul 10, 2004

Re: Toggle on off button

Noticed that the button on my control pages goes from red (off) to green (on) on my mac, but stays green on iPhone. Is this an error you are aware of? I recall seeing something like this more than a year ago, but figured it would have been corrected.

Posted on
Tue Feb 04, 2014 3:26 pm
matt (support) offline
Site Admin
User avatar
Posts: 21417
Joined: Jan 27, 2003
Location: Texas

Re: Toggle on off button

I believe this thread will explain the situation and solution.

Image

Posted on
Wed Feb 05, 2014 9:26 am
pgershon offline
Posts: 509
Joined: Jul 10, 2004

Re: Toggle on off button

Thanks Matt. I read the other thread and I see and understand the problem, but not the solution. I have a button that shows the device state for my plugin (red for off, green for on). It works on the web and even in safari on my iPhone, but not in Indigo Touch control page. This is a device state variable, and not a variable I can change the name of

Posted on
Wed Feb 05, 2014 9:19 pm
matt (support) offline
Site Admin
User avatar
Posts: 21417
Joined: Jan 27, 2003
Location: Texas

Re: Toggle on off button

What are the specific file names for your device images?

And what type of device state is it? Is it a relay/sensor type of device and this is a boolean (on/off or true/false) state?

Image

Posted on
Thu Feb 06, 2014 7:49 am
pgershon offline
Posts: 509
Joined: Jul 10, 2004

Re: Toggle on off button

The device is a plugin - a Nuvo Concerto stereo receiver. It is a boolean on/off state.

Control page stats:

Display "Device State" for "Concerto-study" "Mode (on or off)"
As Image "PowerButton_small.png"
Caption "Power" "Right of Control"
Client Action "None"
Server action "toggle zone"

Posted on
Thu Feb 06, 2014 9:10 am
matt (support) offline
Site Admin
User avatar
Posts: 21417
Joined: Jan 27, 2003
Location: Texas

Re: Toggle on off button

That plugin is setting the value of the Mode state like this:

Code: Select all
servdev.updateStateOnServer("onOffState", value="OFF")

But probably should instead be doing:

Code: Select all
servdev.updateStateOnServer("onOffState", value=False)


Using "OFF" string (versus a boolean) as the argument to updateStateOnServer() changes the state from a boolean type to a string, which causes the basic image lookup to fail.

One workaround would be to use the more advanced image file names. This is a bit of a shotgun approach, but inside this folder:

Code: Select all
/Library/Application Support/Perceptive Automation/Indigo 6/IndigoWebServer/images/controls/devices/

Duplicate the file PowerButton_small.png four times with the names: PowerButton_small+.png, PowerButton_small+OFF.png, PowerButton_small+off.png, PowerButton_small+false.png.

Then duplicate the file PowerButton_small+on.png twice with the names: PowerButton_small+ON.png, PowerButton_small+true.png.

I believe that will handle all of the cases for that particular device state.

Image

Posted on
Thu Feb 06, 2014 3:18 pm
pgershon offline
Posts: 509
Joined: Jul 10, 2004

Re: Toggle on off button

I tried. did not seem to help. Will reboot computer later and see if that helps. I shut down indigo server and restarted to no avail

Posted on
Thu Feb 06, 2014 7:28 pm
matt (support) offline
Site Admin
User avatar
Posts: 21417
Joined: Jan 27, 2003
Location: Texas

Re: Toggle on off button

Move the file PowerButton_small.png to the desktop (so Indigo cannot find it), then stop and restart the Indigo Server. Does it work then?

Image

Posted on
Fri Feb 07, 2014 9:24 am
pgershon offline
Posts: 509
Joined: Jul 10, 2004

Re: Toggle on off button

Still no luck

Posted on
Fri Feb 07, 2014 9:42 am
RogueProeliator offline
User avatar
Posts: 2501
Joined: Nov 13, 2012
Location: Baton Rouge, LA

Re: Toggle on off button

Might be a silly question, but just in case you forgot (as I have done this before), did you go to your control page and update it to use the newly-copied/created PowerButton_small+.png image?

Adam

Posted on
Fri Feb 07, 2014 9:57 am
matt (support) offline
Site Admin
User avatar
Posts: 21417
Joined: Jan 27, 2003
Location: Texas

Re: Toggle on off button

Great question Adam, especially since I forgot that step was necessary. I'll bet that is it...

Image

Who is online

Users browsing this forum: No registered users and 11 guests