Charmed Quark Systems, Ltd. - Support Forums and Community

Full Version: How do I have one set of control (on/off) buttons for multiple devices?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
I want to create a small UI for my PPC that will allow me to control the lights from it. I'd like to have a number of buttons along the top for the diff rooms. Below those I'd like to have controls for On, Off, and the level of lighting. When I tap on the "Living Room" button I can click the On button to turn on the Living room lights. Then I tap on "Kitchen" and click the same On buttong to turn on the kitchen lights. Is this possible? How do I do this?
Pretty easy in 2.0 using a global variable and an if-then. Set a global variable i.e., "RoomToControl"=LivingRoom when you tap the "living room" button.

Then, in the "On" command button, have the following (it's psuedo-code. The actual code looks scary, but it's mostly done through point&click so I won't post it)
Code:
IF GVar:RoomToControl = LivingRoom
THEN
   WhateverYouDoToTurnOnLivRmLights
ELSE
  IF GVar:RoomToControl = Kitchen
  THEN
     WhateverYouDoToTurnOnKitchenLights
   ENDIF
ENDIF
IVB Wrote:Pretty easy in 2.0 using a global variable and an if-then. Set a global variable i.e., "RoomToControl"=LivingRoom when you tap the "living room" button.

Then, in the "On" command button, have the following (it's psuedo-code. The actual code looks scary, but it's mostly done through point&click so I won't post it)
Code:
IF GVar:RoomToControl = LivingRoom
THEN
   WhateverYouDoToTurnOnLivRmLights
ELSE
  IF GVar:RoomToControl = Kitchen
  THEN
     WhateverYouDoToTurnOnKitchenLights
   ENDIF
ENDIF


Hmm, thats close, but not quite what I want. I want to have something more like:
"Devices::Field Write(GVAR:RoomToControl,100) On Click"

And any time I click the room button it will set the GVar:RoomToControl to the correct value.

I don't want to have to do a lot of IF statements. That makes it a pain to add any new rooms and the code gets very long when I have at least 8 rooms already.

Is this possible in 2.0?
As long as the lighting fields you want to write to are consistently named, then you can set up a variable in each button that can be used to then build up the correct field in the buttons of the overlay, by just appending a few things to a variable to build up the whole name, and then do the write.

If they are consistently enough named, then no logic would be required. I.e. if every reach had a XXXLights, where XXX is the name of the room, then just set the variable to that XXX value, then build up a string by setting a variable to XX value, then append Lights and then write the value.
Would you use a Global Variable if you want to control a device from multiple zones? If so why would you ever not make it a Global Variable?
Dean Roddey Wrote:As long as the lighting fields you want to write to are consistently named, then you can set up a variable in each button that can be used to then build up the correct field in the buttons of the overlay, by just appending a few things to a variable to build up the whole name, and then do the write.

If they are consistently enough named, then no logic would be required. I.e. if every reach had a XXXLights, where XXX is the name of the room, then just set the variable to that XXX value, then build up a string by setting a variable to XX value, then append Lights and then write the value.

Yup, all lights will be named consistently. I don't think I understand exactly how to do what you're saying though. In my current implementation I am only doing it on a single screen that is not using multiple overlays. I admit I still learning at this Smile I'd like to have just one variable (selectedLight) that any button can set and then when I click the On button it uses that variable name as in my wish code above.

Also, how do I go about getting a download of the 2.0 beta? Smile
Sendero Wrote:Yup, all lights will be named consistently. I don't think I understand exactly how to do what you're saying though. In my current implementation I am only doing it on a single screen that is not using multiple overlays. I admit I still learning at this Smile I'd like to have just one variable (selectedLight) that any button can set and then when I click the On button it uses that variable name as in my wish code above.

Also, how do I go about getting a download of the 2.0 beta? Smile
try this..

http://www.charmedquark.com/Web2/Downloa...1_7_15.Zip
Wait a bit and get the 1.7.16 version. It fixes some known issues, and you might as well start with that. I'm testing it now.
Quote:Yup, all lights will be named consistently. I don't think I understand exactly how to do what you're saying though. In my current implementation I am only doing it on a single screen that is not using multiple overlays. I admit I still learning at this Smile I'd like to have just one variable (selectedLight) that any button can set and then when I click the On button it uses that variable name as in my wish code above.

That'll work. The buttons at the top just set the variable. The buttons at the bottom, when pressed, use that variable to build up the name of the fields they will write to.

You will want to have an OnLoad of the template to set the variable to some initial value so that it's always set.
Dean Roddey Wrote:That'll work. The buttons at the top just set the variable. The buttons at the bottom, when pressed, use that variable to build up the name of the fields they will write to.

You will want to have an OnLoad of the template to set the variable to some initial value so that it's always set.

Cool, I'll wait for the next version of the beta to be ready.


In the meantime, another question: Is there an easy way to do search/replace on a set of widgets? The full experience UI has a number of lightswitch graphics for controlling lights in diff areas. When I make new areas I select the set of widgets and copy/paste them but then I manually have to go into each one and change the target. I figure there has to be an easier way to do this.
Pages: 1 2