Jump to content

Is there a way to cycle through multiple scenes using 1 KPL button?


Guest

Recommended Posts

I have 5.0.14 beta running on my system, as well as Polyglot with several node servers including Hue.

I have successfully created a scene controller using an 8-key KPL on 'H', that will successfully turn on/off, as well as Dim Up/Down on the selected light. (It's a Hue LED strip for under kitchen cabinets).

I would LIKE to use the 'G' button to cycle through various color options, such that each press of that button will change the color (as an example). Without getting too crazy, I was thinking about 4 favorite color modes.

As I'm not a big programmer, I was wondering if there's any easy way to do this without using state variables, and programming per se.

If this is NOT possible, could someone provide an example of what it would take to set this up with programming and variables?

Thanks in advance!

 

Tony

Link to comment

I think this would be best achieved with state vars and programs. Note: you HueFav MUST be a state variable and not an integer, or this code will not work.

State var 1: HueFav, init val = 1


Program 1:

If
$HueFav is 4
and (KPL.Button.G switched ON or KPL.Button.G switched OFF)

Then
$HueFav = 1

Else
(nothing)


Program 2:

If
$HueFav is NOT 4
and (KPL.Button.G switched ON or KPL.Button.G switched OFF)

Then
$HueFav =+ 1

Else
(nothing)

 

Program 3:

If
$HueFav = 1

Then
Set HueLights to setting xxx

Else
(nothing)

Program 4:

If
$HueFav = 2

Then
Set HueLights to setting yyy

Else
(nothing)

Program 5:

If
$HueFav = 3

Then
Set HueLights to setting aaa

Else
(nothing)

Program 6:

If
$HueFav = 4

Then
Set HueLights to setting ddd

Else
(nothing)

Hope this is helpful. ISY programming really isn't too difficult -- and you must be technically inclined if you're working with PolyGlot.

Best,

Ben

Link to comment

In addition to beninsteon above, those programs can use just one of the six codes available from most Insteon devices.

What this means is that you can use your Paddle up for the normal On, your paddle down for your normal off, and say the fade up (paddle up, long tap) for these sequences. I use one SwitchLinc to control about 20 different scenes, with 22 different lamps.

 

<EDIT: Single looping program may become unstable with oscillation of the state variable retriggerring the program. Removed to avoid future confusion.>

Another trick I used in my ensuite for an RGBWW rope around the room on the floor, was to add a "Wait 5 seconds, Turn lights off"  to the Then section. This way the colours rotate with each Fast Off paddle input but after 5 seconds of Waiting it turns them Off. So you get 5 seconds between each tap for colour change but when you come back later and do the same button tap the lights turn off.

So many programs to write....so little time!  :)

Link to comment

Hey Guys... thanks for the loop program tips.

I did manage to get the state variable to change on each button press, and loop back to the beginning as expected (with Prog 1).

I assumed that I could use this to cycle through the color scenes by creating an Insteon Scene that included the rope light as the only member of the scene as a responder, and customize the color for each scene.

 

Doing that results in nothing... Am I supposed to put the button I assigned into the scene as well? (And I thought that your button can only be a controller to one scene)... so perhaps I'm missing something.

 

I did create programs 3 and 4 (just testing until I have everything working), and pressing the button does NOT turn on the scene when it hits fav=1 or fav=2.

 

What am I missing?

 

All the best, Tony

Link to comment
5 hours ago, Tonyhuk said:

I did create programs 3 and 4 (just testing until I have everything working), and pressing the button does NOT turn on the scene when it hits fav=1 or fav=2.

What am I missing?

You don't need to put the button into the scene.

Are you sure you're using a state variable and not an integer?  If you are using a state variable, then you'll probably need to post your programs 3 and 4 for people to review.  Simply right-click on the program and choose "Copy to Clipboard" (not "Copy") and then you can paste them into your forum reply.

Link to comment

Yes, I'm sure I set the variable as a State Variable...

Moreover, Program 3 and Program 4 Are intended to turn on the scene indicated within the program.

 

Since I can't call specific Hue Scenes (as the Node Server doesn't read and store Hue Scenes), I 'believe' the best way of getting them is to set the Hue Scene through the phone app, refresh the Hue device in the ISY tree, and observe the values used to create that specific scene. (No different than having different scenes in Insteon with different dim conditions, etc).

Perhaps that's where I'm going wrong, but I can't be sure.

 

Here's what I have, as below:

 

KitRopeFav as State Var.

 

Program 1:

KPL Switcher 4 to 1 - [ID 000D][Parent 0001]

If
        $KitRopeFav is 4
    And 'Kitchen Lights / KPL Kitchen - Breakfast / KPL Kitchen - Unused F' is switched On
     Or 'Kitchen Lights / KPL Kitchen - Breakfast / KPL Kitchen - Unused F' is switched Off
 
Then
        $KitRopeFav  = 1
 
Else
   - No Actions - (To add one, press 'Action')
 

Program 2:

KPL Switcher add 1 - [ID 0015][Parent 0001]

If
        $KitRopeFav is not 4
    And 'Kitchen Lights / KPL Kitchen - Breakfast / KPL Kitchen - Unused F' is switched On
     Or 'Kitchen Lights / KPL Kitchen - Breakfast / KPL Kitchen - Unused F' is switched Off
 
Then
        $KitRopeFav += 1
 
Else
   - No Actions - (To add one, press 'Action')
 

Program 3:

AccEnergize - [ID 0016][Parent 0001]

If
        $KitRopeFav is 1
 
Then
        Set 'Accent Energize' On
 
Else
   - No Actions - (To add one, press 'Action')
 

Program 4:

AccSpringBloss - [ID 0017][Parent 0001]

If
        $KitRopeFav is 2
 
Then
        Set 'Accent Spring Blossom' On
 
Else
   - No Actions - (To add one, press 'Action')
 

Link to comment

You may want some parentheses.  Furthermore, it might be possible (or even beneficial) to combine your two variable programs (programs 1 and 2):

If
        $KitRopeFav is 4
    And

(  

'Kitchen Lights / KPL Kitchen - Breakfast / KPL Kitchen - Unused F' is switched On
     Or 'Kitchen Lights / KPL Kitchen - Breakfast / KPL Kitchen - Unused F' is switched Off

)
 
Then
        $KitRopeFav  = 1
 
Else
   $KitRopeFav += 1

 

As your programs were, both would have triggered and run TRUE if you tapped the OFF side of your switch.  Have you checked the value of your variable lately?  Might it be higher than 4?

Do programs 3 and 4 run properly if you select, right-click, run then?

Link to comment

I like this idea of consolidating the 1st 2 programs!

Can I simplify the OR statement to just check for off or on by changing the button toggle mode to Toggle Off ‘or’ Toggle On mode?

Since my goal is simply to have each button press run through the numbers of 1 thru x, then go back and do it again, I don’t really need the On/Off functionality. I’m already using a separate button for On/Off/Dim.

(And yes, I have extra buttons to use, so I’m OK with using 2 buttons to control that light... for the time being)


Sent from my iPhone using Tapatalk

Link to comment
1 hour ago, oberkc said:

You may want some parentheses.  Furthermore, it might be possible (or even beneficial) to combine your two variable programs (programs 1 and 2):

If
        $KitRopeFav is 4
    And

(  

'Kitchen Lights / KPL Kitchen - Breakfast / KPL Kitchen - Unused F' is switched On
     Or 'Kitchen Lights / KPL Kitchen - Breakfast / KPL Kitchen - Unused F' is switched Off

)
Then
        $KitRopeFav  = 1
Else
   $KitRopeFav += 1

 

As your programs were, both would have triggered and run TRUE if you tapped the OFF side of your switch.  Have you checked the value of your variable lately?  Might it be higher than 4?

Do programs 3 and 4 run properly if you select, right-click, run then?

I have deleted my single program above. Use of the Else section in this manner may case oscillation of the variable and program after the program modifies one of it's own trigger elements.

The single variable looper program should not function properly. My apologies for introducing this concept without proofing it again.
As per @oberkc the parenthesese are still required.

Link to comment

Good morning Larry!!

So, If I read this correctly, I SHOULDN'T consolidate the programs to increment the index number, correct?

 

Also, I'm struggling with the parenthesis aspect. In theory, I get this (like mathematical order of precedence)... but when I try to use them, I'm left with an empty parenthesis pair that I can't insert code into... (probably a newbie lack of understanding on the ISY interface)... is there a link I can read in the forum or in the guide that will help me with that?

As for my other comment, can I avoid the ( x or y) logic by simply setting my KPL button to either Toggle On or Toggle Off? The button press is intended to cycle the index, not actually control a device directly...

 

 

Link to comment

Never mind, I figured out the parentheses process. (Create the parenthesis, add the lines you want, then use move line up/down so they land inside the parenthesis). :-)

Everything works in terms of cycling through the index, so thanks everyone for that. Now I just need to figure out how to actually create the scene settings (i.e. different color choices) for each of my options.

As this is being done through the Hue Node Server, I can't really use Insteon-based commands to accomplish this.

I created 2 (to be 4 later) scenes, and made the device a responder in each of the scenes, hoping that I could simply adjust the color parameters inside of each scene for the effect I want. However, this doesn't seem to work.

 

Perhaps xKing might have some ideas (?)

Link to comment
1 hour ago, Tonyhuk said:

As for my other comment, can I avoid the ( x or y) logic by simply setting my KPL button to either Toggle On or Toggle Off? The button press is intended to cycle the index, not actually control a device directly...

Absolutely!  If your devices are keypad buttons, this is exactly the way I would do it.  The only question is whether you want the button in a perpetual state of ON or OFF.  

1 hour ago, Tonyhuk said:

So, If I read this correctly, I SHOULDN'T consolidate the programs to increment the index number, correct?

 

That sure sounds like his suggestion...to avoid consolidation.  While I have not tried this program, I must admit that it would surprise me a bit if his concern turned out to be realized.  Theoretically, I guess the consolidated program could cause an infinite loop, constantly changing the variable value and retriggering itself, changing the value again, retriggering again...etc....  I was just not sure that theory holds out here, whether by design or just the nature of computer latency.  My nature is also to use a single program but, perhaps, it is safest to keep them separate in retrospect.

Link to comment

So, thanks for that... I'm perfectly happy to keep the button in the perpetual 'off' state for this purpose.

 

Also, I had asked about how to change the settings for each key press, and I did manage to find out that the parameters for each scene can be adjusted in the program itself, no need for ISY Scenes!

 

Here's an example:

AccEnergize - [ID 0016][Parent 0001]

If
        $KitRopeFav is 1
 
Then
        Set 'Hue Lights / Hue Bridge / Accent lights' Set Color Aqua
        Set 'Hue Lights / Hue Bridge / Accent lights' Set Hue 41442
        Set 'Hue Lights / Hue Bridge / Accent lights' Set Saturation 75
        Set 'Hue Lights / Hue Bridge / Accent lights' Set Brightness 254
        Set 'Hue Lights / Hue Bridge / Accent lights' Set Color Temperature 6410° K
 
Else
   - No Actions - (To add one, press 'Action')
 

It took me a little more digging, and I think I'm finally on the right track!

Link to comment
1 hour ago, Tonyhuk said:

I created 2 (to be 4 later) scenes, and made the device a responder in each of the scenes, hoping that I could simply adjust the color parameters inside of each scene for the effect I want. However, this doesn't seem to work.

I don't know how important it is to use the node server, but hue lights can be controlled via network resource also, assuming you have the network module added to your ISY.  This approach would, I expect, allow one to cycle through different hue light settings (Color, brightness, etc...) in the way you desire.

But, I see you figured this out so...never mind.

Link to comment

Hah! That's a funny thing!

Yes, you are correct, I do believe that you can use Network Resources, but as I'm still fumbling through these programming ideas (I'm NOT a programmer... I help design data center storage systems for a living, no programming involved).

I also just figured out, by reading the Hue Developer site (meethue.com), that there actually is a precedent when selecting which values you send to the lights. 

The lights can be set with X/Y pairs (with number ranging from 0 to 1, with .WXYZ as the format), or you can send HSB (hue,saturation,brightness)... X/Y will always be given the precedent in terms of Hue response.

So, I modified the programs to reflect as such:

 

AccTropical - [ID 0019][Parent 0001]

If
        $KitRopeFav is 3
 
Then
        Set 'Hue Lights / Hue Bridge / Accent lights'  X 0.2961 Y 0.2253 Brightness 123 in 400 ms
 
Else
   - No Actions - (To add one, press 'Action')
 

This is one of the 4 programs I've created. Now here's where the Node Server can be very helpful... If you use your phone/tablet Hue application to set the scene (either built-in or user created), you can then go to the ISY Admin Console, and look at the current status of that device (press Query if needed to refresh). You are presented with the appropriate values that you would need!

 

Link to comment
42 minutes ago, Tonyhuk said:

Hah! That's a funny thing!

Yes, you are correct, I do believe that you can use Network Resources, but as I'm still fumbling through these programming ideas (I'm NOT a programmer... I help design data center storage systems for a living, no programming involved).

I also just figured out, by reading the Hue Developer site (meethue.com), that there actually is a precedent when selecting which values you send to the lights. 

The lights can be set with X/Y pairs (with number ranging from 0 to 1, with .WXYZ as the format), or you can send HSB (hue,saturation,brightness)... X/Y will always be given the precedent in terms of Hue response.

So, I modified the programs to reflect as such:

 

AccTropical - [ID 0019][Parent 0001]

If
        $KitRopeFav is 3
 
Then
        Set 'Hue Lights / Hue Bridge / Accent lights'  X 0.2961 Y 0.2253 Brightness 123 in 400 ms
 
Else
   - No Actions - (To add one, press 'Action')
 

This is one of the 4 programs I've created. Now here's where the Node Server can be very helpful... If you use your phone/tablet Hue application to set the scene (either built-in or user created), you can then go to the ISY Admin Console, and look at the current status of that device (press Query if needed to refresh). You are presented with the appropriate values that you would need!

 

The NodeServers present some advantages over Network Resources and vice versa.

With the NRs I require a line to set each lamp parameters before calling the unified NR but I see you are doing that with PolyGlot, anyway.
NRs do not allow you to read the current lighting settings and Polyglot does.
NRs are all self-contained in ISY and do not depend on a third party box/hub.

I use state variables for my major lighting setups. In my main gathering room I have variables $sGathRm.mode and $sGathRm.colour.
I have defined a bank of Integer variable constants for white light scenes, as well as colour scenes suchs as $cSTRIP.RED, $cHUE.AQUA, $cML.BLUE
   $c.MODE.FULLON, $c.MODE.DIM, $c.MODE.TV, $cMODE.READING etc.. Each constant variable has  predefined number assigned to it permanently.
I have a bank of programs for each control variable with each mode and colour, as appropriate, tha does the diry work. These are combinations of scene calls, node server device calls, Network Resorce calls etc... to do whatever it takes to get the lighting I want. Ramp speed is adjusted to make the various time delays look similar and smooth.

On the upper layer I have a bank of programs for each input from Alexa, GH, and a few SwitchLincs. These programs do very simple things like
If
   SwitchLinc is switched Fast On
Then
    set $sGathRm.mode = $cMODE.FULLON
    set $sGathRm.colour = $cMOOD.BRIGHT
Else
   ----

Any program can now one-line stuff a single integer into these control variables and change a bank of 22 lights of 10 different brands, and match the colour responses.
In addition, when you want to borrow a lamp to flash or change colour (garage door is open) , you can save the control variable into a temp location,  use the lamp or parameter for an indicator, and then write the saved setup back in one line of code, when the alarm is done.

Link to comment
1 hour ago, beninsteon said:

@larryllix I don't like using the else result in isy programs when there are multiple conditions - I worry that the program may get triggered inadvertently, for example on a reboot.

Agreed! You have to be very careful with Else and multiple conditions / triggers. Somebody had requested UDI abolish the Else as few years ago. :)
But what he really meant was to replace them with a "case" construct. :)

 

Link to comment

Archived

This topic is now archived and is closed to further replies.


  • Recently Browsing

    • No registered users viewing this page.
  • Who's Online (See full list)

  • Forum Statistics

    • Total Topics
      36.9k
    • Total Posts
      370.2k
×
×
  • Create New...